The Event-Sourced Time Machine — Rebuild Any State Without Rewriting History
Issue real warehouse commands, watch immutable events become disposable projections, rewind without erasing, and fork a future the canonical timeline never has to believe.
What this is
A local-first warehouse flight recorder in one self-contained HTML file. Register products, receive inventory, place and ship orders, cancel reservations, and make controlled stock adjustments. Commands validate against the active head projection; accepted commands append one deeply frozen, hash-linked event, while rejected commands advance no sequence at all. The inventory table, order cards, operational metrics, branch comparison, and every displayed state fingerprint are rebuilt from those events.
The replay cursor can move from genesis to the latest valid sequence without touching history. Verified snapshots cache derived state, a deterministic incident preset always produces the same stream, and the data port exports plain JSON or atomically validates an import entirely in the browser.
Why this is mind-blowing
Rewinding changes what the application knows without changing what happened. Fork sequence six and the hypothetical timeline inherits the same verified past, then grows a separate hash chain whose inventory can be compared directly with canonical reality. Neither future edits the other.
Then break it on purpose. The corruption control appends a plausible event with a forged previous-hash link. The reducer stops at the last trustworthy fact, writes lock, the invalid envelope remains visible, and strict import refuses to absorb it. Replay is not an animation here—it is the proof that immutable facts plus a deterministic reducer reproduce the same state hash.
Prompt
Build “The Event-Sourced Time Machine — Rebuild Any State Without Rewriting History,” a polished, local-first, single-file event-sourcing lab. Use a concrete domain (inventory/orders or banking) with commands that validate and append immutable events. Show event log, one or more projections, current sequence/hash, replay cursor, snapshots, and rejected commands. Users can rewind the projection without mutating history, fork a hypothetical branch, compare branch state with canonical state, replay, inject a corrupt event to demonstrate validation, export/import JSON, and reset/run a deterministic incident preset. Ensure projection state is actually derived from events and replay produces the same hash. Include pause/step where useful, accessible keyboard/touch controls, responsive 390px layout, reduced motion. Inline self-contained HTML/CSS/JS only, no dependencies/network/build, <=160KB.
Paste into your favorite AI and adapt it to your context.
What I learned shipping it
- Why event sourcing separates facts from views: commands may be rejected, accepted events become immutable history, and every projection can be deleted and rebuilt without losing the business record.
- How hash-linked envelopes, deterministic reducers, verified snapshots, and atomic import validation turn replay from a visual trick into an integrity proof.
- Why a branch is not an edit to the past: it shares a canonical prefix, owns an isolated tail, and can be compared with the real head without rewriting either timeline.