Skip to content

A practical and imaginary ecommerce microservices, built with .Net 8, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.

License

Notifications You must be signed in to change notification settings

tguankheng016/dotnet-commerce-microservice

Repository files navigation

Project Overview

This is a practical and imaginary eCommerce system built with .NET 8 as the backend and React and Angular for the frontend. The system is designed using Microservices Architecture, Vertical Slice Architecture, and Clean 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:

OAuth project used:

For more details on frontend projects

Table of Contents

Goals Of This Project

  • ✅ Using Microservices and Vertical Slice Architecture as a high level architecture
  • ✅ Using Event Driven Architecture with RabbitMQ as Message Broker on top of MassTransit library
  • ✅ Using Inbox and Outbox pattern of MassTransit to ensure Exactly once Delivery and At Least One Delivery
  • ✅ Using gRPC for internal communication between microservices
  • ✅ Using MediatR library for CQRS implementation.
  • ✅ Using PostgresQL as the relational database.
  • ✅ Using MongoDB as the NoSQL database.
  • ✅ Using xUnit for unit testing and NSubstitute for mocking dependencies.
  • ✅ Using TestContainers and xUnit for integration testing.
  • ✅ Using Minimal APIs for handling requests.
  • ✅ Using Fluent Validation as Validation Pipeline Behaviour of MediatR.
  • ✅ Using EF Core to manage code first migration.
  • ✅ Using YARP reverse proxy as API Gateway.
  • ✅ Using OpenTelemetry and Jaeger 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.

Plan

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 ✔️

Technologies Used

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

The Domain And Bounded Context - Service Boundary

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

Quick Start

Prerequisites

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:

About

A practical and imaginary ecommerce microservices, built with .Net 8, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.

Resources

License

Stars

Watchers

Forks

Packages

No packages published