How itlibrium/ddd-starter-dotnet works
Project type and purpose
• This is a modular monolith / sample framework project (“DDD-starter-dotnet”) demonstrating Domain-Driven Design (DDD) patterns, hexagonal architecture, CQRS, event sourcing, outbox, BDD, etc., in C#/.NET.
• It provides multiple “bounded contexts” (Contacts, Sales, Payments, ProductsDelivery, RiskManagement, Search, TechnicalStuff) each implemented in its own set of projects (DeepModel, ProcessModel, Adapters.Api, Adapters.Out, FluentMigrations, IntegrationTests, etc.). A separate Startup project composes everything, and a Build folder contains Nuke-based CI/CD automation and Docker-Compose definitions for infrastructure.
File structure
• Top-level directories:
• Build/Nuke·… → build scripts and Docker-Compose tasks for spinning up Postgres, Elasticsearch, Kafka, etc.
• Sources/… → each bounded context under its own folder, following “screaming architecture” (folder and namespace names reveal business domain and layers).
• Each context typically has layers:
– *.DeepModel (domain layer, hexagon’s core)
– *.ProcessModel (application / use-case layer)
– *.Adapters.Api (incoming port, REST controllers)
– *.Adapters.Out (outgoing port, repositories, external integrations)
– *.Crud or simple single-layer projects (in Contacts) for straight CRUD.
– *.Tests or IntegrationTests (testing).
• Sources/Monolith.Startup and Sources/Search.Startup → host entire system or Search module, wire up DI, configuration, middleware.
• TechnicalStuff → reusable cross-cutting libraries (persistence abstractions, outbox, Kafka, JSON converters, transactions, etc.).
Extract architecture hints from the README
• “Screaming architecture”: bounded contexts mapped to solution folders; hexagonal only for high-complexity DeepModel in Sales; simple CRUD for Contacts.
• Demonstrates DDD building blocks (Aggregates, Value Objects, Policies, Factories, Domain Services) in DeepModel.
• Uses Outbox Pattern and event publishing (TransactionalOutbox, NonTransactionalOutbox).
• Startup code in separate project.
A. Build / Infrastructure orchestration
• Nuke build orchestrator
• Docker-Compose (Postgres, Elasticsearch, Kafka)
For each module (e.g. Sales):
– Incoming Port: Adapters.Api (REST controllers)
– Application Layer: ProcessModel (use-case handlers, outbox ports)
– Domain Layer: DeepModel (aggregates, value objects, policies)
– Outgoing Ports & Adapters: Adapters.Out (SQL/EF/raw/document repositories, external service clients for Payments, RiskManagement, ProductsDelivery or in-memory fakes)
– Integration with TechnicalStuff libs (Persistence, Outbox, Transactions, Kafka)
For simple CRUD contexts (Contacts): single-layer CRUD project + EF DAO + REST controllers.
C. Shared Startup host(s)
• Monolith.Startup (aggregate of all BCs)
• Search.Startup (for the Search module only)
D. Infrastructure services
• Postgres DB(s) for main contexts
• Elasticsearch for Search context
• Kafka cluster for event-driven integrations
E. Cross‐cutting libraries (TechnicalStuff)
Relationships and data flows
• Client HTTP → Adapters.Api → ProcessModel handlers → Domain DeepModel → Adapters.Out writes to DB / emits events to Outbox → outbox processor sends to Kafka → Kafka topics consumed by other BC adapters.
• ProcessModel may read CRUD tables (Contacts or Sales CRUD tables) in same transaction.
• Adapters.Out for external services: HTTP calls or in-memory.
• Startup wires up: configuration → DI container → module registrations → middleware pipelines → outbox background services.
Architectural patterns and design principles
• Hexagonal Architecture in Sales.DeepModel / Sales.ProcessModel / Sales.Adapters.*
• Single-layer CRUD in Contacts (anemic, directly using EF).
• DDD building blocks in domain layer (Aggregates, Value Objects, Domain Events, Policies, Factories, Domain Services).
• Outbox pattern for reliable event publishing (Transactional vs Non-Transactional).
• Screaming architecture: project names, namespaces and folder structure map directly to BCs and layers.
• Separate Startup host for composition root.
• Use of cross-cutting abstractions (TechnicalStuff) so adapters and use-cases remain technology-agnostic.