Roadmap › .NET Project Architectures & Folder Structures — Layered, Clean, Onion, Vertical Slice › Module: Architecture Styles
Lessons in this course (8)
5. Modular monolith and DDD building blocks
IntermediateMediumLesson 5 of 8
Modular monolith — one deployable application, divided into modules by business capability; each module has its own folders/projects, its own database schema and a small public API; modules communicate via interfaces or in-process events.
text
src/
├── Shop.Host/ ASP.NET Core host — registers all modules
├── Modules/
│ ├── Catalog/ Catalog.Api (endpoints) · Catalog.Core (domain + use cases) · Catalog.Infrastructure (schema "catalog")
│ ├── Ordering/ Ordering.Api · Ordering.Core · Ordering.Infrastructure (schema "ordering")
│ └── Billing/ Billing.Api · Billing.Core · Billing.Infrastructure (schema "billing")
└── Shared/ Shared.Kernel (base types), Shared.Infrastructure (event bus, outbox)Rules: no module reads another's tables; communication through a module's public contracts or integration events; architecture tests enforce boundaries. A module can later become a microservice.
DDD building blocks:
| Block | Meaning | Example |
|---|---|---|
| Entity | Has identity that persists | Order (Id 1001) |
| Value object | Defined by its values, immutable | Money(4500, "INR"), Address |
| Aggregate (root) | Consistency boundary; outside code changes it only through the root | Order with OrderLines |
| Domain service | Logic that doesn't belong to one entity | PricingService |
| Domain event | Something that happened | OrderPlaced |
| Repository | Collection-like access to aggregates | IOrderRepository |
| Bounded context | Boundary where a model applies | Sales vs Shipping |