An application that uses Command Query Responsibility Segregation (CQRS) and Event Sourcing to implement a shopping cart system using the OpenCQRS framework.
Features
- Event Store and Read Model/Database using EntityFramework Core (InMemory Provider)
- Swashbuckle to generate API documentation + UI to explore and test endpoints
- AutoRest to generate a client library
- Validation with FluentValidation
- Native .NET Core Dependency Injection
Core Requirements
- .NET Core 2.1
Optional Requirements
- Docker
# build
dotnet build -c Release -o src/ShoppingCart.WebApi
# start the app
dotnet src/ShoppingCart.WebApi/bin/Release/netcoreapp2.1/ShoppingCart.WebApi.dll
# access
https://localhost:5001 # -- this will open Swagger UI
Running on Docker
dotnet restore
dotnet publish -o publish -c Release
docker build -t djamseed/shopping-cart-api .
docker run -it --rm -p 5000:80 -t djamseed/shopping-cart-api .
#access
http://localhost:5000 # -- this will open Swagger UI
Based on the Onion Architecture
CQRS/ES using OpenCQRS
POST /api/v1/cart
{
"customerId": "90ab0d48-6253-4189-a7c2-24f1f8862809"
}
POST /api/v1/cart/{cartId}
{
"productName": "item-1",
"price": 500,
"quantity": 2
}
PUT /api/v1/cart/{cartId}
{
"productName": "item-1",
"quantity": 5
}
DELETE /api/v1/cart/{cartId}
{
"productName": "item-1"
}
DELETE /api/v1/cart/{cartId}/clear
- Customer already have an account and is authenticated
- Stock management is done externally
- API doc is available via Swagger and testing can be done by Swagger UI (https://localhost:5001)