Retail network · Generic domain · EventStorming board

shipping-and-tracking

Issues shipping labels and keeps one timeline per package, from handover to delivery, return or loss.

GitHub ↗ · Documentation ↗ · Architecture check · Briefings

events published
13
commands
14
policies
42
read models
4
hot spots
5

The board, row by row

20 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. Issue a label for a package

    A vendor asks for a label for one package of a purchase order. The shipping address is fetched live and checked; if it looks like a placeholder the label is refused. Otherwise the label and the package's journey start together.

    ActorVendor (through partner connectivity)
    Read modelShipping address of the order
    CommandIssueLabelPOST /labels
    AggregateShippingLabel
    EventLabelIssued
    Systemlinehaul-transportation
    PolicyAdds the tracking number to the booking's expected volume
    Systemcustomer-ordering
    PolicyCreates the package row that the order's tracking view reads
    Systemlast-mile-delivery
    PolicyKeeps the opaque stop id and postal prefix so it can group packages into stops

    Source: application/usecases/labels.go · domain/label/label.go · domain/journey/journey.go

  2. Void a label

    An operator voids a label that should not be used. It only works while the package is still waiting for pickup; once it is handed over the void is refused.

    ActorOperator
    CommandVoidLabelPOST /labels/{labelRef}/voids
    AggregateShippingLabel
    EventLabelVoided
    Systemcustomer-ordering
    PolicyMarks the package as voided
    Systemlinehaul-transportation
    PolicyDrops the tracking number from the expected volume; the booking stays

    Source: application/usecases/labels.go · domain/label/label.go · domain/journey/journey.go

  3. Record a scan by hand

    An operator adds a scan to a package's journey. It follows the same rules as scans from partners: an old, repeated or impossible scan is refused, and a handover or delivery scan also announces that milestone.

    ActorOperator
    CommandRecordScanPOST /journeys/{trackingNumber}/scans
    AggregateJourney
    EventPackageScanned
    EventPackageHandedOver
    EventPackageDelivered
    Systemcustomer-ordering
    PolicyAdds the scan to the order's tracking timeline
    Systemnode-performance
    PolicyJudges a handover against the purchase order's ship-by date
    Systemdelivery-promise
    PolicyRecords a delivery and judges the promise when it was the last package
    Systemorder-sourcing
    PolicyRecords a delivered package; the last one delivers the assignment

    Source: application/usecases/scans.go · domain/journey/journey.go

  4. Note the vendor's shipment confirmation

    The vendor says a shipment has left. Each package on it gets a 'shipment confirmed' scan, but its journey does not move: the handover waits for the carrier's pickup.

    Systemvendor-connectivity
    EventVendorShipmentConfirmed
    PolicyWhenever a vendor confirms a shipment, add one scan per tracking number
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    Systemcustomer-ordering
    PolicyAdds the scan to the order's tracking timeline

    Source: adapters/inbound/kafka/handlers.go · application/usecases/scans.go · domain/journey/journey.go

  5. Hand the package over at pickup

    A load leaves its origin. The first pickup departure of a labelled package hands it over to the carrier; any later departure is just a movement.

    PolicyWhenever a load departs, add one scan per package; the first pickup hands it over
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    EventPackageHandedOver
    Systemnode-performance
    PolicyJudges the handover against the purchase order's ship-by date
    Systemcustomer-ordering
    PolicyAdds the scan to the order's tracking timeline

    Source: adapters/inbound/kafka/handlers.go · application/usecases/scans.go · domain/journey/journey.go

  6. Follow the package through the middle mile

    A load arrives. At a delivery station the package becomes ready to go out; at any other hub it stays in transit.

    PolicyWhenever a load arrives, add one scan per package: station arrival or transit arrival
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    Systemcustomer-ordering
    PolicyAdds the scan to the order's tracking timeline

    Source: adapters/inbound/kafka/handlers.go · application/usecases/scans.go · domain/journey/journey.go

  7. Hand the package to an outside carrier

    In a service area served by an outside carrier, the carrier reports that it picked the package up. The journey moves from at the station to with the carrier, and the handoff is announced once. A repeated report is refused as a duplicate.

    ActorOutside carrier
    CommandReportCarrierEventPOST /carrier-events
    AggregateJourney
    EventPackageScanned
    EventPackageHandedToCarrier

    Source: application/usecases/carrier_events.go · domain/journey/journey.go

  8. Show the package out for delivery

    The delivery station sends the package out on a route. The journey moves to out for delivery.

    Systemlast-mile-delivery
    EventPackageOutForDelivery
    PolicyWhenever a package goes out for delivery, add an out-for-delivery scan
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    Systemcustomer-ordering
    PolicyAdds the scan to the order's tracking timeline

    Source: adapters/inbound/kafka/handlers_lastmile.go · application/usecases/scans.go · domain/journey/journey.go

  9. Close the journey on delivery

    A delivery attempt ends. A successful one delivers the package and closes the journey; a failed one sends it back to the station and the journey stays open.

    Systemlast-mile-delivery
    EventDeliveryAttempted
    PolicyWhenever an attempt is made, add a delivered or failed scan to the journey
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    EventPackageDelivered
    Systemdelivery-promise
    PolicyRecords the delivery and judges the promise when it was the last package
    Systemorder-sourcing
    PolicyRecords a delivered package; the last one delivers the assignment
    Systemcustomer-ordering
    PolicyMarks the package and its order group delivered

    Source: adapters/inbound/kafka/handlers_lastmile.go · application/usecases/scans.go · domain/journey/journey.go

  10. Deposit the package at a pickup point

    A delivery attempt succeeds at a pickup point. The package is not delivered to a doorstep: it is deposited at the point and waits there until the shopper collects it, with a hold deadline.

    Systemlast-mile-delivery
    EventDeliveryAttempted
    PolicyWhenever a delivery attempt succeeds at a pickup point, deposit the package there instead of delivering it
    CommandApplyScansstarted by the policy
    AggregateJourney
    EventPackageScanned
    EventPackageReadyForCollection

    Source: adapters/inbound/kafka/handlers_lastmile.go · application/usecases/scans.go · domain/journey/journey.go

  11. Collect the package at the pickup point

    The shopper collects a waiting package and, when a proof code was taken, it is kept with the scan. Collected is the end of the journey.

    ActorOperator
    CommandRecordScanPOST /journeys/{trackingNumber}/scans
    AggregateJourney
    EventPackageScanned
    EventPackageCollected

    Source: application/usecases/scans.go · domain/journey/journey.go

  12. Return a package to the sender

    After repeated failed attempts, last-mile-delivery starts a return. A package waiting at the station becomes returned, which ends its journey.

    Systemlast-mile-delivery
    EventPackageReturnInitiated
    PolicyWhenever a return is started, mark the package at the station as returned
    CommandReturnToSenderstarted by the policy
    AggregateJourney
    EventPackageReturned
    Systemdelivery-promise
    PolicyRecords the return and judges the promise broken
    Systemcustomer-ordering
    PolicyMarks the package and its order group returned
    Systemcustomer-payments
    PolicyRefunds the order, or waits until its payment exists

    Source: adapters/inbound/kafka/handlers_lastmile.go · application/usecases/scans.go · domain/journey/journey.go

  13. Store the day-of delivery window

    When a route starts, last-mile-delivery gives each stop a time window. Every package of the stop keeps it; the window shows only while the package is out for delivery.

    Systemlast-mile-delivery
    EventStopEtaWindowAssigned
    PolicyWhenever a stop gets a time window, store it on each package of the stop
    CommandApplyEtaWindowsstarted by the policy
    AggregateJourney
    EventPackageEtaWindowAssigned
    Systemcustomer-ordering
    PolicyKeeps the window for the order's tracking view unless a newer one exists

    Source: application/usecases/eta.go · domain/journey/journey_eta.go · 0013-day-of-eta-window-on-the-journey.md

  14. Relay a delivery-point warning

    last-mile-delivery flags a delivery point after two failed attempts. It knows the stop, not the order, so this context passes the warning on for each package of the stop, without any address.

    Systemlast-mile-delivery
    EventDeliveryPointFlagged
    PolicyWhenever a delivery point is flagged, store the flag on each open package of the stop
    CommandRelayDeliveryPointFlagstarted by the policy
    AggregateJourney
    EventPackageDeliveryPointFlagged
    Systemcustomer-ordering
    PolicyKeeps the flag on the package's tracking view so the shopper can be advised

    Source: application/usecases/point_flag.go · domain/journey/journey_point_flag.go · 0014-relay-the-delivery-point-flag-by-order-id.md

  15. Raise an exception on silence

    A periodic sweep looks for open packages with no new scan for longer than their service tier allows. Each silent package gets one exception until a new scan arrives.

    TimeSilence sweep
    PolicyEvery sweep, any package silent past its window raises one exception
    CommandRaiseExceptionstarted by the clock
    AggregateJourney
    EventPackageExceptionRaised
    Systemdelivery-promise
    PolicyTreats the exception as a risk to the promise and may re-promise
    Systemcustomer-ordering
    PolicyRecords the exception on the order's tracking view

    Source: application/usecases/sweep.go · domain/journey/types.go · 0002-aggregates-and-invariants.md

  16. Declare a silent package lost

    If a package in transit stays silent for 48 hours after its exception, the same sweep declares it lost and closes its journey.

    TimeSilence sweep
    PolicyEvery sweep, an in-transit package with an unanswered exception for 48 hours is lost
    CommandDeclareLoststarted by the clock
    AggregateJourney
    EventPackageLost
    Systemdelivery-promise
    PolicyRecords the loss and judges the promise broken
    Systemcustomer-ordering
    PolicyMarks the package and its order group lost
    Systemcustomer-payments
    PolicyRefunds the order, or waits until its payment exists

    Source: application/usecases/sweep.go · domain/journey/types.go · 0002-aggregates-and-invariants.md

  17. Keep the delivery mode of each postal area

    node-topology assigns a postal prefix to a delivery station. This context keeps only the delivery mode, any carrier options and the version; an older version is ignored.

    Systemnode-topology
    EventServiceAreaAssigned
    PolicyWhenever a postal prefix is assigned, keep its delivery mode and carrier options
    CommandApplyAreaAssignmentstarted by the policy
    Read model · kept up to datePostal area copy

    Source: adapters/inbound/kafka/handlers_nodetopology.go · application/usecases/areas.go

  18. Keep the pickup points and node states

    A newly registered node that is a pickup point is noted with the station that serves it. Activated, suspended and retired events keep the node's state in the same copy.

    Systemnode-topology
    EventNodeRegistered
    PolicyWhenever a node is registered, note it if it is a pickup point
    CommandNotePickupPointstarted by the policy
    Read model · kept up to datePickup point copy

    Source: adapters/inbound/kafka/handlers_nodetopology.go · application/usecases/points.go

  19. Keep the product dimensions copy

    Every product that offer-availability creates leaves its size, weight and handling flags here. Nothing reads them yet.

    Systemoffer-availability
    EventCatalogItemCreated
    PolicyWhenever a catalogue item is created, store its dimensions and handling flags
    CommandRecordCatalogItemstarted by the policy
    Read model · kept up to dateProduct dimensions

    Source: application/usecases/housekeeping.go · adapters/inbound/kafka/handlers.go · 0002-aggregates-and-invariants.md

  20. Delete old delivery addresses

    The saved, encrypted delivery address is deleted 30 days after its journey closes, whether delivered, returned, lost or voided.

    TimeHousekeeping sweep
    PolicyEvery housekeeping run, delete addresses of journeys closed over 30 days ago
    CommandPurgeShipTostarted by the clock

    Source: application/usecases/housekeeping.go · 0002-aggregates-and-invariants.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.

Opportunities

This board is a reconstruction from the code and documentation of shipping-and-tracking at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.