Domain layer
A domain layer is an architectural part of an application that contains its domain concepts, rules, and behavior.
Unit Testing Principles, Practices, and Patterns
The application layer that contains domain concepts, rules, and business logic independently of external communication and infrastructure responsibilities.
- How it is used
- Centers business logic while application services orchestrate interactions with external applications.
- How deep it goes
- Defines responsibilities, dependency direction, and communication boundaries, then demonstrates them with domain and controller examples.
- Examples
- Uses User name normalization and Customer purchasing with inventory, repositories, and receipt delivery.
- What you can do after
- Evaluate architecture by separating business behavior from orchestration and external communication.
Read how Unit Testing Principles, Practices, and Patterns explains domain layer →
Grokking Simplicity
The architectural layer containing domain rules and calculations while remaining independent of external services.
- How it is used
- Structures business calculations so interaction code can coordinate external effects without embedding them in domain rules.
- How deep it goes
- Defines layer boundaries and demonstrates extraction through examples, while stopping short of prescribing a fixed set of layers.
- Examples
- Uses shopping-cart totals, report generation, product discounts, database retrieval, and service protocols as concrete applications.
- What you can do after
- Apply it by extracting business calculations from database and web interactions for reuse, testing, and easier infrastructure changes.
Learn Go with Pocket-Sized Projects
A domain layer is an architectural layer that contains an application's business rules and domain behavior independently of delivery and persistence concerns.
- How it is used
- Places business validation and entity completion in a reusable layer called directly by new features.
- How deep it goes
- Implements validation, defaults, generated fields, typed errors, persistence orchestration, and focused tests.
- Examples
- Uses a habit tracker, typed Habit values, validation tests, generated identifiers, and creation timestamps.
- What you can do after
- Builds a validated habit-creation operation and tests its complete, partial, and invalid-input behavior.
Read how Learn Go with Pocket-Sized Projects explains domain layer →
Related concepts
- hexagonal architecturepart of · Hexagonal architecture is a software architecture pattern that isolates an application’s core logic from external systems through ports and adapters.
- service layerused by · A service layer is a distinct software-architecture layer that provides application-level functionality or services through interfaces to other components or applications.
- multi-tier applicationpart of · A multi-tier application is an application organized into distinct tiers that separate responsibilities and interact through defined dependencies or interfaces.
- interface layerused by · An interface layer is a software architectural layer that mediates interactions between consumers and application functionality or external services through defined interfaces.
- idempotency keyproduces · An idempotency key is an identifier associated with a logical operation that lets a service recognize repeated requests and prevent duplicate effects.
- infrastructure layercontrasts with · An infrastructure layer is an architectural layer that provides technical capabilities and connects application functionality to resources such as databases, messaging systems, and external services.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


