This is step-by-step development of reference microservices architecture that include microservices on .NET platforms which used ASP.NET Web APIDockerRabbitMQMassTransitGrpcYarp API GatewayPostgreSQLRedisSQLiteSqlServerMartenEntity Framework CoreCQRSMediatRDDDVertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12.

There is a couple of microservices which implemented E-Commerce Microservices, those are CatalogBasketDiscountOrderingYarpApiGateway microservices and Shopping.Web Client Application.

These microservices data’s will store NoSQL and Relational databases
with communicating over gRPC and RabbitMQ Event Driven Communication and also using Yarp API Gateway for client operations.

Lets deep dive into internal architectures of microservices:

Catalog Microservice

  • Using ASP.NET Core Minimal APIs and latest features of .NET8 and C# 12
  • Vertical Slice Architecture implementation with Feature folders and single .cs file includes different classes in one file
  • CQRS implementation using MediatR library
  • CQRS Validation Pipeline Behaviors with MediatR and FluentValidation
  • Use Marten library for .NET Transactional Document DB on PostgreSQL, so Product microservices database will be PostgreSQL but acting as a Document DB using Marten library
  • Use Carter for Minimal API endpoint definition
  • Cross-cutting concerns LoggingGlobal Exception Handling and Health Checks
  • Implement Dockerfile and docker-compose file for running Product microservice and PostgreSQL database in Docker environment

Basket Microservice

  • All above Catalog Microservice items into Basket Microservice
  • ASP.NET 8 Web API application, Following REST API principles, CRUD
  • Using Redis as a Distributed Cache over basketdb
  • Implements ProxyDecorator and Cache-aside patterns
  • Consume Discount Grpc Service for inter-service sync communication to calculate product final price
  • Publish BasketCheckout Queue with using MassTransit and RabbitMQ
  • Containerize Basket Microservices with Redis and PostgreSQL database

Discount Microservice

  • ASP.NET gRPC Service application
  • Build a Highly Performant inter-service gRPC Communication with Discount and Basket Microservice
  • gRPC Communications, Proto files CRUD operations
  • Exposing Grpc Services with creating Protobuf messages
  • SQLite database connection and containerization
  • Entity Framework Core ORM — SQLite Data Provider and Migrations to simplify data access and ensure high performance
  • N-Layer Architecture implementation
  • Containerize Discount Microservices with SQLite database using Docker Compose

Ordering Microservice

  • ASP.NET Core Web Minimal APIs for building fast HTTP APIs-fully functioning REST endpoints for CRUD operations
  • Implementing DDDCQRS, and Clean Architecture with using Best Practices
  • Apply SOLID PrinciplesDependency Injection
  • Raise and handle Domain Events & Integration Events
  • Entity Framework Core Code-First ApproachMigrations, DDD Entity Configurations
  • Clean Architecture implementation on Entity Framework and SQL Server
  • Consuming RabbitMQ BasketCheckout event queue with using MassTransit-RabbitMQ Configuration
  • Containerize Ordering Microservices with SQL Server database

Microservices Async Communication w/ RabbitMQ & MassTransit

  • Async Microservices Communication with RabbitMQ Message-Broker Service
  • Using RabbitMQ Publish/Subscribe Topic Exchange Model
  • Using MassTransit for abstraction over RabbitMQ Message-Broker
  • Publishing BasketCheckout event queue from Basket microservices and Subscribing this event from Ordering microservices
  • Create RabbitMQ EventBus.Messages library and add references Microservices
  • Containerize RabbitMQ Message Queue system with Basket and Ordering microservices using Docker Compose

YarpApiGateway Microservice

  • Develop API Gateways with Yarp Reverse Proxy applying Gateway Routing Pattern
  • Yarp Reverse Proxy ConfigurationRoute, Cluster, Path, Transform, Destinations
  • Rate Limiting with FixedWindowLimiter on Yarp Reverse Proxy Configuration
  • Containerize YarpApiGateway Microservices using Docker Compose

Shopping Web Client Application

  • ASP.NET Core Razor Web Application with Bootstrap 4 and Razor template
  • Consume YarpApiGateway APIs using Refit Library with Generated HttpClientFactory
  • Bootstrap 4 Theme Implementation
  • ASP.NET Core Razor Tools — View Components, Partial Views, Tag Helpers, Model Bindings and Validations, Razor Sections etc.
  • Containerize Shopping Web Client Application using Docker Compose

Patterns, Principles, Libraries, Communications, Best Practices

  • Implement different architecture styles: DDD, Vertical Slice and Clean Architecture
  • Implement different patterns: SOLID PrinciplesDependency Injection principles, CQRS and Mediator PatternOptions PatternProxy and Decorator PatternPublish-Subscribe PatternApi Gateway PatternCache-aside Pattern
  • Implements different Database types: NoSQL and Relational: Transactional DocumentDB, PostgreSQLSQLiteSQL ServerDistributed Caches (Redis) and Message brokers async communication with RabbitMQ and Masstransit library
  • Use Popular .NET libraries: CarterMartenMediatRFluentValidationMapsterMassTransitEF CoreRefit
  • Implement different communication stylesSync and Async communication between microservices
  • Build a Highly Performant inter-service gRPC Communication with Discount and Basket Microservice
  • Microservices Async Communication Publish Subscribe Pattern w/ RabbitMQ & MassTransit for Checkout Basket Between Basket-Ordering Microservices
  • Building API Gateways with Yarp Reverse Proxy applying Gateway Routing Pattern

Source Code on Live GitHub Repository

You can reach latest EShop Microservices GitHub Repository in this link.

I am also developing aspnetrun repositories on GitHub with latest .NET 8 and create courses from these repositories. So this course is the main repository of the aspnetrun ecosystem and this is a lively course and evolves with repository changes.