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.

GitHub ↗ · Documentation ↗ · Architecture check · Briefings

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.

  1. Pivotal eventReturnAuthorized
  2. Pivotal eventReturnLabelIssued
  3. Pivotal eventReturnCompleted
  4. Pivotal eventReturnCancelled

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

    ActorShopper
    Read modelOrder groups and their status
    Read modelReturns centres per region
    Read modelWhich node fulfilled each group
    CommandAuthorizeReturnPOST /return-authorizations
    AggregateReturnAuthorization
    EventReturnAuthorized
    Systemvendor-connectivity
    PolicyKeeps a return advice for the vendor that runs the destination node

    Source: application/usecases/authorize.go · domain/returnauthorization/decide.go · domain/returnauthorization/authorization.go

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

    ActorShopper
    CommandIssueLabelPOST /return-authorizations/{authorizationId}/labels
    AggregateReturnAuthorization
    EventReturnLabelIssued
    Systemvendor-connectivity
    PolicyAdds the tracking number to the vendor's return advice

    Source: application/usecases/labels.go · adapters/outbound/labels/client.go · domain/returnauthorization/commands.go

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

    ActorShopper
    CommandCancelReturnPOST /return-authorizations/{authorizationId}/cancellations
    AggregateReturnAuthorization
    EventReturnCancelled
    Systemvendor-connectivity
    PolicyMarks the vendor's return advice cancelled, unless an outcome is already recorded

    Source: application/usecases/queries.go · domain/returnauthorization/commands.go

  4. 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
    EventVendorReturnOutcomeSubmitted
    PolicyWhenever a graded outcome fits an open return, complete it with the authorized lines only
    CommandOnOutcomeSubmittedstarted by the policy
    AggregateReturnAuthorization
    EventReturnCompleted
    Read model · kept up to dateGraded outcomes
    Systemoffer-availability
    PolicyAdds the restockable units back to the matching listings

    Source: application/usecases/outcome.go · adapters/inbound/kafka/consumers.go · domain/returnauthorization/commands.go

  5. 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
    EventCustomerOrderPlaced
    PolicyWhenever an order is placed, keep each group as promised, never undoing a status already seen
    CommandOnOrderPlacedstarted by the policy
    Read model · kept up to dateOrder groups and their status

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go

  6. 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
    EventShopperNoticeDecided
    PolicyWhenever a final notice is decided, set the group's status from it
    CommandOnNoticeDecidedstarted by the policy
    Read model · kept up to dateOrder groups and their status

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers.go

  7. 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 status
    CommandOnNodeRegisteredstarted by the policy
    Read model · kept up to dateReturns centres per region

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go

  8. 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 newer
    CommandOnNodeStatusstarted by the policy
    Read model · kept up to dateReturns centres per region

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go

  9. 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
    EventServiceAreaAssigned
    PolicyWhenever a prefix is assigned, keep it if its version is newer
    CommandOnPrefixFactstarted by the policy
    Read model · kept up to datePostal prefix regions

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers_topology.go

  10. 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 owners
    CommandOnOriginFactstarted by the policy
    Read model · kept up to dateWhich node fulfilled each group

    Source: application/usecases/consumers.go · adapters/inbound/kafka/consumers_sourcing.go

  11. 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 counts
    CommandApplystarted by the policy
    Read model · kept up to dateReturns per day and reason mix

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

Opportunities

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.