Skip to main content

Bounded Context Canvas

As built

Derived from network/model/model.yaml. This context's service is built; the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses.

Following the ddd-crew Bounded Context Canvas v5. Every message row comes from contexts[customer-ordering] (inbound, consumes, publishes, sync_calls, rest) or from a neighbour's entry that names this context.

Canvas at a glance​

Two pictures of the sections below, laid out like the ddd-crew canvas: first the inbound collaborators feeding this context (purpose, domain roles and the business decisions it enforces), then the outbound collaborators it calls or notifies. Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt); each arrow names its channel and the messages it carries. Box shapes mark the collaborator kind: rounded = people, UI or any client; blue = sibling bounded context. Channel names on the arrows are abbreviated; the Inbound and Outbound Communication tables carry the exact route, topic and CloudEvents type for every message.

Inbound​

Outbound​

Derived from: model.yaml → contexts[customer-ordering].inbound, .sync_calls, .publishes, .purpose, .roles, .business_decisions.

The diagrams omit assumptions, verification metrics, open questions and the ubiquitous language (sections below), the relationship pattern per message (see the tables), and the synchronous replies. RegisterShopper (POST /shoppers) is in the model's rest list but has no inbound row; the arrow assigns it to the storefront, which is an assumption (see Open Questions).

Name​

Customer Ordering (customer-ordering, code CO, CloudEvents tier commerce).

Purpose​

To turn a shopper's cart into a customer order. The context:

  • obtains a promise from delivery-promise for every shipment group at checkout (MakePromise), re-quoting when the offer the shopper saw has expired (QuoteDeliveryOffers);
  • records the order with the shopper and the ship-to address (synthetic PII, held only here);
  • publishes CustomerOrderPlaced with the promise snapshot of every group, so order-sourcing does not have to correlate two streams;
  • shows status and tracking, built from fulfilment, promise and package events;
  • handles customer cancellation as a request for the groups no node has locked yet.

Strategic Classification​

AxisVerdict
DomainGeneric subdomain. See the Core Domain Chart.
Business ModelEngagement (the storefront transaction).
EvolutionCommodity.

Domain Roles​

RoleApplies?Evidence in the model
Execution (checkout)Yes, primaryPlaceOrder, the CheckoutPromising policy, the sync calls MakePromise and QuoteDeliveryOffers.
Gateway (storefront)YesThe storefront routes POST /checkout, GET /orders/{orderId}, GET /orders/{orderId}/tracking, POST /orders/{orderId}/cancellations are the shopper's way into the network's order flow (Open Host).
AnalysisNoOrderTrackingView is a projection for display, not a decision.
Specification / EnforcerNoPromise rules and capacity belong to delivery-promise.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Shopper / storefrontPlaceOrderCommandREST POST /checkoutOpen Host
Shopper / storefrontCancelOrderCommandREST POST /orders/{orderId}/cancellationsOpen Host
Shopper / storefront (assumed; no inbound row)RegisterShopperCommandREST POST /shoppersOpen Host
Shopper / storefrontGetOrderQueryREST GET /orders/{orderId}Open Host
Shopper / storefrontGetTrackingQueryREST GET /orders/{orderId}/trackingOpen Host
shipping-and-trackingGetShipToQueryREST GET /orders/{orderId}/ship-to (in-org, restricted)Customer/Supplier (we are the Supplier)
Network operatorPublishNotificationPolicyCommandREST PUT /notification-policy (the whole document; every call publishes a new version)UI
Network operatorGetNotificationPolicyQueryREST GET /notification-policyUI
order-sourcingFulfillmentLockedEventKafka retailnetwork.order-sourcing.events, com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLockedConformist
order-sourcingFulfillmentShippedEventKafka retailnetwork.order-sourcing.events, com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentShippedConformist
order-sourcingFulfillmentUnsourceableEventKafka retailnetwork.order-sourcing.events, com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentUnsourceableConformist
delivery-promisePromiseAtRiskEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promise.PromiseAtRiskCustomer/Supplier
delivery-promisePromiseRevisedEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promise.PromiseRevisedCustomer/Supplier
delivery-promisePromiseKeptEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promise.PromiseKeptCustomer/Supplier
delivery-promisePromiseBrokenEventKafka retailnetwork.delivery-promise.events, com.retailnetwork.commerce.delivery-promise.promise.PromiseBrokenCustomer/Supplier
shipping-and-trackingLabelIssuedEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedConformist
shipping-and-trackingPackageScannedEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageScannedConformist
shipping-and-trackingPackageDeliveredEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageDeliveredConformist
shipping-and-trackingPackageExceptionRaisedEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.journey.PackageExceptionRaisedConformist

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
delivery-promiseQuoteDeliveryOffersQueryREST POST /delivery-quotes (in-org)Customer/Supplier (we are the Customer)
delivery-promiseMakePromiseCommandREST POST /promises (in-org)Customer/Supplier (we are the Customer)
order-sourcing, delivery-promiseCustomerOrderPlacedEventKafka retailnetwork.customer-ordering.events, com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlacedCustomer/Supplier (we are the Supplier)
order-sourcing, delivery-promiseCustomerOrderCancelledEventKafka retailnetwork.customer-ordering.events, com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelledCustomer/Supplier (we are the Supplier)

What the consumers do with them (from their own model entries): delivery-promise confirms the provisional promise of each group (ConfirmPromise) on CustomerOrderPlaced and cancels it (CancelPromise) on CustomerOrderCancelled; order-sourcing queues one assignment per group (QueueAssignment) and cancels it (CancelAssignment). Full payloads: Domain Events. Relationship evidence: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Shopper, Customer Order, Ship-To (PII, held only here), Checkout, Group Promise (a snapshot of the Promise), Shipment Group, Delivery Offer, Path Lock (ends customer cancellation).

Business Decisions​

  1. No order without a promise per group. Every line is in exactly one group and every group has a promise (ErrLineWithoutPromise). The promise's destination postal prefix matches the ship-to (ErrPromiseDestinationMismatch).
  2. Promise from the offer the shopper saw. If that offer has expired, re-quote and show the new window before placing (CheckoutPromising). The order is never placed on a window the shopper did not see.
  3. The ship-to never leaves this context except to shipping-and-tracking, for a label, through GET /orders/{orderId}/ship-to. Published events carry destinationPostalPrefix only.
  4. Cancel only while some group is unlocked (ErrCancelAfterLock). After the lock, cancellation is a return. The check is advisory: a cancel is a request (every unlocked group becomes CANCELLATION_REQUESTED) and order-sourcing decides (FulfillmentCancelled, or FulfillmentCancelRefused after the lock).
  5. Status moves forward only (ErrStatusRegression). The order status is derived from the group states, and a late or duplicated upstream event never moves the order back: the consumer records the event and skips it.
  6. An unfulfillable group is cancelled, not kept open. When delivery-promise publishes PromiseUnkeepable for a group no node has locked, cancel that group at once, and the order if nothing remains (CancelOnUnfulfillable). FulfillmentUnsourceable alone cancels nothing.

Assumptions​

  • delivery-promise answers QuoteDeliveryOffers and MakePromise within the checkout's request budget. Checkout has no fallback promise.
  • delivery-promise consumes CustomerOrderPlaced before the provisional hold expires (holdExpiresAt); otherwise ConfirmPromise fails with ErrPromiseHoldExpired. The outbox relay lag must stay well under the hold time.
  • order-sourcing publishes FulfillmentLocked for every group it locks, so this context can enforce ErrCancelAfterLock from local data.
  • Every consumed event carries orderId, or an id this context has already linked to an order (assignmentId from FulfillmentLocked, promiseId from checkout, trackingNumbers from FulfillmentShipped). LabelIssued and PackageScanned carry no orderId.
  • "Restricted" on the ship-to route is enforced by network placement (the route is not exposed through the storefront edge), because the network has no authentication (conventions.no_auth).

Verification Metrics​

MetricTarget (proposed)Source
Checkout success rate (201 / all POST /checkout)tracked; alert on a dropREST access log
Share of checkouts answered 409 offer-not-quotable (offer expired, re-quoted)below 2%REST access log
p95 latency of POST /checkout, including every MakePromisebelow 800 mstraces
Placed orders whose promise was never confirmed (CustomerOrderPlaced without a matching PromiseConfirmed before holdExpiresAt)0analytics join on promiseId
Outbox age of the oldest unpublished CustomerOrderPlacedbelow 5 soutbox_events.created_at
ErrCancelAfterLock share of cancel requeststrackedREST access log
GET /orders/{orderId}/ship-to calls per LabelIssuedabout 1access log vs consumed events
Ship-to fields in any published event or non-restricted response0contract test on the schemas
Consumer lag on the three consumed topicsbelow 30 sKafka consumer metrics

Open Questions​

  • Which event drives which command? These pages use (ADR 0002 and the consumers in the service): FulfillmentLocked → MarkInFulfillment, FulfillmentShipped → MarkGroupShipped, PackageDelivered → MarkGroupDelivered, PackageLost / PackageReturned → MarkGroupLost / MarkGroupReturned, FulfillmentCancelled / FulfillmentCancelRefused → ConfirmGroupCancelled / RefuseGroupCancellation, PromiseRevised → UpdateGroupPromise, PromiseUnkeepable → CancelOnUnfulfillable. FulfillmentUnsourceable only records its reason on OrderTrackingView.
  • Cancel wording (resolved). business_decisions says a customer may cancel "until every shipment group is locked"; the invariant, ADR 0002 A3 and the service act on the groups that are still unlocked, and an order with none left is refused with ErrCancelAfterLock. IN_FULFILLMENT → CANCELLED is unreachable (ADR 0002).
  • Group-level state (resolved). GroupPromise also carries the group status, tier, witnessNodeId, shipBy and the lock, shipment, delivery and cancellation facts (ADR 0002 A2); the model's value-object list names only the promise fields.
  • Cancel racing the lock. A cancel accepted before FulfillmentLocked arrives can meet a lock order-sourcing already made; its CancelAssignment then fails, and the model has no compensation.
  • Hold expiry after placement. If delivery-promise confirms too late, the promise is RELEASED and PromiseReleased goes to analytics only, so this context never learns that a placed order lost its promise.
  • Who calls POST /shoppers? The route and RegisterShopper exist, but no inbound row names the caller.
  • Restricted without auth. How the ship-to route is restricted, given no_auth.