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

NamespaceDescription
{System}.[Context].DomainDomain entities and value objects

Application Layer

NamespaceDescription
{System}.[Context].ContractsService interfaces, other interfaces, and data contracts
{System}.[Context].ServicesService implementations
{System}.[Context].UnitTestsEntity and service unit tests

Infrastructure Layer

NamespaceDescription
{System}.[Context].AdaptersImplImplementation of adapters
{System}.Host.ControllersAPI controllers
{System}.HostApplication host (includes services, adapters, and controllers)
{System}.TestsIntegration and component tests

Adapter Suffixes

  • Repository
  • Adapter
  • Gateway
  • Provider
  • Store
  • Db