Skip to main content
PreparationZone Logo
PrepZone

Event Sourcing on a Kafka Log

Rebuild VaultCommerce order state from the event log — snapshots, replay, and temporal queries.

Pass checkpoint below

Why this matters

  • VaultCommerce order read model rebuilds from OrderPlaced, PaymentCaptured, OrderShipped events.
  • Snapshots every 100 events avoid replaying 5 years of history on cold start.
  • Temporal queries ('what was inventory on date X?') need full event history or snapshots.
  • Pairs with CQRS — write side emits events, read side projects to Postgres/ES.
Partition log
Segment 0offsets 0–999
Segment 1offsets 1000–1999
Active segmentoffsets 2000+
Consumer offset 1850Points into segment 1
Each partition is an append-only sequence of segments. Consumers track position by offset.

Event store patterns on Kafka

Compacted topic keyed by orderId holds latest snapshot OR full event stream on separate topics. VaultCommerce uses non-compacted event stream + Postgres projection as source of truth for queries. Kafka retention = 90 days; archive to S3 for compliance.

Key points

  • Event sourcing — state derived by applying ordered events
  • Projection — materialized view built by consuming events
  • Snapshot — cached aggregate state at a point in time
  • CQRS — separate write model (commands/events) and read model
  • Replay — reprocess history to rebuild or fix projections

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Snapshots and replay
  • VaultCommerce rollout checklist

Test yourself

Answer these before moving on — recall is what makes it stick.