liveBook · Manning

Domain layer

Also called business layer, business logic 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.

How 5 Manning books explain it

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.

Read how Grokking Simplicity explains domain layer →

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

What to know first

Related concepts

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.