System Design Atlas

Parcel delivery with offline synchronisation

05 / 10Worked example

Data and states

What identity deduplicates an event?

An append-only event history feeds a protected shipment projection.

Starting point Use device, route, version and sequence.

Assumptions for the example case

Illustrative design: 100,000 shipments per day, 50 events per shipment, 250 bytes of raw data per event, 500 events/s peak. This yields 5 million events and 1.25 GB of raw data per day. Retention, indices and replication are added.

Data and state model

S-17 is only changed by the gapless active sequence.

Conditions and protection

ObjectStateRule
S-17out_for_delivery → delivered | delivery_failed → returnedterminal does not reset
R-17Version 4 is activev3 events superseded
N-17Tied to deliveredReject delivered without proof type

S-17

State
out_for_delivery → delivered | delivery_failed → returned
Rule
terminal does not reset

R-17

State
Version 4 is active
Rule
v3 events superseded

N-17

State
Tied to delivered
Rule
Reject delivered without proof type

Terms in this step

Projection
State derived from a course of events, which can be read quickly.

Try it yourself

Form the key for sequence 43.

A hint for your attempt

Four parts determine the device sequence.

Compare with a possible solution
Keys
D-17/R-17/v4/43.
Content
The fingerprint protects shipment, event type, evidence type and event time.

Apply to your project

Form a key for a second device.

The architecture assigns acceptance and projection processes.