Retail network · Supporting domain · EventStorming board
customer-returns
Lets a shopper return a shipped order group: decides where it goes (or that they keep it), gets the reverse label and closes the return when the centre grades it.
- events published
- 4
- commands
- 11
- policies
- 12
- read models
- 6
- hot spots
- 5
The story in 4 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventReturn
Authorized - Pivotal eventReturn
Label Issued - Pivotal eventReturn
Completed - Pivotal eventReturn
Cancelled
Listens to (4): contexts whose events this one reacts to
Tells (2): contexts that react to its events
The board, row by row
11 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
-
Authorize a return for a shipped group
A shopper asks to return lines of a shipped or delivered order group. The context decides the outcome itself: keep it (cheap lines), send it to the region's returns centre, or back to the node that shipped it.
ActorShopperRead modelOrder groups and their statusRead modelReturns centres per regionRead modelWhich node fulfilled each groupCommandAuthorizeReturn POST /return-authorizationsAggregateReturnAuthorization EventReturnAuthorized Systemvendor-connectivity PolicyKeeps a return advice for the vendor that runs the destination nodeSource: application/usecases/authorize.go · domain/returnauthorization/decide.go · domain/returnauthorization/authorization.go
-
Issue the shopper's reverse label
For a return that travels, the shopper asks for a label. The context asks the shipping context for it with a direct request, then links the tracking number. A return past its 30 days is cancelled instead.
ActorShopperCommandIssueLabel POST /return-authorizations/{authorizationId}/labelsAggregateReturnAuthorization EventReturnLabel Issued Systemvendor-connectivity PolicyAdds the tracking number to the vendor's return adviceSource: application/usecases/labels.go · adapters/outbound/labels/client.go · domain/returnauthorization/commands.go
-
Cancel a return before it travels
The shopper withdraws a return while it is still only authorized. An expired return is cancelled the same way when it is next touched by a label request, a cancel or an outcome.
ActorShopperCommandCancelReturn POST /return-authorizations/{authorizationId}/cancellationsAggregateReturnAuthorization EventReturnCancelled Systemvendor-connectivity PolicyMarks the vendor's return advice cancelled, unless an outcome is already recordedSource: application/usecases/queries.go · domain/returnauthorization/commands.go
-
Close the return from the centre's graded outcome
The returns centre grades the parcel through its vendor. The first outcome that fits an open return completes it with restockable and unsellable units; lines nobody authorized are only recorded.
Systemvendor-connectivity EventVendorReturn Outcome Submitted PolicyWhenever a graded outcome fits an open return, complete it with the authorized lines onlyCommandOnOutcome started by the policySubmitted AggregateReturnAuthorization EventReturnCompleted Read model · kept up to dateGraded outcomesSystemoffer-availability PolicyAdds the restockable units back to the matching listingsSource: application/usecases/outcome.go · adapters/inbound/kafka/consumers.go · domain/returnauthorization/commands.go
-
Keep the placed order groups
customer-ordering announces each placed order. Returns keeps every group with its lines and the order's postal prefix, so a return request only has to name the line numbers.
Systemcustomer-ordering EventCustomerOrder Placed PolicyWhenever an order is placed, keep each group as promised, never undoing a status already seenCommandOnOrder started by the policyPlaced Read model · kept up to dateOrder groups and their statusSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go
-
Learn that a group shipped or arrived
customer-ordering decides the shopper's notices. Shipped and delivered notices make a group returnable; lost and returned ones are recorded too.
Systemcustomer-ordering EventShopperNotice Decided PolicyWhenever a final notice is decided, set the group's status from itCommandOnNotice started by the policyDecided Read model · kept up to dateOrder groups and their statusSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go
-
Keep the network's nodes
node-topology registers each node with its type and region. Returns keeps them, so it knows which returns centre serves a region.
Systemnode-topology EventNodeRegistered PolicyWhenever a node is registered, keep its type and region without changing its statusCommandOnNode started by the policyRegistered Read model · kept up to dateReturns centres per regionSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go
-
Track which returns centres are open
node-topology activates, suspends and retires nodes. Only an active returns centre is ever chosen as a destination; an older status change never overrides a newer one.
Systemnode-topology EventNodeActivated PolicyWhenever a node is activated, suspended or retired, move its status if the change is newerCommandOnNode started by the policyStatus Read model · kept up to dateReturns centres per regionSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go
-
Map postal prefixes to regions
node-topology assigns postal prefixes to regions. Returns keeps the newest assignment, so a group's postal prefix leads to its region's returns centre.
Systemnode-topology EventServiceArea Assigned PolicyWhenever a prefix is assigned, keep it if its version is newerCommandOnPrefix started by the policyFact Read model · kept up to datePostal prefix regionsSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go
-
Remember who fulfilled each group
order-sourcing locks a group to a node and releases it with each item's stock owner (also FulfillmentReleasedToNode). Returns keeps both, for the ship-back destination and the owner on each line.
Systemorder-sourcing EventFulfillmentLocked PolicyWhenever a group is locked or released to a node, record the node and the item ownersCommandOnOrigin started by the policyFact Read model · kept up to dateWhich node fulfilled each groupSource: application/usecases/consumers.go · adapters/inbound/kafka/consumers_sourcing.go
-
Count returns for the performance report
Returns reads its own authorized and completed facts into a separate reporting store: returns per day and the reason mix, read by the returns performance report.
Event · earlierReturnAuthorized PolicyWhenever a return is authorized or completed, add it to the daily countsCommandApplystarted by the policyRead model · kept up to dateReturns per day and reason mixSource: adapters/inbound/kafka/analytics_consumer.go · domain/returnsperformance/facts.go · 0012-analytics-read-side-and-return-rate-facts.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 lagging copy of orders or nodes refuses a return (not shipped, no destination); the shopper has to retry with the same key.
Source: adr/0003-consumed-contracts-and-local-read-models.md
- Hot spotThe reverse label is off until the shipping service address is configured; until then every label request answers label unavailable.
- Hot spotDoorstep pickup is dormant: nothing raises the pickup-failed state until the last-mile pickup wave arrives.
- Hot spotLines the centre received but nobody authorized are only recorded; nothing here restocks or re-decides them.
- Hot spotThe return rate is not reported: this context holds no delivered-order count to divide by, and no refund facts.
Source: adr/0012-analytics-read-side-and-return-rate-facts.md
Opportunities
- OpportunityA later event carrying the delivered-group fact could let the return rate be served from here.
Source: adr/0012-analytics-read-side-and-return-rate-facts.md
This board is a reconstruction from the code and documentation of customer-returns at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.