CQRS Architecture
CQRS (Command Query Responsibility Segregation) is an architectural pattern that separates the write model (commands that change state) from the read model (queries that return data), allowing each side to be optimized, scaled, and evolved independently.
CQRS (Command Query Responsibility Segregation) is an architectural pattern that separates the write model (commands that change state) from the read model (queries that return data), allowing each side to be optimized, scaled, and evolved independently.
What the diagram shows
The diagram splits into two clear paths from the Client. On the left, a Command (create, update, delete) flows to the Command Handler, which validates the intent and writes to the Write Store — a normalized relational database optimized for consistency and transactional integrity. After a successful write, a Domain Event is published to an Event Bus.
On the right, Query requests flow to the Query Handler, which reads from a Read Store — a denormalized projection database, search index, or materialized view optimized purely for fast retrieval. An Event Projector subscribes to the Event Bus and continuously updates the Read Store to reflect the latest committed state, keeping the two sides eventually consistent.
Why this matters
When read and write workloads have very different characteristics — for example, thousands of reads per second against tens of writes — a single unified model forces both to share the same indexes, schema design, and scaling strategy. CQRS breaks that coupling: the write side can use a strongly-typed domain model with strict validation, while the read side uses flat, pre-joined projections that return in a single query.
The trade-off is eventual consistency: a command may complete successfully before its effect appears in the read store. Systems using CQRS must handle this lag explicitly. For the async backbone that connects both sides, see Event Driven System. For replication patterns on the read side, see Database Replication.