System Design Atlas

Parcel delivery with offline synchronisation

06 / 10Worked example

The overall architecture

Why is the API not allowed to confirm before permanent storage?

The API accepts events durably; the worker can continue processing contiguous event sequences.

Starting point Simulate a crash right after 2xx.

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.

Runtime architecture

Ingestion and the domain projection have explicit commit boundaries.

API and worker modules

Synchronization, sequence and backlog are separate responsibilities.

Boundaries

Acceptance
Store the key and fingerprint permanently before confirmation.
Projection
Apply active sequences on S-17 only.

Terms in this step

Inbox
Durable ingestion log for messages delivered at least once.

Try it yourself

Assign inbox and projection to commits.

A hint for your attempt

A gap may persist after acceptance.

Compare with a possible solution
Inbox
Confirms durable acceptance.
Projection
Follows once the event sequence is contiguous.

Apply to your project

Use the separation for sensor data.

The sequences show gap, duplicate and old route.