Event Sourcing & CQRS Vocabulary
5 exercises — master the vocabulary of event-sourced architectures: event stores, projections, read models, command vs query separation, event replay for recovery, and crypto-shredding for GDPR.
0 / 5 completed
Event Sourcing & CQRS vocabulary quick reference
- Event Sourcing — domain events are the source of truth; current state is derived by replaying events
- Event store — append-only database storing the immutable event sequence
- Projection — process that reads events and builds an optimised read model
- Read model — denormalized, query-optimised view derived from projections
- CQRS — separates write operations (commands → event store) from reads (queries → read model)
- Event replay — reprocessing all events to rebuild state (recover from bugs)
- Crypto-shredding — GDPR erasure by deleting the encryption key for a user's encrypted PII
1 / 5
What is Event Sourcing, and how does it differ from traditional (state-based) persistence?
Event Sourcing is a fundamentally different approach to persistence — events ARE the database.
Traditional (state-based) persistence:
• You store the current state:
• To update: overwrite the row with new state
• History is lost — you can't see the previous statuses
Event Sourcing:
• You store events:
• To get current state: replay all events through an aggregate
• Complete history is preserved — every state change is recorded
Benefits of Event Sourcing:
• Complete audit trail — you know every state transition and when it happened
• Temporal queries — reconstruct state at any point in time
• Event replay — rebuild projections, fix bugs, backfill new read models
• Debugging — the full history of what happened is always available
Costs:
• More complex to implement than simple CRUD
• Queries require projections (not simple SQL SELECTs)
• Schema evolution is harder (events are immutable)
Key vocabulary:
• Event store — the append-only database that stores the event sequence
• Append-only — events are never updated or deleted, only new events are added
• Event replay — rebuilding current state by processing all historical events
Traditional (state-based) persistence:
• You store the current state:
{"orderId": "123", "status": "shipped"}• To update: overwrite the row with new state
• History is lost — you can't see the previous statuses
Event Sourcing:
• You store events:
OrderPlaced → PaymentReceived → OrderShipped• To get current state: replay all events through an aggregate
• Complete history is preserved — every state change is recorded
Benefits of Event Sourcing:
• Complete audit trail — you know every state transition and when it happened
• Temporal queries — reconstruct state at any point in time
• Event replay — rebuild projections, fix bugs, backfill new read models
• Debugging — the full history of what happened is always available
Costs:
• More complex to implement than simple CRUD
• Queries require projections (not simple SQL SELECTs)
• Schema evolution is harder (events are immutable)
Key vocabulary:
• Event store — the append-only database that stores the event sequence
• Append-only — events are never updated or deleted, only new events are added
• Event replay — rebuilding current state by processing all historical events
Next up: Saga Pattern →