liveBook · Manning

Read model

As explained in Clean Applications with Hexagonal Architecture

A model optimized for retrieving and presenting selected application data rather than enforcing domain behavior.

A distributed read model is a local view shaped for a query, containing only the fields it needs and none of the domain’s rules or invariants. It can avoid calling the owning context on every render, but reflects only the events processed so far. section 11.6

Choose the read-side structure to fit the query:

  • A replica keeps a broader copy of a context’s published contract; a projection reshapes data for a query. section 11.6
  • Materialize a projection when joining local replicas misses the response-time target and the query can tolerate lag; account for updating and rebuilding the view. section 11.6
  • Use the view for display, not command decisions: stale data cannot validate an author or authorize article approval. section 11.6
Figure 11.2 The author service’s events feed WriteFlow’s author directory through a projection. The query reads the directory rather than calling the author service. The diagram shows one source context; others can feed the view when the query needs their data.

The diagram traces author-service events into WriteFlow’s author directory and shows a query reading that projection. section 11.6

How Clean Applications with Hexagonal Architecture covers it

How deep it goes
Defines event-fed projections, eventual consistency, and read-only boundaries; works through one source context and defers multi-source views.
Examples
Uses an author directory keyed by author identifier, populated from author events and queried for display name or active status.
What you can do after
Evaluate whether a query merits materialization by weighing response-time needs, acceptable lag, and view maintenance or rebuild costs.
How it connects
Connects CQRS, events, projections, and replicas, distinguishing query-shaped views from broader contract copies.

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.