The domain layer is the center of an application: it contains the business logic and concepts that provide the application’s essential functionality and differentiation. It should remain focused on business rules rather than external communication or infrastructure responsibilities. section 5.3
A domain layer in hexagonal architecture follows three practical boundaries:
- Separates business logic from application services, which coordinate domain work with databases, APIs, and other external systems. section 5.3
- Keeps dependencies flowing inward: domain classes may depend on one another, but not on application-service classes. section 5.5
- Receives external connections through interfaces maintained by application services rather than exposing direct access to the domain. section 5.5
Business rule versus orchestration
A User domain class normalizes a name when its Name property changes. A UserController retrieves the user, invokes that domain operation, and saves the result. Likewise, a CustomerController retrieves a customer and product, invokes Purchase, and sends a receipt only after a successful purchase. The controllers coordinate; the domain objects enforce business behavior.


