Modeling · demo 10

Event Sourcing: the balance doesn't exist, it is replayed

Alice's balance is not stored, the sequence of facts is: opening, withdrawals, transfers. For each command, the aggregate reads the stream back and replays it to find its state, decides, then appends an event, if nobody wrote in the meantime.

Reduced motion: the scene is paused; use "Step" or "Play".

    What to watch

    • The amber cursor replays the events one by one: that is how the aggregate finds its balance. Every 5 events, a snapshot saves replaying everything; Clear the snapshots loses nothing, the next load is just longer.
    • Concurrent write: two writers load the same version; the first appends its event, the second gets a 409 and writes nothing (optimistic concurrency).
    • ◀ Version: time travel replays only the first N events. As in the doc: at version 2, Alice had €900.