A courier's scans reach the system
sequence
From a barcode scan on an offline handheld to the recipient's SMS
/
Fit
SVG
PNG
Mermaid
Save layout
Reset layout
Step 1: scan the barcode
1. scan the barcode
Step 2: POST /v1/scans · the whole batch, over mTLS
2. POST /v1/scans
the whole batch, over mTLS
Step 3: insert if new · unique index on idempotency_key
3. insert if new
unique index on idempotency_key
Step 4: inserted?
4. inserted?
Step 5: parcel.scanned
5. parcel.scanned
Step 6: count it as a duplicate
6. count it as a duplicate
Step 7: 200 OK · accepted, duplicates
7. 200 OK
accepted, duplicates
Step 8: parcel.scanned
8. parcel.scanned
Step 9: apply the scan · ordered by scanned_at, not arrival
9. apply the scan
ordered by scanned_at, not arrival
Step 10: UPDATE parcel status
10. UPDATE parcel status
Step 11: ok
11. ok
Step 12: parcel.delivered
12. parcel.delivered
Step 13: parcel.delivered
13. parcel.delivered
Step 14: send the delivered SMS
14. send the delivered SMS
Step 15: queued
15. queued
alt
[a scan we have not seen]
[already held: the batch was replayed]
loop
[for each scan in the batch]
opt
[it was a delivery scan]
Offline for hours is normal. Scans
queue on the device, each with an
idempotency key.
Courier
Courier
Courier
Courier handheld · Kotlin / Android
Courier handheld
Kotlin / Android
Courier handheld
Kotlin / Android
Scan ingest · Go · The only service that knows about devices
Scan ingest
Go
Scan ingest
Go
Relay DB · PostgreSQL 15
Relay DB
PostgreSQL 15
Relay DB
PostgreSQL 15
Parcel events · Kafka
Parcel events
Kafka
Parcel events
Kafka
Dispatch · Java / Spring
Dispatch
Java / Spring
Dispatch
Java / Spring
Notifier · Node.js
Notifier
Node.js
Notifier
Node.js
Twilio
Twilio
external
Twilio
external
drag a box to move it · drag empty space to pan · wheel to zoom · click a node
Why the loop matters
The same batch may arrive twice if an upload times out. The unique index makes replaying it change nothing.
Late scans are published like fresh ones; Dispatch orders by scanned_at.