Event Sourcing and CQRS Architecture Diagrams (2026)
How to diagram Event Sourcing and CQRS architectures. Covers the event store, command and query separation, projections, sagas, and the full event-driven system — with AI prompt templates.
Event Sourcing and CQRS (Command Query Responsibility Segregation) are complementary architectural patterns that solve different problems but are almost always used together. Event Sourcing stores the full history of state changes as an immutable sequence of events rather than only the current state — giving you a complete audit log, the ability to replay history, and temporal queries for free. CQRS separates the write model (commands that change state) from the read model (queries that return state) — allowing each to be optimized independently. Together, they enable highly scalable, auditable systems that are especially well-suited for financial applications, order management, distributed workflows, and anywhere a complete history of changes matters.
This guide explains the components and data flows you need to show in an Event Sourcing / CQRS diagram, with prompt templates for the most common system shapes.
Core components of an Event Sourcing architecture
- Command: An intent to change state — "PlaceOrder", "TransferFunds", "CancelSubscription". Commands are validated and processed by a command handler.
- Command handler: Validates the command against domain rules, loads the current aggregate state by replaying events, applies the command, and emits one or more domain events if the command succeeds.
- Event store: The append-only log of all domain events, ordered by time. Every write is an append — nothing is ever updated or deleted. EventStoreDB, PostgreSQL with an events table, and Kafka (with infinite retention) are common implementations.
- Aggregate: The domain entity whose state is derived by replaying its event stream. Aggregates enforce invariants; each has its own event stream in the event store.
- Event: An immutable record of something that happened — "OrderPlaced", "FundsTransferred", "SubscriptionCancelled" — stored with a timestamp, aggregate ID, and version number.
- Projection: A read-model built by subscribing to the event stream and maintaining a materialized view optimized for queries. Different projections can serve different query patterns — a list view, a detail view, a reporting aggregate.
- Query handler: Reads directly from the projection (read database) — completely separate from the write path.
- Saga / process manager: Orchestrates long-running workflows that span multiple aggregates — listens for events and issues compensating commands if a step fails.
CQRS: separating reads from writes
In a pure CQRS system, the write side (commands) and read side (queries) are completely decoupled:
- Write side: Receives commands, validates against business rules, emits events to the event store. Optimized for consistency and correctness.
- Read side: Subscribes to the event stream and maintains denormalized read models in a database optimized for query patterns (Elasticsearch for full-text search, Redis for low-latency lookups, PostgreSQL for relational views). Optimized for query performance.
- Eventual consistency: The read side lags slightly behind the write side — events must be projected before queries reflect the latest state. Your diagram should show this with a dashed arrow labeled "eventually consistent" between the event store and read databases.
Prompt templates for Event Sourcing / CQRS diagrams
E-commerce order management system
Banking ledger with event sourcing
What to show in your diagram
- Write path: Command → command handler → aggregate → event store (solid arrows, synchronous)
- Read path: Query → query handler → read database (solid arrows, separate from write path)
- Projection pipeline: Event store → event subscriber → projection → read database (dashed arrows, async, labeled "eventually consistent")
- Saga: Event store subscription → saga → command dispatch (show as a box with subscribe and publish connections)
- Snapshots (if used): Show the snapshot store and the policy that triggers snapshot creation
- External event bus: Show Kafka or similar as a separate component that receives published events for downstream consumers
When to use Event Sourcing + CQRS
These patterns add significant complexity — don't use them by default. They're the right choice when you need:
- A complete, immutable audit trail (finance, healthcare, compliance)
- The ability to replay history and reconstruct state at any point in time
- Multiple read models with very different query patterns
- High write throughput with independent read scaling
- Complex business workflows where compensating transactions are needed
- Temporal queries ("what was the account balance on March 15?")
Related guides: software architecture patterns, microservice architecture patterns, event-driven architecture diagrams, and streaming data architecture.
Ready to try it yourself?
Start Creating - Free