Event sourcing works nicely with aggregates from Domain driven design.

An aggregate has the responsibility of creating immutable events, command handlers that emit these events and validate them too.

Besides creating these events, they can be instantiated and create a state from consuming this history of events, or in other words “applying these events” with event handlers.

Reference

Hoffman, Kevin. Real-World Event Sourcing: Distribute, Evolve, and Scale Your Elixir Applications. The Pragmatic Bookshelf, 2025. The Pragmatic Programmers.

Highlights or timestamps

Real-World Event Sourcing

  • [?] An aggregate is a single, uniquely identifiable entity that has state, validates commands and emits events.

— highlight from Highlights of Real-World Event Sourcing

An event sourcing aggregate has the following required characteristics:

— highlight from Highlights of Real-World Event Sourcing

  • Validates incoming commands and returns one or more events

— highlight from Highlights of Real-World Event Sourcing

  • Applies events to state to produce new state

— highlight from Highlights of Real-World Event Sourcing

  • Application of events and commands is pure and referentially transparent.

— highlight from Highlights of Real-World Event Sourcing