Summary
"Closing the Books" is an increasingly popular domain-driven alternative to aggregate snapshots that eliminates the need for snapshots entirely by redesigning stream boundaries.
Pattern
- Identify natural business lifecycle boundaries (shift end, day close, billing period)
- When a lifecycle ends, store a summary event containing required carry-forward state
- Archive old events, begin a new stream
- The summary event acts like a snapshot but is a first-class domain concept
Example: Instead of one CashRegister stream with thousands of events needing snapshots, model as individual CashierShift streams. Each shift ends with a CashierShiftEnded event containing all summaries. Next shift starts a new stream.
Benefits over snapshots
- No schema versioning problem (summary events are domain events, versioned like any other)
- Natural archival boundaries
- Shorter streams = faster replay without any snapshot mechanism
- Aligns with business reality
What to do
- Add a section in the nexus documentation explaining this pattern
- Include an example showing the contrast between long-lived aggregate + snapshot vs. lifecycle-bounded streams
- Reference this as the preferred approach before reaching for
snapshot feature
References
Summary
"Closing the Books" is an increasingly popular domain-driven alternative to aggregate snapshots that eliminates the need for snapshots entirely by redesigning stream boundaries.
Pattern
Example: Instead of one
CashRegisterstream with thousands of events needing snapshots, model as individualCashierShiftstreams. Each shift ends with aCashierShiftEndedevent containing all summaries. Next shift starts a new stream.Benefits over snapshots
What to do
snapshotfeatureReferences