CQRS diagram template
Separate write and read models, kept in sync by events, for independent scaling.
About this design
Command Query Responsibility Segregation separates the model you change from the model you read. Commands go to a write service that enforces business rules against a normalised database. Each accepted change publishes an event, and a projector consumes those events to maintain one or more read models shaped exactly for the screens that need them, perhaps a denormalised document store or a search index. Queries hit only the read side, so the two sides can scale, be cached and even use different technologies. The price is eventual consistency: a read may lag a write by a moment, which the interface must be designed to tolerate. Use this template to decide whether the pattern earns its complexity, and to discuss rebuilding a read model from history, handling projector failures, and reporting a command's outcome back to the user.
Diagram as text
This is the source of the diagram, in the ArchBoard diagram DSL. Paste it into Tools, Diagram from text to rebuild or change it.
title "CQRS"
direction LR
client "Client" -> service cmd "Command API" -> db postgres "Write model"
cmd -> topic kafka "Domain events" -> worker proj "Projector" -> search elasticsearch "Read model"
client -[query]-> service qry "Query API" -> read-model