event-drivenauditabilityreplaystate-modeling
Event Sourcing
Persist state as an append-only event log and rebuild current state by replay.
Definition
Event sourcing stores immutable domain events as source of truth; current state is materialized from the event stream.
When To Use
- Domains needing full history/auditability and temporal debugging.
- Systems requiring deterministic state reconstruction.
- Workflows with multiple read projections over same write facts.
When Not To Use
- Simple CRUD systems where event reconstruction adds unnecessary complexity.
- Use-cases without strict audit or replay requirements.
- Teams lacking event schema/versioning governance.
Tradeoffs
- Excellent auditability, but higher complexity in projection management.
- Supports flexible read models, with operational overhead for replay/backfill.
- Natural fit for temporal analysis, but event evolution requires strict discipline.
Common Failure Modes
- Projection lag causes stale user-facing reads.
- Schema evolution errors break replay compatibility.
- Event ordering gaps create nondeterministic state reconstruction.
Interview Framing
Use this structure when the interviewer asks for this pattern explicitly.
Explain command/event boundaries, projection strategy, replay windows, and schema compatibility controls.
Related Project Deep Dives
Event Replay Platform for Debugging Microservices
Design an event replay platform that allows developers to capture, store, and replay events from microservices for debugging and testing purposes. Enable time-travel debugging across distributed systems.
Collaborative Document Branching System
Design a branching and merging system for real-time collaborative documents with CRDT sync, conflict resolution, and full audit history.
Related Concepts
Transactional Outbox Pattern
Atomically persist business state and event records in one DB transaction, then publish asynchronously.
Exactly-Once Processing (Practical)
Achieve effective exactly-once outcomes via idempotency, transactions, and dedup rather than magic guarantees.
Change Data Capture (CDC)
Stream database changes from logs to downstream systems with low-latency propagation.