Retail network · Core domain · EventStorming board
order-sourcing
Chooses which fulfillment node ships each group of an order, releases it at the right time and tracks it from release to delivery.
- events published
- 15
- commands
- 15
- policies
- 35
- read models
- 4
- hot spots
- 5
The story in 5 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventFulfillment
Queued - Pivotal eventFulfillment
Released To Node - Pivotal eventFulfillment
Locked - Pivotal eventFulfillment
Shipped - Pivotal eventFulfillment
Delivered
Listens to (9): contexts whose events this one reacts to
Tells (7): 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
-
Queue a shipment group
When an order is placed, each shipment group gets an assignment and the best node is picked; a same-day group is released at once. If no node can serve the group in time, it is marked unsourceable so the promise can be revised.
Systemcustomer-ordering EventCustomerOrder Placed PolicyWhenever an order is placed, queue one assignment per shipment group and pick its best nodeRead modelNetwork graphRead modelAvailability copyRead modelNode scorecardsCommandQueueAssignment started by the policyAggregateAssignmentEventFulfillmentQueued analytics stream onlyEventFulfillmentUnsourceable Systemdelivery-promise PolicyFlags the promise as at risk when no node can serve the groupSystemcustomer-ordering PolicyKeeps the reason on the order tracking viewSource: application/usecases/queue.go · domain/assignment/assignment.go · adapters/inbound/kafka/handlers.go
-
Release a group to its best node
A sweep releases every group whose release time has come. The node is re-checked against fresh copies first, and the release records why this node was chosen.
TimeQueue sweepPolicyWhenever a queued group's release time is due, re-check the best node and release the group to itRead modelNetwork graphRead modelAvailability copyRead modelNode scorecardsCommandReleaseTo started by the clockNode AggregateAssignmentEventFulfillmentReleased To Node EventFulfillmentSourcing analytics stream onlyDecided EventFulfillmentReassigned EventFulfillmentUnsourceable Systemvendor-connectivity PolicyIssues a purchase order to the nodeSystemlinehaul-transportation PolicyNotes the planned pickup; nothing is booked yetSystemseller-inbound PolicyAdds the released lines to its demand viewSource: application/usecases/release.go · application/usecases/sweep.go · domain/assignment/commands.go
-
Release one shopper's packages together
If the shopper chose the consolidated delivery day and a merge limit is published, queued groups with the same key ride on the first group's release. The merge never moves the node.
TimeQueue sweepPolicyWhenever a due consolidated group has queued mates with the same key, release them as oneCommandReleaseTo started by the clockNode AggregateAssignmentEventAssignmentsConsolidated analytics stream onlySystemvendor-connectivity PolicyReceives one purchase order carrying the lines of every merged groupSource: application/usecases/release.go · domain/assignment/consolidation.go · 0015-carrier-and-follower-consolidation-at-release.md
-
Move a queued group to a better node
A network planner, or the sweep, asks for a fresh search for a group that is still queued. If another node is now better the group moves; if none is left it becomes unsourceable.
ActorNetwork-ops plannerRead modelNetwork graphRead modelAvailability copyCommandReoptimiseAssignment POST /assignments/{assignmentId}/reoptimisationsAggregateAssignmentEventFulfillmentReassigned EventFulfillmentUnsourceable Systemlinehaul-transportation PolicyUpdates its view of the group's nodeSource: application/usecases/commands.go · domain/assignment/commands.go
-
Publish a sourcing policy
A planner sets the cross-region surcharge, how far above the cheapest route the choice may drift to stay in region, and how many groups may merge. Every publish makes the next version; nothing changes until one exists.
ActorNetwork-ops plannerCommandPublishSourcing PUT /sourcing-policyPolicy AggregatePolicyEventSourcingPolicy analytics stream onlyPublished Source: application/usecases/policy.go · domain/policy/policy.go · 0014-a-versioned-sourcing-policy.md
-
Lock the group when the node accepts
When the node accepts the purchase order, the group is locked on that node and its pickup departure. After that it can no longer be moved or cancelled.
Systemvendor-connectivity EventPurchaseOrder Accepted PolicyWhenever the node accepts the purchase order of the pending release, lock the group on that nodeCommandLockAssignment started by the policyAggregateAssignmentEventFulfillmentLocked Systemdelivery-promise PolicyMoves the capacity hold to the locked node and pickup, then re-judges the promiseSystemcustomer-ordering PolicyMarks the group as in fulfilmentSystemlinehaul-transportation PolicyBooks one package on the pickup departure, or moves it to the next oneSource: application/usecases/commands.go · domain/assignment/commands_lifecycle.go · adapters/inbound/kafka/handlers_partner.go
-
Try another node after a refusal
If the node rejects the purchase order or lets it expire, that node is excluded and the group is searched again. A merged release breaks up and each group is searched on its own.
Systemvendor-connectivity EventPurchaseOrder Rejected PolicyWhenever a node rejects or lets a purchase order expire, skip that node and search againCommandHandleNode started by the policyRefusal AggregateAssignmentEventFulfillmentReassigned EventFulfillmentUnsourceable EventAssignmentsDeconsolidated analytics stream onlySystemlinehaul-transportation PolicyUpdates its view of the group's nodeSystemdelivery-promise PolicyFlags the promise as at risk when no node is leftSource: application/usecases/commands.go · domain/assignment/commands.go · adapters/inbound/kafka/handlers_partner.go
-
Record the shipment
When the node confirms that the purchase order shipped, the group is marked shipped with its tracking numbers, and a merged release ships all its groups.
Systemvendor-connectivity EventVendorShipment Confirmed PolicyWhenever the node confirms a shipment, mark the group shipped with its tracking numbersCommandMarkShipped started by the policyAggregateAssignmentEventFulfillmentShipped Systemcustomer-ordering PolicyMarks the group shipped and stores the tracking numbersSystemdelivery-promise PolicyRecords the packages of the group to judge the promiseSystemcustomer-payments PolicyCaptures the payment of the groupSource: application/usecases/commands.go · domain/assignment/commands_lifecycle.go
-
Record the delivery
Each delivered package is remembered. The group counts as delivered only when its last package arrives.
Systemshipping-and- tracking EventPackageDelivered PolicyWhenever a package is delivered, record it; the last package delivers the groupCommandMarkDelivered started by the policyAggregateAssignmentEventFulfillmentDelivered analytics stream onlySource: application/usecases/commands.go · domain/assignment/commands_lifecycle.go · adapters/inbound/kafka/handlers_logistics.go
-
Cancel a group before it locks
A cancelled order cancels its groups while they are queued, released or unsourceable. A locked group, or a member of a merged release, refuses the cancellation and the order keeps it.
Systemcustomer-ordering EventCustomerOrder Cancelled PolicyWhenever an order is cancelled, cancel its groups that are not locked and refuse the othersCommandCancelAssignment started by the policyAggregateAssignmentEventFulfillmentCancelled EventFulfillmentCancel Refused Systemvendor-connectivity PolicyCancels the purchase order of a released groupSystemlinehaul-transportation PolicyUpdates its view of the groupSystemseller-inbound PolicyRemoves the group's lines from its demand viewSystemcustomer-payments PolicyLets go of the payment hold for the groupSystemcustomer-ordering PolicyConfirms the cancellation, or keeps the group when refusedSource: application/usecases/cancel_revise.go · domain/assignment/commands_lifecycle.go
-
Re-check a group after a promise change
When delivery-promise revises a promise, the group gets the new deadline and its exclusions are reset. A merged release that no longer fits the window is withdrawn and its groups are searched again.
Systemdelivery-promise EventPromiseRevised PolicyWhenever a promise is revised, apply the new deadline and search again if the group is still queuedCommandApplyRevised started by the policyPromise AggregateAssignmentEventFulfillmentConstraint Revised EventFulfillmentRelease Withdrawn EventAssignmentsDeconsolidated analytics stream onlySystemvendor-connectivity PolicyCancels the purchase order of the withdrawn releaseSource: application/usecases/cancel_revise.go · domain/assignment/commands_revision.go · 0015-carrier-and-follower-consolidation-at-release.md
-
Follow a moved pickup
If linehaul moves a booking to another departure, the locked group points at the new pickup. The node never changes. A failed booking changes nothing here.
Systemlinehaul-transportation EventBookingMoved PolicyWhenever a booking moves to another departure, point the locked group at the new pickupCommandRecordPickup started by the policyMoved AggregateAssignmentSource: application/usecases/commands.go · domain/assignment/commands_revision.go
-
Keep the network map
Nodes, their profiles and status, lanes, regions and service areas come from node-topology. Order-sourcing keeps a copy so a search never needs a live call.
Systemnode-topology EventLaneOpened PolicyWhenever a node, lane, region or service area changes, update the local network copiesCommandProjector.LaneOpened started by the policyRead model · kept up to dateNetwork graphRead model · kept up to dateNode profilesSource: application/usecases/projector.go · adapters/inbound/kafka/handlers_logistics.go
-
Keep the departures copy
Linehaul announces departures, capacity changes and cancellations. A route can only start on a departure that this copy still shows as usable.
Systemlinehaul-transportation EventDepartureScheduled PolicyWhenever a departure is scheduled, resized or cancelled, update the local departures copyCommandProjector.DepartureScheduled started by the policyRead model · kept up to dateNetwork graphSource: application/usecases/projector.go · adapters/inbound/kafka/handlers_logistics.go
-
Keep the delivery waves copy
Last-mile delivery announces its waves, capacity changes, cancellations and per-stop costs. A route ends on a wave of the destination's station.
Systemlast-mile- delivery EventDeliveryWave Scheduled PolicyWhenever a wave is scheduled, resized, cancelled or priced, update the local waves copyCommandProjector.WaveScheduled started by the policyRead model · kept up to dateNetwork graphSource: application/usecases/projector.go · adapters/inbound/kafka/handlers_logistics.go
-
Keep the availability copy
Offer-availability reports what each node can ship. A node only qualifies when every line of the group is listed, not suppressed and in stock.
Systemoffer-availability EventListingAvailability Changed PolicyWhenever a listing's stock changes, update the local availability copyCommandProjector.ListingAvailability started by the policyChanged Read model · kept up to dateAvailability copySource: application/usecases/projector.go · adapters/inbound/kafka/handlers.go
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 spotAfter a promise revision withdraws a merged release, the vendor may still accept the old purchase order: a duplicate pick and ship of the other groups' goods.
Source: adr/0015-carrier-and-follower-consolidation-at-release.md
- Hot spotIf the pickup departure of a locked group is cancelled, no transition handles it: the departures copy changes and nothing else.
Source: docs/ddd/eventstorming.md
- Hot spotAn acceptance that arrives after the group was cancelled is only logged, so the vendor may still ship.
Source: docs/ddd/eventstorming.md
- Hot spotA group released at the latest pickup has no slack: after a refusal there may be no later wave, so it becomes unsourceable.
Source: adr/0016-consolidated-delivery-day-search-and-latest-pickup-hold.md
- Hot spotFulfillmentConstraintRevised has no consumer declared in any spec yet.
Source: apis/asyncapi.yaml
Opportunities
- OpportunityA split surcharge and a single-node preference are not built. Revisit when sourcing plans across the groups of one order.
This board is a reconstruction from the code and documentation of order-sourcing at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.