The Orders Processing Service
is a basic CRUD ASP.net core application that connects with MongoDB that was requested as a coding task during an interview process.
It displays a simple scenario where you can add/update/delete/retrieve orders in a business application.
Order Model
{
"id": "guid",
"userId": "guid",
"amount": "int"
}
API endpoints are versioned as v1
v1/orders/by-users
endpoint returns an aggregation of the orders grouped by userId with a sum of the total amount of the orders.
{
"userId": "guid",
"orders": [
"guid"
],
"totalAmount": "int"
},
- Instead of running my own MongoDB instance I use a free tier on MongoDB Cloud Atlas.
- I use AutoMapper to map between domain models and API models.
- I use Moq and XUnit for unit testing the
OrdersService
. - I use Swagger for API documentation.
Due to time constraints there are some "Missing" features that I would normally implement in a "Real World" Project. Some of them are the following:
- Authentication and Authorization using something like
Identity
andJWT
. - Add pagination to the endpoints including limit and offset.
- Complete separation between Domain Models and Database Models.
- Generic implementation of the
Repository Pattern
when other repositories are introduced to the service. - In Memory DB or Mock to run integration tests.
- Separate concerns between
Queries
andCommands
. - HealthCheck endpoint that shows Database Integrity. For that, I like this library.
On a terminal with OrdersProcessingService as root run the following commands:
docker build -t orders-service .
docker run -p 8080:80 orders-service
open https://localhost:8080/index.html for the swagger page
On a terminal with OrdersProcessingService.Api as root run the following commands:
dotnet restore
dotnet build
dotnet run