Skip to content

IMAuhammad/shopping-basket

Repository files navigation

Shopping Basket

An application that implements a Command Query Responsibility Segregation (CQRS) and Event Sourcing framework to implement and manage a shopping basket system using EventFlow 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 done with FluentValidation

Install

Core Requirements

  • .NET Core 2.1

Usage

# build
dotnet build -c Release -o src/ShoppingBasket.WebApi

# start the app
dotnet src/ShoppingBasket.WebApi/bin/Release/netcoreapp2.1/ShoppingBasket.WebApi.dll

# access
https://localhost:5001/swagger # -- this will open Swagger UI

Architecture

System is based on the Onion Architecture

Onion Architecture


CQRS/ES using EventFlow

Assumptions

  • Product management is done externally
  • Customer account already exists in the system

API Endpoints

CREATE BASKET

POST /api/v1/basket
{
  "customerId": "eb042700-242e-49ee-9a5b-842a9cabb455"
}

GET BASKET

GET /api/v1/basket/{basketId}

ADD ITEM TO BASKET

POST /api/v1/basket/{basketId}
{
  "productName": "Product 1",
  "price": 10.99,
  "quantity": 2
}

UPDATE BASKET ITEM QUANTITY

PUT /api/v1/basket/{basketId}
{
  "productName": "Product 1",
  "quantity": 4
}

REMOVE ITEM FROM BASKET

DELETE /api/v1/basket/{basketId}
{
  "productName": "Product 1"
}

CLEAR BASKET

DELETE /api/v1/basket/{basketId}/clear

Notes

About

A shopping basket system using EventFlow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages