Keep the useful bits, human.
Beginner field notes
- CQRS separates the model used to change information from the model used to read it. The two sides have different jobs.
- A command asks for a business change, such as completing a task. A query asks for information, such as the task cards to display.
- Read and write models can share one database. CQRS does not require two databases or an event-sourced history.
See a worked example
Separate a task command from its board-card projection
One reviewed sample, shared across levels. Nothing here runs on your computer.
Example review recorded 2026-10-16 · version 1.
Fictional variant: separate models; read projection updates after the write, with no competing changes. Storage may be one database.
Write model: T7, status Open, revision 2; completing requires Open and expected revision 2.
Read model: card “Label seed box — Open”; completed count 0.
1. Complete T7 with expected revision 2; commit succeeds.
2. Query board before projection refresh.
3. Refresh projection, then query again.After 1: write model is Done, revision 3.
After 2: old read model can still show Open and count 0.
After 3: read model shows “Label seed box — Done” and count 1.
A command with stale expected revision 2 is rejected rather than silently overwriting revision 3.The write model validates a change; the read model shapes the displayed result. Delayed projection explains the temporary difference. Revision checks, timing and single-database permission are assumptions of this illustration, not a complete CQRS implementation or an endpoint naming convention.
Sources for this sampleVisual
The reviewed description and complete diagram source are available here.
More of this diagram is available inside its frame. Focus the frame and use the arrow keys to pan.
Read the complete diagram source
This is the source for the reviewed diagram, not a command to run.
flowchart LR
C["Complete task request"] --> W["Write model: task rules and revision"]
W --> S["Stored task data"]
S --> P["Read model: board cards and counts"]
P --> Q["Board screen query"] Full explanation and primary sources
Reviewed explanation
CQRS, Command Query Responsibility Segregation, uses a different model for changing information from the model used to read it. A model is the representation and rules a part of the application works with. Lantern Board’s write model can enforce which task changes are allowed; its read model can provide ready-to-display cards and totals. Two HTTP endpoints alone do not establish that model separation.
For a Complete task command, our write model checks that T7 is Open and that the supplied revision matches the stored revision. It then accepts or rejects the change. The board’s query model instead answers “Which cards and completion count should this screen show?” It need not expose the write model’s entire structure or use the same shape. The worked example shows these two responsibilities explicitly.
CQRS does not require two databases, event sourcing or a message broker. Distinct models can share one database. If a chosen implementation updates its read projection later, a successful write can precede the screen catching up. Our example deliberately uses that delayed projection; the delay is a stated design choice, not a requirement of every CQRS system. A synchronous implementation can have a different consistency contract.
The separation can help when reads and changes have genuinely different needs, but adds models and synchronization to maintain. It does not automatically make an application faster or secure. A small application with straightforward reads and updates may be easier to maintain with one model. Event sourcing remains background here: you can understand and implement this separation without making events the authoritative record.
Source collection
- Microsoft Azure Architecture Center: CQRS pattern
Used in: Quick notes · Worked example · Lesson text
Separate command/query models, shared or separate storage, write validation, delayed projections, optional messaging/event sourcing and transactional-outbox consistency trade-offs.
Distinct read/write data models, a shared-store implementation, optional separate stores, synchronization trade-offs and added complexity.
- Martin Fowler: CQRS
Used in: Worked example · Lesson text
Different models for update and display, possible shared database, and deciding whether separation justifies its complexity.
Notes AI source review · 2026-10-17
AI source comparison recorded 2026-10-16. Human learner validation is pending.
Quick quiz · one question
Read the model that the screen actually queries
Sample scenario. Synthetic task T7. Write model starts Open/revision 2/count 0. A Complete command needs Open and the current expected revision. This chosen CQRS example refreshes its read projection only at the listed Refresh step. No other writer or missing refresh is implied; models may share one database.
- Write model initially
Open, revision 2, currently completed tasks 0- Read model initially
Open, count 0- Step 1
complete with expected revision 2- Step 2
query- Step 3
complete with expected revision 2- Step 4
refresh- Step 5
query
Which two answers do the board queries return, and does the stale command overwrite the task?
Why this answer?
Answers stay on this device.
Sources and exercise scope
- Microsoft Azure Architecture Center: CQRS pattern
Separate read/write models and synchronization choices. Delayed projection and revision rejection are explicit example assumptions, not requirements of every CQRS system.
Original synthetic exercise. AI comparison against the reviewed lesson recorded on 2026-10-17; the references above state their scope. Human learner validation has not been run. A result here records this attempt; it does not establish mastery.
Save or adjust this lesson
Make this lesson yours
Save it for later, or tell your robot what would help.
This correction stays on this browser. Browse all concepts if the topic is missing.
Familiarity is your own assessment. To use it in your coding tool, download your updated learning profile.
Familiarity and lesson feedback are saved on this browser. They do not sync to your account or coding tool.