System Design Atlas

Waste collection routes and disposal records

04 / 10Worked example

Interfaces

How does the report-emptying contract distinguish a retry from a new intent?

The load profile now applies to the specific command “report emptying”. Its payload contains the route, bin, device event, action time and reported mass. An idempotency key recognises the same intent after a response is lost; an aggregate version protects the business state against concurrent changes.

Starting point Reconnection determines peak processing load.

Assumptions for the example case

Original fictional example design. A municipal collection service for non-hazardous waste uses its own operational records and confirmed handovers. The illustrative load limit is 10000 kg; additional planned loading is allowed only if total mass remains ≤ 10000 kg. All figures and test targets are illustrative assumptions.

Commands, retries and current state

Command and replay

CommandCollection route T-38 · Bin B-38 · Handover record U-38
Command → Touren-APICheck content and expected version
Collection route APIAccept the command or recognise a replay
Touren-API → ErgebnisjournalCommit the result before responding
Result journalFingerprint + stored record

Identical content returns the same record; changed content produces a conflict.

The report-emptying command links the route, bin, device event, action time and reported mass. Reusing the key leads back to the stored result; changing the content leads to a conflict.

Proposed API for this example

  1. POST/abfalltouren/{id}/commands

    Report emptying

    Input
    Route, bin, device event, action time and reported mass; expected aggregate version, authorised role and stable command key.
    Result
    Durably stored business result and new version; version or content conflicts produce no partial effects. An accepted external request receives an open status.
    Retry behaviour
    The key is scoped to the actor, operation and business object. After authentication, first compare the existing result and canonical content: identical content returns the stored evidence; changed content produces a conflict. Only new keys trigger validation of the current version.
  2. GET/abfalltouren/{id}

    Read the current business state and reason for investigation.

    Input
    Authorised identity and business object.
    Result
    Collection route with its current version, evidence and reason for pending work.
    Retry behaviour
    Repeating a read creates no business change; access is checked again.

Additional state changes

OperationInputResult and protection
Report a bin exceptionCollection team, route, bin and actual reasonThe bin work order records an exception instead of an emptying.
End collectionCollection team, version and a complete set of bin outcomesunterwegs → übergabe_offen; all unresolved bin outcomes must be explicitly resolved.
Accept the loadReceiving facility, route/load, weighing record and massMatching record → übergeben; differing assignment or mass → klärfall.
Complete the chain of evidenceRecords officers, handover and resolved exceptionsübergeben or resolved klärfall → abgeschlossen; the completion record remains immutable.

Report a bin exception

Input
Collection team, route, bin and actual reason
Result and protection
The bin work order records an exception instead of an emptying.

End collection

Input
Collection team, version and a complete set of bin outcomes
Result and protection
unterwegs → übergabe_offen; all unresolved bin outcomes must be explicitly resolved.

Accept the load

Input
Receiving facility, route/load, weighing record and mass
Result and protection
Matching record → übergeben; differing assignment or mass → klärfall.

Complete the chain of evidence

Input
Records officers, handover and resolved exceptions
Result and protection
übergeben or resolved klärfall → abgeschlossen; the completion record remains immutable.

Messages across the external boundary

Source contract
ZKS-Abfall describes unique identifiers for formal waste records. This case uses its own operational records and does not claim eANV compliance.
System responsibility
The device sends a locally stored bin-emptying record. The collection route API checks the route-and-bin assignment and event identity, then acknowledges only after commit. A second report with a different mass is stored as a discrepancy; the receiving facility later confirms the actual total load.

A device event identifies its route and bin

A device event identifies its route and bin

A device event identifies its route and bin.

A report-emptying command may arrive again after a response is lost.

The route, bin, device event, action time and reported mass must remain identical on replay. The exercise specifies the input and expected result.

Alternative considered
A key stored only in volatile memory loses its evidence on restart.
Trade-off
The journal for report-emptying commands requires durable retention and protected access.
Reassess
The documented retry window and journal volume determine the future archiving strategy.

Try it yourself

Predict the results of an identical report-emptying retry, the same key with a different mass, and a new key with an old version.

A hint for your attempt

Retry identity and current state require separate checks.

Compare with a possible solution
Identical
The stored result for collection route T-38 is returned; its effect is not repeated.
Changed
The same key with altered canonical content results in conflict.
New intent with a stale version
A new key with a stale version is rejected before any business change. The interface reloads the current state and asks the user to confirm the decision again.

Apply to your project

Which input fields make two change intentions different in your project?

Next: each route-and-bin work order records one effective emptying.