Skip to main content

Overview

AspNetRun Microservices is a production-ready reference implementation showcasing modern microservices architecture on .NET 8. This project demonstrates best practices for building scalable, distributed systems with real-world e-commerce scenarios across Catalog, Basket, Discount, and Ordering services.

Quick Start

Get the entire microservices stack running in minutes with Docker Compose

Prerequisites

Required tools and environment setup for development

Architecture Overview

Understand the system design and architectural patterns

Microservices

Explore each microservice implementation in detail

Key Features

This reference architecture implements cutting-edge patterns and technologies for building microservices:
  • Catalog Service: Product catalog with Vertical Slice Architecture and Marten (DocumentDB on PostgreSQL)
  • Basket Service: Shopping cart with Redis caching and gRPC integration
  • Discount Service: Discount management via gRPC with SQLite and Entity Framework Core
  • Ordering Service: Order processing with DDD, Clean Architecture, and SQL Server
  • API Gateway: YARP reverse proxy with rate limiting and routing
  • Shopping Web: ASP.NET Core Razor Pages application with Refit HTTP client
  • Domain-Driven Design (DDD): Rich domain models with aggregates, entities, and value objects
  • CQRS Pattern: Command Query Responsibility Segregation using MediatR
  • Clean Architecture: Separation of concerns with Domain, Application, Infrastructure layers
  • Vertical Slice Architecture: Feature-focused organization in Catalog service
  • Event-Driven Architecture: Asynchronous communication via RabbitMQ message broker
  • Synchronous Communication: gRPC for high-performance inter-service calls
  • Asynchronous Communication: RabbitMQ with MassTransit for event-driven messaging
  • API Gateway Pattern: Centralized entry point with YARP reverse proxy
  • Publish/Subscribe: Topic exchange model for event distribution
  • PostgreSQL: Document database for Catalog service using Marten
  • SQL Server: Relational database for Ordering service with EF Core
  • Redis: Distributed cache for Basket service
  • SQLite: Lightweight database for Discount service
  • Database per Service: Each microservice owns its data store
  • Validation: FluentValidation pipeline behaviors
  • Logging: Structured logging with Serilog
  • Exception Handling: Global exception handling middleware
  • Health Checks: Built-in health monitoring for all services
  • Docker Support: Complete containerization with Docker Compose

Technology Stack

.NET 8

Latest .NET with C# 12 features, Minimal APIs, and performance improvements

MediatR

CQRS implementation with pipeline behaviors for validation and logging

Marten

.NET transactional document DB on PostgreSQL with event sourcing support

Entity Framework Core

ORM for SQL Server and SQLite with migrations and code-first approach

RabbitMQ

Message broker for asynchronous event-driven communication

MassTransit

Distributed application framework for .NET with message routing

gRPC

High-performance RPC framework for inter-service communication

YARP

Reverse proxy toolkit for building API gateways

Redis

In-memory data store for distributed caching

Carter

Minimal API endpoint definition library

Mapster

Fast object-to-object mapper

FluentValidation

Validation library for .NET with fluent interface

Learning Resources

This project is designed as a learning resource and reference implementation. It includes practical examples of modern .NET development patterns and microservices best practices.

Udemy Course

Step-by-step development course covering the entire implementation

Medium Article

Detailed explanation of DDD, CQRS, and architecture decisions

Next Steps

1

Install Prerequisites

Set up Visual Studio 2022, .NET 8 SDK, and Docker Desktop on your machine
2

Clone and Run

Clone the repository and start all services with Docker Compose
3

Explore Services

Browse the Swagger UIs and test the API endpoints for each microservice
4

Study the Code

Dive into the implementation details of each architectural pattern

Build docs developers (and LLMs) love