Domain layer
A domain layer is the architectural part of an application that contains its domain concepts, business rules, and behavior, distinct from infrastructure and delivery concerns.
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.
Grokking Software Architecture
The architectural part of an application that contains core business knowledge, rules, logic, state, entities, value objects, and domain services.
- How it is used
- Separates core business rules and state from presentation, application orchestration, and infrastructure concerns.
- How deep it goes
- Defines its contents and boundaries, but offers little implementation detail beyond naming entities, value objects, and services.
- Examples
- Uses Order and Customer entities, a Widget class with business logic, and a project /domain/ folder.
- What you can do after
- Evaluate which components express business logic and which handle technical infrastructure.
Read how Grokking Software Architecture explains domain layer →
Clean Applications with Hexagonal Architecture
A software layer that contains business concepts, rules, and behavior independently of infrastructure frameworks.
- How it is used
- Keeps business rules and invariants independent of frameworks, deployment choices, and infrastructure.
- How deep it goes
- Specifies domain building blocks and factory-based invariant validation, including collecting multiple errors with Vavr Validation.
- Examples
- Uses Article rules, a constrained Title value object, and factory methods to illustrate domain behavior and construction.
- What you can do after
- Build framework-free domain entities whose factories validate invariants before creation.
Read how Clean Applications with Hexagonal Architecture explains domain layer →
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 →
Also covered in
- Java Persistence with Spring Data and Hibernate epub
- Functional Design and Architecture: Examples in Haskell
- Testing Spring Boot ApplicationsIn early access (MEAP)
- Secure APIs
What to know first
- business logicBusiness logic is the domain-specific rules, computations, and decisions that determine how a software system processes operations and behaves.
- data transfer objectA data transfer object is a data-carrying structure that conveys selected information between software components or across boundaries without encapsulating substantial domain behavior.
- contractA contract is an agreed specification of the conditions, expectations, rights, or obligations that govern behavior or interactions between parties or software components.
Related concepts
- hexagonal architecturepart of · Hexagonal architecture is a software architecture pattern that isolates an application's core logic behind ports and connects external systems through adapters.
- n-tier architecturepart of · N-tier architecture organizes an application into distinct tiers with separate responsibilities and defined interactions, which may be logical divisions or separately deployed components.
- 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.
- persistencecontrasts with · Data persistence is the retention of data in storage so it remains available beyond the process or computation that created or changed it.
- domain servicehas part · A domain service is a stateless component that encapsulates business logic not naturally belonging to a single entity or value object.
- idempotency keyproduces · An idempotency key is an identifier associated with a logical operation that allows repeated requests to be recognized and handled without duplicating the operation’s effects.
Questions about domain layer
What is domain layer?
A domain layer is the architectural part of an application that contains its domain concepts, business rules, and behavior, distinct from infrastructure and delivery concerns.
Which Manning books explain domain layer?
Unit Testing Principles, Practices, and Patterns, Grokking Simplicity, Grokking Software Architecture, Clean Applications with Hexagonal Architecture and Learn Go with Pocket-Sized Projects.
What should I know before learning domain layer?
Manning books that teach domain layer usually introduce business logic, data transfer object and contract first.
What is the difference between domain layer and persistence?
A domain layer is the architectural part of an application that contains its domain concepts, business rules, and behavior, distinct from infrastructure and delivery concerns. Data persistence is the retention of data in storage so it remains available beyond the process or computation that created or changed it.
What is domain layer part of?
Domain layer is part of hexagonal architecture. Hexagonal architecture is a software architecture pattern that isolates an application's core logic behind ports and connects external systems through adapters.
What are the parts of domain layer?
Domain layer includes domain service.
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.




