DDD and Microservices Namespace Naming Conventions#
Building software systems using microservices and Domain-Driven Design (DDD) reduces overall complexity and simplifies development by dividing a complex system into separate, smaller subsystems (called bounded contexts in DDD). To simplify implementation, we propose the following namespace naming conventions for .NET microservices.

Namespace Templates#
- System: Short name of the software system.
- Context: Name of the bounded context (subsystem).
Domain Layer#
| Namespace | Description |
|---|
{System}.[Context].Domain | Domain entities and value objects |
Application Layer#
| Namespace | Description |
|---|
{System}.[Context].Contracts | Service interfaces, other interfaces, and data contracts |
{System}.[Context].Services | Service implementations |
{System}.[Context].UnitTests | Entity and service unit tests |
Infrastructure Layer#
| Namespace | Description |
|---|
{System}.[Context].AdaptersImpl | Implementation of adapters |
{System}.Host.Controllers | API controllers |
{System}.Host | Application host (includes services, adapters, and controllers) |
{System}.Tests | Integration and component tests |
Adapter Suffixes#
RepositoryAdapterGatewayProviderStoreDb