System Design Atlas

Parcel delivery with offline synchronisation

04 / 10Worked example

Interfaces

What distinguishes duplicate and conflict?

Acceptance, application and conflict are different outcomes.

Starting point Compare key and fingerprint.

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.

Interfaces

Device, API and Status View exchange versioned contracts.

API contracts

  1. POST/routes/R-17/events

    Accepting device event

    Input
    D-17, v4, sequence, content
    Result
    accepted, duplicate, conflict or superseded
    Retry behaviour
    identical fingerprint provides duplicate
  2. GET/sync/D-17

    Read the synchronization status

    Input
    Device and active route
    Result
    Last applied sequence and gaps
    Retry behaviour
    Safely repeatable
  3. GET/shipments/S-17

    Reading the status of the shipment

    Input
    Authorised access
    Result
    State and evidence reference
    Retry behaviour
    Safely repeatable

Terms in this step

Superseded
Validly received, but superseded in the domain by a newer route assignment.

Try it yourself

Evaluate two repetitions of sequence 43 .

A hint for your attempt

Once identical, once different evidence type.

Compare with a possible solution
Identical
duplicate.
Changed
conflict.

Apply to your project

Define results for an offline form upload.

The data model explains the state effect.