Retail network · Supporting domain · EventStorming board
linehaul-transportation
Plans the trucks and flights between nodes, books each locked order's package on a pickup, and tracks loads from dispatch to arrival.
- events published
- 10
- commands
- 15
- policies
- 23
- read models
- 2
- hot spots
- 4
The story in 4 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventDeparture
Scheduled - Pivotal eventBooking
Moved - Pivotal eventLoad
Departed - Pivotal eventLoad
Arrived
Listens to (3): contexts whose events this one reacts to
Tells (4): contexts that react to its events
The board, row by row
15 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
-
Define a lane's weekly schedule
A planner sets the weekly template of a lane: for each slot the cut-off, departure and arrival times and how many packages fit. Redefining replaces the slots; departures already planned stay.
ActorPlannerRead modelLane and node copiesCommandDefineLane POST /lane-schedulesSchedule AggregateLaneSchedule Source: application/usecases/schedules.go · domain/schedule/schedule.go
-
Retire a lane's schedule
A planner retires the schedule of a lane. No new departures are planned from it; departures already planned are not cancelled.
ActorPlannerCommandRetireLane POST /lane-schedules/{laneId}/retirementsSchedule AggregateLaneSchedule Source: application/usecases/schedules.go · domain/schedule/schedule.go
-
Keep two weeks of departures planned
At start and then every interval, every active lane schedule is expanded into departures for the next 14 days. A rerun adds only what is missing.
TimeHorizon rollPolicyEvery interval, plan the departures missing from the next 14 days of every active scheduleRead modelLane and node copiesCommandGenerateDepartures started by the clockAggregateDepartureEventDepartureScheduled Systemdelivery-promise PolicyAdds the departure to its copy so promises can use itSystemorder-sourcing PolicyAdds the departure to the network copy its search usesSource: application/usecases/generate.go · domain/schedule/plan.go · domain/departure/departure.go
-
Plan pickups when a vendor centre goes live
A vendor-run centre gets a pickup departure for each of its declared cut-offs, over 14 days. Pickups are re-planned when its profile changes or a lane opens, whichever arrives last.
Systemnode-topology EventNodeActivated PolicyWhenever a centre is activated, revised or gets a lane, plan its pickups from its cut-offsCommandHandleNode started by the policyActivated AggregateDepartureEventDepartureScheduled Read model · kept up to dateLane and node copiesSystemdelivery-promise PolicyAdds the pickup to its copy so promises can use itSystemorder-sourcing PolicyAdds the pickup to the network copy its search usesSource: application/usecases/consumers.go · application/usecases/generate.go · domain/schedule/pickup.go
-
Stop pickups when a centre leaves service
When a node is suspended or retired, its future pickups are cancelled, and every package booked on them is moved to the next pickup or reported as failed.
Systemnode-topology EventNodeSuspended PolicyWhenever a node is suspended or retired, cancel its future pickupsCommandHandleNode started by the policySuspended AggregateDepartureEventDepartureCancelled Read model · kept up to dateLane and node copiesSystemdelivery-promise PolicyFlags promises whose route used the pickup as at riskSystemorder-sourcing PolicyMarks the pickup as cancelled in its network copySource: application/usecases/consumers.go · application/usecases/booking.go · domain/departure/departure.go
-
Cancel a departure
A planner cancels a departure that has not left. Every package booked on it moves to the next pickup from the same origin, or the booking is reported as failed.
ActorPlannerCommandCancelDeparture POST /departures/{departureId}/cancellationsAggregateDepartureEventDepartureCancelled Systemdelivery-promise PolicyFlags promises whose route used the departure as at riskSystemorder-sourcing PolicyMarks the departure as cancelled in its network copySource: application/usecases/departures.go · application/usecases/booking.go · domain/departure/departure.go
-
Change a departure's capacity
A planner resizes a departure that has not left. It cannot go below what is already booked.
ActorPlannerCommandChangeDeparture PUT /departures/{departureId}/capacityCapacity AggregateDepartureEventDepartureCapacity Changed Systemdelivery-promise PolicyUpdates the room left on its copy of the departureSystemorder-sourcing PolicyUpdates the room left on its copy of the departureSource: application/usecases/departures.go · domain/departure/departure.go
-
Book a package when the order locks
When a group locks on a node, one package is booked on its pickup. If that pickup is full, closed or gone the booking moves to the next pickup, or fails. A merged package books only once.
Systemorder-sourcing EventFulfillmentLocked PolicyWhenever a group locks, book one package on its pickup, or the next one, or report a failureRead modelExpected volumeCommandHandleLocked started by the policyAggregateExpectedVolume EventDepartureCapacity Changed EventBookingMoved EventBookingFailed Systemorder-sourcing PolicyPoints the locked group at the new pickup; a failed booking changes nothing thereSystemdelivery-promise PolicyFlags the promise as at risk and skips the departure that was leftSource: application/usecases/consumers.go · application/usecases/booking.go · domain/volume/volume.go · 0014-consolidated-follower-lock-books-nothing.md
-
Keep the expected volume
Each release tells linehaul which node and planned pickup a group is heading for. A reassignment or cancellation only updates this record; nothing is booked before the lock.
Systemorder-sourcing EventFulfillmentReleased To Node PolicyWhenever a group is released, reassigned or cancelled, update its expected volume recordCommandHandleReleased started by the policyRead model · kept up to dateExpected volumeSource: application/usecases/consumers.go · domain/volume/volume.go
-
Keep the tracking numbers
Shipping-and-tracking issues the labels. Linehaul keeps each tracking number on the group's record; a voided label removes its number but keeps the booking.
Systemshipping-and- tracking EventLabelIssued PolicyWhenever a label is issued or voided, add or remove its tracking number on the group's recordCommandHandleLabel started by the policyIssued Read model · kept up to dateExpected volumeSource: application/usecases/consumers.go · domain/volume/volume.go
-
Open a load on a departure
An operator opens the load that will ride a departure that has not left. A departure has at most one load.
ActorOperatorCommandOpenLoad POST /loadsAggregateLoad -
Add a package to the load
An operator scans a package onto an open load. A package can be on only one open load, and the load cannot exceed the departure's capacity. On a truck or flight (not a pickup) the package also takes a seat.
ActorOperatorCommandAddPackage POST /loads/{loadId}/packagesAggregateLoad -
Close the load
An operator closes the load; the departure closes with it. No package can be added afterwards.
ActorOperatorCommandCloseLoad POST /loads/{loadId}/closuresAggregateLoadEventLoadClosed analytics stream only -
Dispatch the load
An operator sends a closed load on its way. The load and its departure are recorded as departed.
ActorOperatorCommandDispatchLoad POST /loads/{loadId}/dispatchesAggregateLoadEventLoadDeparted EventDepartureDeparted analytics stream onlySystemshipping-and- tracking PolicyRecords a departure scan for each tracking numberSystemdelivery-promise PolicyStarts timing the trip to measure real transit timeSource: application/usecases/loads.go · domain/load/load.go · domain/departure/departure.go
-
Receive the load at its destination
An operator receives a departed load at its destination. The load and its departure are recorded as arrived.
ActorOperatorCommandReceiveLoad POST /loads/{loadId}/receiptsAggregateLoadEventLoadArrived EventDepartureArrived analytics stream onlySystemlast-mile- delivery PolicyTakes in each package when the load reaches a delivery stationSystemshipping-and- tracking PolicyRecords an arrival scan for each tracking numberSystemdelivery-promise PolicyCompletes the measured transit time and notes the arrivalSource: application/usecases/loads.go · domain/load/load.go · domain/departure/departure.go
Hot spots and opportunities
Open questions and known gaps, each taken from a decision record or a document in the repository, never invented.
- Hot spotA booking that fails leaves the locked group without a seat. Order-sourcing only records it; delivery-promise flags the promise as at risk.
Source: docs/ddd/eventstorming.md
- Hot spotIf order-sourcing cancels after the lock, the package stays booked on its departure until the departure leaves.
- Hot spotA closed lane cancels nothing: departures already planned on it stay until a planner cancels them by hand.
- Hot spotThere is no metric for the unsent-event backlog, consumer lag or the horizon roll, and no alert on parked failed messages; they are read from the database and logs.
Source: docs/operations/observability.md
This board is a reconstruction from the code and documentation of linehaul-transportation at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.