Retail network · Supporting domain · EventStorming board
last-mile-delivery
Runs the final leg: delivery waves at a station, packages taken in when loads arrive, partner routes, delivery attempts, retries and returns.
- events published
- 13
- commands
- 16
- policies
- 16
- read models
- 2
- hot spots
- 5
The story in 4 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventDelivery
Wave Scheduled - Pivotal eventPackage
Out For Delivery - Pivotal eventDelivery
Attempted - Pivotal eventPackage
Return Initiated
Listens to (3): contexts whose events this one reacts to
Tells (3): contexts that react to its events
The board, row by row
16 rows, in the order the business story happens: the main path first, then how this context reacts to the others, then the clock. Rows are small stories; read each one left to right.
- Event
- Command
- Actor
- Aggregate
- Policy
- Read model
- External system
- Hot spot
- Opportunity
-
Keep the list of delivery stations
Node-topology announces every node. Only delivery stations matter here; a wave or a partner can be set up only for a station that is on this list.
Systemnode-topology EventNodeRegistered PolicyWhenever a node is registered, keep it only if it is a delivery stationCommandApplyNode started by the policyRegistered Read model · kept up to dateStationsSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go
-
Keep the stop of each labelled package
When a label is issued, the package's stop key and order assignment are kept. Packages for one address share a stop, so they take one place in a wave.
Systemshipping-and- tracking EventLabelIssued PolicyWhenever a label is issued, keep the package's stop key; a label without a usable key is ignoredCommandApplyLabel started by the policyIssued Read model · kept up to datePackage stopsSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go
-
Schedule a delivery wave
A station planner opens a wave: an induction cut-off, a delivery window and how many stops it can take. Packages already waiting at the station are taken into it, oldest first.
ActorStation plannerRead modelStationsCommandScheduleWave POST /wavesAggregateDeliveryWave EventDeliveryWave Scheduled EventDeliveryWave Capacity Changed Systemdelivery-promise PolicyAdds the wave to its copy so promises can use itSystemorder-sourcing PolicyAdds the wave to the network copy its search usesSource: application/usecases/waves.go · application/usecases/induct.go · domain/wave/wave.go
-
Take in packages when a load arrives
When a load reaches a delivery station, each package goes into the earliest wave that still accepts it. A package no wave accepts waits at the station and a deferral is announced.
Systemlinehaul-transportation EventLoadArrived PolicyWhenever a load reaches a delivery station, put each package on the earliest open wave or defer itRead modelStationsRead modelPackage stopsCommandInductOn started by the policyArrival AggregateDeliveryWave EventDeliveryWave Capacity Changed EventPackageInduction Deferred Systemdelivery-promise PolicyUpdates the room left on the wave; a deferred package flags its promise as at riskSystemorder-sourcing PolicyUpdates the room left on the wave in its network copySource: application/usecases/consumers.go · application/usecases/induct.go · domain/history/history.go
-
Declare what a stop costs
A station planner declares the cost of one stop on a wave that is still running. Order-sourcing adds it to the cost of the routes it compares.
ActorStation plannerCommandDeclareWave POST /waves/{waveId}/cost-declarationsCost AggregateDeliveryWave EventWaveCost Declared Systemorder-sourcing PolicyUses it as the wave's per-stop cost when comparing routesSource: application/usecases/waves.go · domain/wave/wave.go · 0011-wave-stop-cost-declaration.md
-
Declare the carbon a stop emits
A station planner declares the carbon, in grams of CO2-equivalent, of one stop on a wave that is still running. Nothing reads it yet.
ActorStation plannerCommandDeclareWave POST /waves/{waveId}/emission-declarationsEmission AggregateDeliveryWave EventWaveEmission Declared Source: application/usecases/waves.go · domain/wave/events.go · 0016-wave-stop-emission-declaration.md
-
Close induction on a wave
A station planner stops taking packages into a wave, so routes can be planned on a fixed set of packages.
ActorStation plannerCommandCloseInduction POST /waves/{waveId}/induction-closuresAggregateDeliveryWave -
Cancel a wave
A station planner cancels a wave that is still open. Its packages move to the next eligible wave in the same step, or wait at the station.
ActorStation plannerCommandCancelWave POST /waves/{waveId}/cancellationsAggregateDeliveryWave EventDeliveryWave Cancelled Systemdelivery-promise PolicyFlags promises whose route used the wave as at riskSystemorder-sourcing PolicyMarks the wave as cancelled in its network copy -
Contract a delivery partner
A station planner signs up a delivery service partner for a station, with the van capacity of its routes.
ActorStation plannerRead modelStationsCommandContractPartner POST /partnersAggregateDeliveryService Partner Source: application/usecases/partners.go · domain/partner/partner.go
-
Deactivate a delivery partner
A station planner deactivates a partner. It gets no new routes; routes already planned are not re-checked.
ActorStation plannerCommandDeactivatePartner POST /partners/{dspId}/deactivationsAggregateDeliveryService Partner Source: application/usecases/partners.go · domain/partner/partner.go
-
Plan a partner's route in a wave
A station planner gives a partner a numbered list of stops from a wave whose induction is closed. The route must fit the van, use only packages of the wave and keep one address in one stop.
ActorStation plannerCommandPlanRoute POST /routesAggregateRouteEventRoutePlanned analytics stream onlySource: application/usecases/routes.go · domain/route/route_planning.go
-
Dispatch a wave
A station planner sends the wave out. Packages that no route holds are moved to the next wave, and a wave with no route completes at once.
ActorStation plannerCommandDispatchWave POST /waves/{waveId}/dispatchesAggregateDeliveryWave -
Start a route
An operator starts a planned route of a dispatched wave. Every package goes out, for delivery or for pickup, and each stop gets an arrival window of up to two hours inside the wave's delivery window.
ActorOperatorCommandStartRoute POST /routes/{routeId}/startsAggregateRouteEventPackageOut For Delivery EventPackagePickup Out EventStopEta Window Assigned Systemshipping-and- tracking PolicyRecords an out-for-delivery scan and keeps the arrival window of each packageSource: application/usecases/routes.go · domain/route/route_start.go · domain/route/route_eta.go · 0017-return-pickup-inductions.md
-
Record a delivery attempt
The driver records for each package whether it was delivered or failed. A package is delivered at most once, and the route completes when every package has an attempt.
ActorDriverCommandRecordAttempt POST /routes/{routeId}/attemptsAggregateRouteEventDeliveryAttempted Systemshipping-and- tracking PolicyRecords a delivered or failed-delivery scan for the packageSource: application/usecases/routes.go · domain/route/route.go
-
Retry a failed delivery, or send it back
After a failed attempt the package goes on the next eligible wave. After the third failure it is not retried: a return to sender starts.
Event · earlierDeliveryAttempted PolicyWhenever an attempt fails, place the package on the next wave unless it was the third failureCommandRetryNext started by the policyWave AggregateHistoryEventPackageReturn Initiated Systemshipping-and- tracking PolicyMarks the package as returned to senderSource: application/usecases/routes.go · domain/history/history.go
-
Flag a drop-off point that keeps failing
Each attempt updates the profile of its stop. After two failed visits for not-home or access problems within 60 days, the point is flagged for the packages affected. A flag changes no route.
Event · earlierDeliveryAttempted PolicyWhenever an attempt is recorded, update the stop's profile; two failed visits flag the pointCommandObservestarted by the policyAggregateProfileEventDeliveryPoint Flagged Systemshipping-and- tracking PolicyKeeps the flag on every package of the stopSource: application/usecases/delivery_points.go · domain/deliverypoint/observe.go · 0014-delivery-point-profile.md
Hot spots and opportunities
Open questions and known gaps, each taken from a decision record or a document in the repository, never invented. Opportunities are improvements the documentation already names.
- Hot spotA route stays out for delivery until every package has an attempt. If the driver skips one, the route and its wave stay open.
- Hot spotDeactivating a partner re-checks nothing: routes already planned keep the partner and the van capacity read at planning time.
- Hot spotFailure reasons are free text and the optional outcome detail is dormant until a client sends it, so delivery-point flags depend on clients adopting it.
- Hot spotThe arrival window is spread evenly across the wave's window: there is no travel-time or position data to refine it.
Source: adr/0013-stop-eta-window.md
- Hot spotService-area assignments are kept but no decision reads them yet.
Opportunities
- OpportunityEntrance, parking and locker knowledge for a drop-off point is left to a later item that needs its own model change.
This board is a reconstruction from the code and documentation of last-mile-delivery at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.