Skip to main content

What is Hybrid DDD Architecture?

Hybrid DDD Architecture is a production-ready .NET 8 template that combines Domain-Driven Design (DDD) principles with modern architectural patterns to help you build scalable, maintainable REST APIs. It provides a complete foundation with CQRS, event-driven architecture, and support for multiple database technologies.
This template is designed for developers who want to build enterprise-grade APIs without starting from scratch, following industry best practices and clean architecture principles.

Who is this for?

This template is ideal for:
  • Backend developers building REST APIs with .NET
  • Architects seeking a proven structure for enterprise applications
  • Teams wanting to standardize on DDD and CQRS patterns
  • Projects requiring flexibility in database technology (SQL Server, MongoDB, MySQL, MariaDB)
  • Microservices that need event-driven communication via RabbitMQ

Key Features

The template provides everything you need to build modern REST APIs:

CQRS Pattern

Built-in command and query bus (ICommandQueryBus) for separating read and write operations

Event-Driven Architecture

RabbitMQ integration for asynchronous event handling and microservices communication

Multi-Database Support

Switch between SQL Server, MySQL, MariaDB, and MongoDB without changing business logic

Domain Validation

Built-in FluentValidation integration at the domain entity level

HTTP Adapters

Abstractions for external service communication with proper dependency inversion

Auto Mapping

AutoMapper configuration for DTOs and domain entities

Architecture Philosophy

This template follows a hybrid approach to Domain-Driven Design:

Core Layer (Reusable)

The Core.* projects contain reusable infrastructure that can be shared across multiple applications:
  • Core.Domain - Base classes for domain entities with validation
  • Core.Application.ComandQueryBus - CQRS implementation with MediatR
  • Core.Application.EventBus - Event bus abstractions
  • Core.Application.Repositories - Repository pattern interfaces
  • Core.Infraestructure.Repositories.Sql - SQL repository implementations
  • Core.Infraestructure.Repositories.MongoDb - MongoDB repository implementations
  • Core.Infraestructure.EventBus.RabbitMq - RabbitMQ event bus implementation
  • Core.Application.Adapters.Http - HTTP client abstractions

Application Layers (Business-Specific)

The main layers contain your specific business logic:
  • Domain - Your business entities, enums, constants, and domain validators
  • Application - Use cases (commands/queries), DTOs, application services
  • Infrastructure - Repository implementations, database contexts, external adapters
  • Template-API - Controllers, startup configuration, API-specific concerns
The separation between Core and Layers allows you to reuse technical infrastructure across projects while keeping business logic isolated.

When to Use This Template

Consider using this template when:
  • You need to build a REST API with clean architecture
  • You want CQRS and event-driven patterns out of the box
  • You require flexibility to switch database providers
  • You’re building microservices that communicate via events
  • You want domain entities with built-in validation using FluentValidation
  • You need a proven structure for team collaboration

When NOT to Use This Template

This template might be overkill if:
  • You’re building a simple CRUD API without complex business rules
  • You don’t need CQRS or event-driven architecture
  • You’re prototyping and need maximum speed over structure
  • Your team is unfamiliar with DDD concepts and has no time to learn

What’s Included

Out of the box, you get:
  • Complete project structure with 13 projects organized by layers
  • Example implementation with DummyEntity showing all patterns
  • Database migrations setup with Entity Framework Core
  • Swagger integration for API documentation and testing
  • Exception handling with custom filters
  • CORS configuration for web client integration
  • Docker support with included Dockerfile
  • Dependency injection configured throughout all layers

Next Steps

Quickstart

Get the template running in minutes

Installation & Setup

Detailed setup and configuration guide

Architecture Overview

Deep dive into the architectural patterns

Creating Entities

Learn how to add your first domain entity

Build docs developers (and LLMs) love