The application has two main components:
- Web API
- Client App
The application has provisioned two API endpoints to demonstrate the requests of searching an artist and the albums of a particular artist.
<base_url>: http://localhost:5000/
- <base_url>/api/artist/search/<artist_name>/<page_number>/<page_size> [HttpGet] - To search an artist by name
- <base_url>/api/artist/album/<artist_id>/<album_count> [HttpGet] - To search the first number (n) of albums for a given Artist Id
When running the WebAPI, the swagger UI can be accessed through the swagger endpint "/swagger/index.html"
To retrieve an artist related information, the following API endpoint has been invoked:
http://musicbrainz.org/ws/2/release/?query=arid:{artistId}
This has been parameterized in the appsettings.json
of the application for flexibility of alterations.
To bring up the whole application on Docker, run the following command on a terminal:
docker-compose -f docker-compose.infra.yml -f docker-compose.app.yml up -d
Use the build --no-cache
flag to force docker to rebuild the images and pick up the latest changes.
This will spin up both the infrastructure and the application components:
Service | URL | Description |
---|---|---|
WebApi | http://localhost:5000/ | WebAPI endpoints base url |
Seq | http://localhost:5341 | UI for Seq Structured Logs |
Swagger | http://localhost:5000/swagger/index.html | Swagger API documentation |
This application requires .NET SDK 6.0.401 and Docker
- Entity Framework Core 6.0.10
- Serilog
- RestSharp
- Polly
- Fluent Validation
There are two docker compose files in this solution:
docker-compose-infra.yml
This file contains the necessary infrastructure which the API requires to be operation. This file will spawn an SQL Server instance, a Seq instance and seed the SQL database with some data.
docker-compose-app.yml
This file contains the application components which are the Web API and Client App
By default when the docker-compose.infra.yml
will be executed, a database MusicBrainz
will be created and some sample data will be automatically seeded into the Artist
table.
Health checks reports for this application are exposed as a HTTP endpoint. Ping http://localhost:5000/health
to get the entire report.
{"Status":"Healthy","HealthChecks":[],"HealthCheckDuration":"00:00:00.0000715"}
For unit tests we use xUnit. These tests cover validators and repository.
To run unit tests, run dotnet cake
or dotnet cake --target=__UnitTest
Serilog sink has been used that writes events to the Seq structured log server.