run-aspnetcore-microservices is a free, open source api development & testing project written in C# and released under MIT. It has 3,263 GitHub stars, 1,740 forks and 43 open issues, and was last pushed 6 months ago. On this registry it ranks #65 of 103 tracked projects in API Development & Testing, with 5 head-to-head comparisons available.

What is run-aspnetcore-microservices?

What it is

run-aspnetcore-microservices is an open-source .NET repository that demonstrates microservices architecture for an e-commerce domain. It combines ASP.NET Web API, ASP.NET Core Minimal APIs, Docker, RabbitMQ, MassTransit, gRPC, YARP, PostgreSQL, Redis, SQLite, SQL Server, Marten, Entity Framework Core, CQRS, MediatR, DDD, vertical and clean architecture, and .NET 8 with C# 12.

The repository addresses the practical problem of wiring multiple .NET services together in one coherent application. It shows how to separate Catalog, Basket, Discount, and Ordering services, choose document, relational, and cache stores, expose HTTP and gRPC endpoints, route traffic through YARP, and communicate asynchronously through RabbitMQ.

Key capabilities

  • The Catalog microservice uses ASP.NET Core Minimal APIs, vertical slice architecture, CQRS with MediatR and FluentValidation, Marten for PostgreSQL document storage, Carter endpoints, logging, exception handling, and health checks.
  • The Basket microservice implements REST CRUD, Redis distributed cache, proxy, decorator, and cache-aside patterns, consumes Discount gRPC for price calculation, and publishes BasketCheckout through MassTransit and RabbitMQ.
  • The Discount microservice runs an ASP.NET gRPC server, exposes Protobuf messages, uses Entity Framework Core with SQLite migrations, and containerizes SQLite.
  • The communication layer uses RabbitMQ Publish/Subscribe Topic exchange, MassTransit, EventBus.Messages, synchronous gRPC between Basket and Discount, and asynchronous BasketCheckout events consumed by Ordering.
  • The Ordering microservice uses DDD, CQRS, Clean Architecture, MediatR, FluentValidation, Mapster, MassTransit-RabbitMQ, Entity Framework Core, and automatic SQL Server migration at startup.
  • The YARP API Gateway applies Route, Cluster, Path, Transform, and Destinations configuration with FixedWindowLimiter, and WebUI ShoppingApp calls it through Refit HttpClientFactory.

Who uses it and how

  • Developers learning or prototyping .NET 8 microservices can inspect Catalog, Basket, Discount, and Ordering and run them with Docker Compose.
  • Teams designing event-driven communication can follow RabbitMQ and MassTransit where Basket publishes BasketCheckout and Ordering consumes it.
  • Architects comparing data stores can study Marten with PostgreSQL, Redis, SQLite, and SQL Server across the services.
  • API teams can use YARP as a reverse proxy gateway for routing and fixed-window rate limiting before WebUI ShoppingApp calls services.

Getting started

Developers need Visual Studio 2022 and .NET 8 or later, then they use Docker Compose to containerize the microservices and databases.

When to use it — and when not to

It is useful when you need a concrete .NET 8 reference for microservices patterns, not when you need a turnkey production service. A self-hosted deployment requires operating PostgreSQL, Redis, SQLite, SQL Server, RabbitMQ, YARP, and Docker Compose, and the repository is tied to a Udemy course and does not list contributors.

project readme (upstream, from github) — read inline

UDEMY COURSE WITH DISCOUNTED - Step by Step Development of this Repository -> https://www.udemy.com/course/microservices-architecture-and-implementation-on-dotnet/?couponCode=MARC26

See the overall picture of implementations on microservices with .net tools on real-world e-commerce microservices project;

microservices

There is a couple of microservices which implemented e-commerce modules over Catalog, Basket, Discount and Ordering microservices with NoSQL (DocumentDb, Redis) and Relational databases (PostgreSQL, Sql Server) with communicating over RabbitMQ Event Driven Communication and using Yarp API Gateway.

Check Explanation of this Repository on Medium

Whats Including In This Repository

We have implemented below features over the run-aspnetcore-microservices repository.

Catalog microservice which includes;
  • 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
  • Use Carter for Minimal API endpoint definition
  • Cross-cutting concerns Logging, Global Exception Handling and Health Checks
Basket microservice which includes;
  • ASP.NET 8 Web API application, Following REST API principles, CRUD
  • Using Redis as a Distributed Cache over basketdb
  • Implements Proxy, Decorator 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
Discount microservice which includes;
  • ASP.NET Grpc Server application
  • Build a Highly Performant inter-service gRPC Communication with Basket Microservice
  • Exposing Grpc Services with creating Protobuf messages
  • Entity Framework Core ORM — SQLite Data Provider and Migrations to simplify data access and ensure high performance
  • SQLite database connection and containerization
Microservices Communication
  • Sync inter-service gRPC Communication
  • Async Microservices Communication with RabbitMQ Message-Broker Service
  • Using RabbitMQ Publish/Subscribe Topic Exchange Model
  • Using MassTransit for abstraction over RabbitMQ Message-Broker system
  • Publishing BasketCheckout event queue from Basket microservices and Subscribing this event from Ordering microservices
  • Create RabbitMQ EventBus.Messages library and add references Microservices
Ordering Microservice
  • Implementing DDD, CQRS, and Clean Architecture with using Best Practices
  • Developing CQRS with using MediatR, FluentValidation and Mapster packages
  • Consuming RabbitMQ BasketCheckout event queue with using MassTransit-RabbitMQ Configuration
  • SqlServer database connection and containerization
  • Using Entity Framework Core ORM and auto migrate to SqlServer when application startup
Yarp API Gateway Microservice
  • Develop API Gateways with Yarp Reverse Proxy applying Gateway Routing Pattern
  • Yarp Reverse Proxy Configuration; Route, Cluster, Path, Transform, Destinations
  • Rate Limiting with FixedWindowLimiter on Yarp Reverse Proxy Configuration
WebUI ShoppingApp Microservice
  • ASP.NET Core Web Application with Bootstrap 4 and Razor template
  • Call Yarp APIs with Refit HttpClientFactory
Docker Compose establishment with all microservices on docker;
  • Containerization of microservices
  • Containerization of databases
  • Override Environment variables

Run The Project

You will need the following tools:

Installing

Follow these steps to get your development environment set up: (Before Run Start the Docker Desktop)

  1. Clone the repository
  2. Once Docker for Windows is installed, go to the Settings > Advanced option, from the Docker icon in the system tray, to configure the minimum amount of memory and CPU like so:
  • Memory: 4 GB
  • CPU: 2
  1. At the root directory of solution, select docker-compose and Set a startup project. Run docker-compose without debugging on visual studio. Or you can go to root directory which include docker-compose.yml files, run below command:
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
  1. Wait for docker compose all microservices. That’s it! (some microservices need extra time to work so please wait if not worked in first shut)

  2. Launch Shopping Web UI -> https://localhost:6065 in your browser to view index page. You can use Web project in order to call microservices over Yarp API Gateway. When you checkout the basket you can follow queue record on RabbitMQ dashboard.

mainscreen2

Authors

See also the list of contributors who participated in this project. Check also gihtub page of repository.

Frequently asked questions

Is run-aspnetcore-microservices free to use?

run-aspnetcore-microservices is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does run-aspnetcore-microservices do?

Microservices on .NET platforms used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entit

What is run-aspnetcore-microservices written in?

run-aspnetcore-microservices is primarily written in C#. Its source is publicly available at https://github.com/aspnetrun/run-aspnetcore-microservices, and it has 3,263 GitHub stars.