A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 10, Wolverine, Domain-Driven Design, CQRS, Vertical Slice Architecture
A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 10, Wolverine, Domain-Driven Design, CQRS, Vertical Slice Architecture
Food Delivery Microservices is a practical and cloud-native food delivery microservices built with .NET Aspire, .Net Core and different software architecture and technologies like Microservices Architecture, Vertical Slice Architecture , CQRS Pattern, Domain Driven Design (DDD), Event Driven Architecture. For communication between independent services, we use asynchronous messaging with RabbitMQ and Wolverine, and sometimes we use synchronous communication for real-time communications with REST and gRPC calls.
This application is not business oriented and my focus is mostly on technical part, I just want to implement a sample with using different technologies, software architecture design, principles and all the thing we need for creating a microservices app.
Warning This project is in progress. I add new features over the time. You can check the Release Notes.
This Application ported to modular monolith approach in food-delivery-modular-monolith repository, we can choose best fit architecture for our projects based on production needs.
Other versions of this project are available in these repositories, We can choose best fit architecture for our projects based on production needs:
For your simplest .net core projects, you can use my vertical-slice-api-template project template:
Don't forget to star () this repo to find it easier later and Support.
Microservices and Vertical Slice Architecture as a high level architectureEvent Driven Architecture on top of RabbitMQ Message Broker and WolverineDomain Driven Designin most of services like Customers, Catalogs, ...Event Sourcing and EventStoreDB in Audit Based services like Orders, PaymentData Centeric Architecture based on CRUD in Identity ServiceCQRS Pattern on top of MediatR library and spliting read models and write modelsOpenTelemetry Collector to receive, process, and export telemetry data to various backends, including Jaeger and Tempo for tracing, Loki and Kibana for logs, and Prometheus for metrics.Outbox, Inbox, and durable local processing in a transactional boundary with EF CoreUnitTests and NSubstitute for mocking dependenciesIntegration Tests and End To End Tests on top of testcontainers-dotnet library for cleanup our test enviroment through docker containersMinimal APIs for handling requestsFluent Validation and a Validation Pipeline Behaviour on top of MediatRPostgres for write database as relational DB and MongoDB and Elasric Search for read databasedocker-compose for deploymentUnit Tests, Integration Tests, End-To-End Tests and testcontainers for testing in isolationOpenTelemetry for collecting Metrics and Distributed TracesHelm, Kubernetes and Kustomize for deploymentThis project is in progress, new features will be added over time.
| Feature | Architecture Pattern | Status | CI-CD |
|---|
.NET 9 - .NET Framework and .NET Core, including ASP.NET and ASP.NET CoreWolverine - Message bus and transactional messaging framework for .NETStackExchange.Redis - General purpose redis clientNpgsql Entity Framework Core Provider - Npgsql has an Entity Framework (EF) Core provider. It behaves like other EF Core providers (e.g. SQL Server), so the general EF Core docs apply here as wellEventStore-Client-Dotnet - Dotnet Client SDK for the Event Store gRPC Client API written in C#FluentValidation - Popular .NET validation library for building strongly-typed validation rulesSwagger & Swagger UI - Swagger tools for documenting API's built on ASP.NET CoreSerilog - Simple .NET logging with fully-structured eventsPolly - 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 mannerScrutor - Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjectionOpentelemetry-dotnet - The OpenTelemetry .NET ClientDuendeSoftware IdentityServer - The most flexible and standards-compliant OpenID Connect and OAuth 2.x framework for ASP.NET CoreNewtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NETRabbitmq-dotnet-client - RabbitMQ .NET client for .NET Standard 2.0+ and .NET 4.6.1+AspNetCore.Diagnostics.HealthChecks - Enterprise HealthChecks for ASP.NET Core Diagnostics PackageMicrosoft.AspNetCore.Authentication.JwtBearer - Handling Jwt Authentication and authorization in .Net CoreNSubstitute - A friendly substitute for .NET mocking libraries.StyleCopAnalyzers - An implementation of StyleCop rules using the .NET Compiler PlatformMapperly - A .NET source generator for generating object mappings, No runtime reflection.IdGen - Twitter Snowflake-alike ID generator for .NetTODO
The bellow architecture shows that there is one public API (API Gateway) which is accessible for the clients and this is done via HTTP request/response. The API gateway then routes the HTTP request to the corresponding microservice. The HTTP request is received by the microservice that hosts its own REST API. Each microservice is running within its own AppDomain and has directly access to its own dependencies such as databases, files, local transaction, etc. All these dependencies are only accessible for that microservice and not to the outside world. In fact microservices are decoupled from each other and are autonomous. This also means that the microservice does not rely on other parts in the system and can run independently of other services.
Microservices are event based which means they can publish and/or subscribe to any events occurring in the setup. By using this approach for communicating between services, each microservice does not need to know about the other services or handle errors occurred in other microservices.
In this architecture we use CQRS Pattern for separating read and write model beside of other CQRS Advantages. Here for now I don't use Event Sourcing for simplicity but I will use it in future for syncing read and write side with sending streams and using Projection Feature for some subscribers to syncing their data through sent streams and creating our Custom Read Models in subscribers side.
Here I have a write model that uses a postgres database for handling better Consistency and ACID Transaction guaranty. beside o this write side I use a read side model that uses MongoDB for better performance of our read side without any joins with suing some nested document, also better scalability with some good scaling features in MongoDB.
This repository now uses Wolverine as the single durable messaging runtime for broker publishing, inbound idempotency, and internal asynchronous processing. The old custom polling outbox and inbox implementation is replaced in the active Wolverine-based services by Wolverine durability primitives.
Outbox: integration events are written through Wolverine using PostgreSQL durability and flushed in the same application transaction boundary as ENo open issues yet, or sync has not completed.