This is a practical and imaginary eCommerce system built with
.NET 8
as the backend andReact
andAngular
for the frontend. The system is designed usingMicroservices Architecture
,Vertical Slice Architecture
, andClean Architecture
principles. The goal is to demonstrate a scalable, maintainable, and testable approach for building modern eCommerce applications.
This project is extended from dotnet-commerce-monolith repository.
Other versions of this project are available in these repositories:
- https://github.com/tguankheng016/dotnet-commerce-monolith
- https://github.com/tguankheng016/golang-ecommerce-microservice
- https://github.com/tguankheng016/golang-ecommerce-monolith
OAuth project used:
For more details on frontend projects
- The Goals of This Project
- Plan
- Technologies Used
- The Domain and Bounded Context - Service Boundary
- Quick Start
- ✅ Using
Microservices
andVertical Slice Architecture
as a high level architecture - ✅ Using
Event Driven Architecture
withRabbitMQ
as Message Broker on top ofMassTransit
library - ✅ Using
Inbox
andOutbox
pattern ofMassTransit
to ensureExactly once Delivery
andAt Least One Delivery
- ✅ Using
gRPC
forinternal communication
between microservices - ✅ Using
MediatR
library forCQRS
implementation. - ✅ Using
PostgresQL
as the relational database. - ✅ Using
MongoDB
as the NoSQL database. - ✅ Using
xUnit
for unit testing andNSubstitute
for mocking dependencies. - ✅ Using
TestContainers
andxUnit
for integration testing. - ✅ Using
Minimal APIs
for handling requests. - ✅ Using
Fluent Validation
asValidation Pipeline Behaviour
of MediatR. - ✅ Using
EF Core
to manage code first migration. - ✅ Using
YARP
reverse proxy as API Gateway. - ✅ Using
OpenTelemetry
andJaeger
for distributed tracing. - ✅ Using
OpenIddict
for authentication based on OpenID-Connect and OAuth2. - ✅ Using
Angular
to build admin facing application. - ✅ Using
React
to build consumer facing application. - ✅ Using
Azure Key Vault
to manage the secrets. - ✅ Using
Github Actions
as CI/CD pipeline. - ✅ Using
AWS EC2
for hosting.
This project is a work in progress, new features will be added over time.
Feature | Status |
---|---|
API Gateway | Completed ✔️ |
Identity Service | Completed ✔️ |
Product Service | Completed ✔️ |
Cart Service | Completed ✔️ |
Admin Portal | Completed ✔️ |
EShop | Completed ✔️ |
-
.NET 8
- The latest stable version of .NET for building high-performance applications. -
MVC Versioning API
- Set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core. -
EF Core
- Modern object-relational mapper for .NET that enables LINQ queries, change tracking, updates, and database schema migrations. -
AspNetCore OpenApi
- Provides built-in support for OpenAPI document generation in ASP.NET Core. -
Masstransit
- Distributed Application Framework for .NET. -
MediatR
- About Simple, unambitious mediator implementation in .NET -
FluentValidation
- Popular .NET validation library for building strongly-typed validation rules. -
Swagger UI
- Swagger tools for documenting API's built on ASP.NET Core. -
Serilog
- Simple .NET logging with fully-structured events -
Polly
- Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. -
Scrutor
- Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection -
OpenIddict
- Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET. -
Opentelemetry-dotnet
- The OpenTelemetry .NET Client -
Jaeger
- About CNCF Jaeger, a Distributed Tracing Platform -
EasyCaching
- Open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier. -
Redis
- Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps. -
Mapperly
- A .NET source generator for generating object mappings. No runtime reflection. -
NSubstitute
- A friendly substitute for .NET mocking libraries. -
Yarp
- Reverse proxy toolkit for building fast proxy servers in .NET. -
MongoDB.Driver
- .NET Driver for MongoDB. -
gRPC-dotnet
- gRPC functionality for .NET. -
RabbitMQ
- Reliable and mature messaging and streaming broker, which is easy to deploy on cloud environments, on-premises, and on your local machine -
xUnit
- A free, open source, community-focused unit testing tool for the .NET Framework. -
Bogus
- A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js. -
Testcontainers
- Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers.
-
Identity Service
- The Identity Service is a bounded context responsible for user authentication and authorization. It handles user creation along with assigning roles and permissions through .NET Core Identity and JWT-based authentication and authorization. -
Product Service
- The Product Service is a bounded context responsible for handling CRUD operations related to product management. -
Cart Service
- The Cart Service is a bounded context responsible for handling CRUD operations related to cart management.
Before you begin, make sure you have the following installed:
- .NET 8 SDK
- Docker
Once you have .NET 8 and Docker installed, you can set up the project by following these steps:
Clone the repository:
git clone https://github.com/tguankheng016/dotnet-commerce-microservice.git
Run the development server:
cd deployments/docker-compose
docker-compose -f docker-compose.yml up -d
Once everything is set up, you should be able to access:
- Gateway: http://localhost:5081
- Identity Service: http://localhost:5196
- Product Service: http://localhost:5285
- Cart Service: http://localhost:5118