Two models, one system
CQRS stands for command query responsibility segregation. The idea is to use one model for changing data, the command side, and a separate model for reading it, the query side. Each side gets a shape tuned for its job.
In a traditional design the same model handles both, which forces compromises. Reads often want denormalized, fast lookups while writes want validated, normalized structure. CQRS lets them diverge.
How it flows
- A command expresses intent to change state and is validated by the write model.
- The write produces an update that is projected into one or more read models.
- Queries hit the read models, which are shaped exactly for the screens that need them.
What you accept
The read side is often updated asynchronously, so it can be briefly behind the write side. This eventual consistency is fine for many features but must be considered in the user experience. CQRS adds moving parts, so reach for it when read and write needs genuinely diverge, not by default.
Key idea
CQRS separates write and read models so each can be optimized, at the cost of eventual consistency.