Skip to content

hamsheed-salamut/musicbrainz-api

Repository files navigation

Components

The application has two main components:

  • Web API
  • Client App

WebApi Endpoints

The application has provisioned two API endpoints to demonstrate the requests of searching an artist and the albums of a particular artist.

URI

<base_url>: http://localhost:5000/

  1. <base_url>/api/artist/search/<artist_name>/<page_number>/<page_size> [HttpGet] - To search an artist by name
  2. <base_url>/api/artist/album/<artist_id>/<album_count> [HttpGet] - To search the first number (n) of albums for a given Artist Id

Postman Collection

Run in Postman Download Collection

Swagger: API Documentation

When running the WebAPI, the swagger UI can be accessed through the swagger endpint "/swagger/index.html"

Third-Party MusicBrainz API

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.

Running Locally

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

Setup

Prerequisites

This application requires .NET SDK 6.0.401 and Docker

Technologies

  • Entity Framework Core 6.0.10
  • Serilog
  • RestSharp
  • Polly
  • Fluent Validation

Infrastructure

Docker Compose Files

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

Database Seeding

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.

Web API Health Checks

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"}

Unit Tests

For unit tests we use xUnit. These tests cover validators and repository.

To run unit tests, run dotnet cake or dotnet cake --target=__UnitTest

Instrumentation

Serilog sink has been used that writes events to the Seq structured log server.

About

Consume API and expose API endpoints

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published