liveBook · Manning

Domain model

As explained in Clean Applications with Hexagonal Architecture

A software representation of the concepts, relationships, and rules of a business domain.

A domain model represents business rules in the core of an application. Entities, value objects, and domain services enforce invariants; framework and transport concerns stay outside that core. section 1.3

Keep application handlers focused on orchestration: they call collaborators in order and propagate failures, while domain objects decide business conditions. A handler that checks a business condition is a signal to move that rule into the domain model. section 4.4.2

Article publishing

An Article aggregate rejects publishing when the article is not a draft or the requester is not its author. On a successful state change, it records an ArticlePublished event; the handler publishes that event after saving the article. section 4.7.2

Using one domain entity for API serialization and persistence couples the core to boundary concerns. Keep the domain model independent of those representations. section 5.4.2

Figure 4.5 The domain event flow. The aggregate generates the event. The handler publishes it after the save. An input adapter listens and invokes a new use case. The event exits the hexagon through an output port and re-enters through an input adapter—maintaining the architectural boundary in both directions.

Trace how the aggregate creates an event, the handler publishes it after saving, and an adapter reacts through another use case. section 4.7.2

How Clean Applications with Hexagonal Architecture covers it

How deep it goes
Explains rule placement through handler orchestration, aggregate behavior, and event generation.
Examples
Uses article creation and publishing, including author validation, publishing rules, and an ArticlePublished event.
What you can do after
Apply the boundary by keeping business conditions in domain objects and leaving handlers to coordinate collaborators.
How it connects
Connects entities, value objects, domain services, application handlers, repositories, and domain events.

Also explained in

Compare how 9 books explain domain model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clean Applications with Hexagonal Architecture. The section links point to the parts of the book it draws on.