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.

GitHub ↗ · Documentation ↗ · Architecture check · Briefings

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.

  1. Pivotal eventDepartureScheduled
  2. Pivotal eventBookingMoved
  3. Pivotal eventLoadDeparted
  4. Pivotal eventLoadArrived

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
  1. 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.

    ActorPlanner
    Read modelLane and node copies
    CommandDefineLaneSchedulePOST /lane-schedules
    AggregateLaneSchedule

    Source: application/usecases/schedules.go · domain/schedule/schedule.go

  2. 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.

    ActorPlanner
    CommandRetireLaneSchedulePOST /lane-schedules/{laneId}/retirements
    AggregateLaneSchedule

    Source: application/usecases/schedules.go · domain/schedule/schedule.go

  3. 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 roll
    PolicyEvery interval, plan the departures missing from the next 14 days of every active schedule
    Read modelLane and node copies
    CommandGenerateDeparturesstarted by the clock
    AggregateDeparture
    EventDepartureScheduled
    Systemdelivery-promise
    PolicyAdds the departure to its copy so promises can use it
    Systemorder-sourcing
    PolicyAdds the departure to the network copy its search uses

    Source: application/usecases/generate.go · domain/schedule/plan.go · domain/departure/departure.go

  4. 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-offs
    CommandHandleNodeActivatedstarted by the policy
    AggregateDeparture
    EventDepartureScheduled
    Read model · kept up to dateLane and node copies
    Systemdelivery-promise
    PolicyAdds the pickup to its copy so promises can use it
    Systemorder-sourcing
    PolicyAdds the pickup to the network copy its search uses

    Source: application/usecases/consumers.go · application/usecases/generate.go · domain/schedule/pickup.go

  5. 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 pickups
    CommandHandleNodeSuspendedstarted by the policy
    AggregateDeparture
    EventDepartureCancelled
    Read model · kept up to dateLane and node copies
    Systemdelivery-promise
    PolicyFlags promises whose route used the pickup as at risk
    Systemorder-sourcing
    PolicyMarks the pickup as cancelled in its network copy

    Source: application/usecases/consumers.go · application/usecases/booking.go · domain/departure/departure.go

  6. 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.

    ActorPlanner
    CommandCancelDeparturePOST /departures/{departureId}/cancellations
    AggregateDeparture
    EventDepartureCancelled
    Systemdelivery-promise
    PolicyFlags promises whose route used the departure as at risk
    Systemorder-sourcing
    PolicyMarks the departure as cancelled in its network copy

    Source: application/usecases/departures.go · application/usecases/booking.go · domain/departure/departure.go

  7. Change a departure's capacity

    A planner resizes a departure that has not left. It cannot go below what is already booked.

    ActorPlanner
    CommandChangeDepartureCapacityPUT /departures/{departureId}/capacity
    AggregateDeparture
    EventDepartureCapacityChanged
    Systemdelivery-promise
    PolicyUpdates the room left on its copy of the departure
    Systemorder-sourcing
    PolicyUpdates the room left on its copy of the departure

    Source: application/usecases/departures.go · domain/departure/departure.go

  8. 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 failure
    Read modelExpected volume
    CommandHandleLockedstarted by the policy
    AggregateExpectedVolume
    EventDepartureCapacityChanged
    EventBookingMoved
    EventBookingFailed
    Systemorder-sourcing
    PolicyPoints the locked group at the new pickup; a failed booking changes nothing there
    Systemdelivery-promise
    PolicyFlags the promise as at risk and skips the departure that was left

    Source: application/usecases/consumers.go · application/usecases/booking.go · domain/volume/volume.go · 0014-consolidated-follower-lock-books-nothing.md

  9. 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
    EventFulfillmentReleasedToNode
    PolicyWhenever a group is released, reassigned or cancelled, update its expected volume record
    CommandHandleReleasedstarted by the policy
    Read model · kept up to dateExpected volume

    Source: application/usecases/consumers.go · domain/volume/volume.go

  10. 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.

    PolicyWhenever a label is issued or voided, add or remove its tracking number on the group's record
    CommandHandleLabelIssuedstarted by the policy
    Read model · kept up to dateExpected volume

    Source: application/usecases/consumers.go · domain/volume/volume.go

  11. 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.

    ActorOperator
    CommandOpenLoadPOST /loads
    AggregateLoad

    Source: application/usecases/loads.go · domain/load/load.go

  12. 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.

    ActorOperator
    CommandAddPackagePOST /loads/{loadId}/packages
    AggregateLoad

    Source: application/usecases/loads.go · domain/load/load.go

  13. Close the load

    An operator closes the load; the departure closes with it. No package can be added afterwards.

    ActorOperator
    CommandCloseLoadPOST /loads/{loadId}/closures
    AggregateLoad
    EventLoadClosedanalytics stream only

    Source: application/usecases/loads.go · domain/load/load.go

  14. Dispatch the load

    An operator sends a closed load on its way. The load and its departure are recorded as departed.

    ActorOperator
    CommandDispatchLoadPOST /loads/{loadId}/dispatches
    AggregateLoad
    EventLoadDeparted
    EventDepartureDepartedanalytics stream only
    Systemshipping-and-tracking
    PolicyRecords a departure scan for each tracking number
    Systemdelivery-promise
    PolicyStarts timing the trip to measure real transit time

    Source: application/usecases/loads.go · domain/load/load.go · domain/departure/departure.go

  15. Receive the load at its destination

    An operator receives a departed load at its destination. The load and its departure are recorded as arrived.

    ActorOperator
    CommandReceiveLoadPOST /loads/{loadId}/receipts
    AggregateLoad
    EventLoadArrived
    EventDepartureArrivedanalytics stream only
    Systemlast-mile-delivery
    PolicyTakes in each package when the load reaches a delivery station
    Systemshipping-and-tracking
    PolicyRecords an arrival scan for each tracking number
    Systemdelivery-promise
    PolicyCompletes the measured transit time and notes the arrival

    Source: 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.

    Source: adr/0002-aggregates-and-invariants.md

  • Hot spotA closed lane cancels nothing: departures already planned on it stay until a planner cancels them by hand.

    Source: adr/0002-aggregates-and-invariants.md

  • 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.