← All articles

Event sourcing, or storing what happened instead of what is

Updated Nov 10, 2026 · 3 min read

Most systems store the current state of things. A parcel row says “in transit”, an account row says “balance 120”. Every change overwrites the last one. Event sourcing turns that around. You store every change as an event in an append-only log, and the current state becomes something you compute from the log. Package tracking is a natural fit, because a parcel’s story really is a list of scans.

The log is the truth

An event records something that happened, in the past tense. “Parcel 7731 was scanned at the Leeds depot at 06:12.” Events are never edited or deleted. New facts become new events. That gives you three things that are hard to get any other way.

  • Full history for free. “Where was it on Tuesday?” is just a read of the log.
  • Cheap, clash-free writes. Appending never fights with another append, so scans from thousands of scanners don’t contend for one row.
  • State you can rebuild. If the code that computes a status had a bug, fix it and replay the log.
readsScannersappend onlyScan lognever editedStatus viewprojectionTracking pageNotifiertexts on change
Scanners append to the log. Everything else reads the log afterwards, at its own pace.

Projections give you current state

Nobody wants to read a parcel’s whole log on every page view. A projection is a table built by reading the log, shaped for one use. The status view has one row per parcel with its latest status. A depot dashboard might count parcels by depot. Each projection is a consumer that reads new events and updates its table.

Projections lag the log slightly, usually by well under a second. That’s fine for a tracking page. If one breaks, or you want a new one, build it by replaying the log from the start, or from a snapshot, a saved copy of the projection at some point in the log.

Late and out-of-order events

Events don’t always arrive in the order they happened. A van loses signal for a morning and sends its scans at lunchtime. A scan from 9:05 can arrive after one from 10:40. If the status is “whatever arrived last”, the page moves a delivered parcel back onto the van.

RuleWhy
Store event time and arrival timeOrder by when it happened. Keep arrival time for debugging
Rank statusesA final status like Delivered can’t be undone by an earlier event
Slot late events into historyThe journey stays complete, even if the status doesn’t change
Expect clock driftDevice clocks are wrong sometimes, so the rank is the backstop

Repeated events

A scanner that isn’t sure its scan got through sends it again. A consumer that crashes after updating its table but before saving its place in the log reads some events twice. Logs deliver at least once, so every consumer has to cope with repeats. Give each event its own id and skip ids you’ve seen. For anything with a side effect, like a text message, key the effect too, such as one text per parcel per status.

Telling subscribers

Notifications are just another consumer. It reads the log, notices that a parcel’s status changed to Out for delivery, looks up who asked to hear about it, and puts a message on a queue. Separate senders work through the queue. The scan API never waits on an SMS provider, and a slow provider only makes texts late, not scans.

Sizing the log

Estimate from the hours events really happen. 10 million parcels a day with 8 scans each is 80 million scans. Spread over a 10-hour working day of 36,000 seconds, that’s about 2,200 a second. Divide by a full day and you’d plan for 2.4 times too little. Logs like Kafka split events into partitions, keyed by parcel id, so every event for one parcel stays in order in one place while the load spreads across many.

When not to use it

Event sourcing adds moving parts. Projections lag, schemas for old events must still be readable years later, and simple questions need a projection built first. It shines when history matters and events are the natural shape of the data, like tracking, ledgers and audit trails. For a settings page, a plain row is fine.