Skip to content

Document "Closing the Books" pattern as alternative to snapshots #139

Description

@joeldsouzax

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

  1. Identify natural business lifecycle boundaries (shift end, day close, billing period)
  2. When a lifecycle ends, store a summary event containing required carry-forward state
  3. Archive old events, begin a new stream
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions