Skip to content

C# CRUD API connected to Mongo DB requested as part of an interview process.

Notifications You must be signed in to change notification settings

Raagh/orders-processing-service

Repository files navigation

Orders Processing Service

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

Dependencies

  • 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.

Extra included features.

  • Deployable as a Docker container.
  • The default URL shows a Swagger page with the API documentation.

Possible Improvements

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 and JWT.
  • 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 and Commands.
  • HealthCheck endpoint that shows Database Integrity. For that, I like this library.

Run on docker

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

Run on dotnet

On a terminal with OrdersProcessingService.Api as root run the following commands:

dotnet restore
dotnet build
dotnet run

About

C# CRUD API connected to Mongo DB requested as part of an interview process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published