Skip to main content

Bounded Context Canvas

Released at v0.1.4, applied to the k3s cluster

Derived from model/model.yaml. The checkout service is built on develop (IQVO/checkout at 51e0379, checked 2026-12-02), released at v0.1.4 and applied to the k3s cluster: the api and the A2A agent are deployed, the MCP server is registered in warehouse-infra and switched off. Every Err... name, REST route and CloudEvents type of this context named on this page exists in the service; where the built service differs from the model's design, the page says so (As built) or the context's Service and operations section lists it.

Following the ddd-crew Bounded Context Canvas v5. Every message row comes from contexts[checkout] (inbound, consumes, publishes, rest, sync_calls) 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 commands, queries and 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; red = network 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[checkout].inbound, .publishes, .sync_calls, .purpose, .roles, .business_decisions.

The diagrams omit assumptions, verification metrics, open questions and the ubiquitous language (sections below) and the relationship pattern per message (see the tables). The model lists no consumed event for this context (consumes: []): everything it learns it learns from a synchronous answer. The AI clients collaborator is as built (cmd/mcp and cmd/a2a, service ADRs 0005 and 0007): the model has no agent row, and the agent surface is the GetSession read only.

Name​

Checkout (checkout, code CK, CloudEvents tier storefront).

Purpose​

To run the purchase saga. The context:

  • opens a session from a cart: reads the cart snapshot, pre-checks (once, at open) that every selected offer is still QUOTED and does not expire within 2 minutes, obtains the binding PriceQuote, numbers the lines 1..n and groups them by the quote's groupNo (gap S1);
  • on confirm authorizes the quote total with an allocation per group, then places the order through the Anti-Corruption Layer with the stored, PII-free request;
  • settles the three definitive failures (decline, requote, contract bug) and the one unknown (in-doubt placement) with a defined state each;
  • announces the outcome: CheckoutCompleted for the cart and for payments, four analytics events for the funnel.

Strategic Classification​

AxisVerdict
DomainSupporting subdomain. See the Core Domain Chart.
Business ModelConversion (the purchase transaction).
EvolutionCustom-built.

Domain Roles​

RoleApplies?Evidence in the model
Execution (saga orchestration)Yes, primaryThe CheckoutSession aggregate: OpenSession through ExpireSession, one record of where the purchase stands, plus the two policies.
Enforcer (no two holds on a card for one session)YesThe deterministic Idempotency-Key <sessionId>:auth:<authAttempt> on AuthorizePayment, the PLACING semantic lock (ErrPlacementInDoubt) and customer-payments' one-authorization-per-session invariant.
AnalysisNoThe cart's readiness is shopping-cart's fact; checkout only enforces it (ErrCartNotCheckoutReady).
SpecificationNoPrices, charges and tax are pricing's specification.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Shopper via storefront-bffOpenSessionCommandREST POST /checkout-sessionsUI
Shopper via storefront-bffConfirmSessionCommandREST POST /checkout-sessions/{sessionId}/confirmationsUI
Shopper via storefront-bffGetSessionQueryREST GET /checkout-sessions/{sessionId}; the same read over MCP (as built)UI
AI clients (agents; as built, not in the model)GetSessionQuery, the A2A delegation entryMCP tool get_checkout_session at /api/mcp/checkout (switched off in warehouse-infra); A2A skill checkout_session_status at /api/a2a/checkout through the Agent Router (deployed)Open Host Service, read-only, L1 inform

Route-to-command note: the three routes map onto OpenSession, ConfirmSession and GetSession. The other seven commands of the aggregate (RecordAuthorization, RecordDecline, RecordPlacementInDoubt, RecordPlaced, RecordRequoteRequired, RecordFailure, ExpireSession) have no inbound route: they are the outcomes the saga records on itself, from the answers of its outbound calls and from the two policies. As built, the MCP tool get_checkout_session and the A2A skill checkout_session_status are the same GetSession read, served by two read-only binaries (cmd/mcp, cmd/a2a) over the use case the REST route uses; no agent surface opens or confirms a session, because both move a shopper's money.

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
shopping-cartGetCartQueryREST GET /carts/{cartId}Customer/Supplier (we are the Customer)
delivery-promise (network)GetDeliveryOfferQueryREST GET /delivery-offers/{offerId} (pre-check that every selected offer is still QUOTED, with margin)Open Host Service; we are the Customer
pricingIssuePriceQuoteCommandREST POST /price-quotesCustomer/Supplier (we are the Customer)
customer-paymentsAuthorizePaymentCommandREST POST /payment-authorizations (Idempotency-Key <sessionId>:auth:<authAttempt>, allocations per group)Customer/Supplier (we are the Customer)
customer-paymentsVoidAuthorizationCommandREST POST /payment-authorizations/{authorizationId}/voids (Idempotency-Key <sessionId>:void; only after a definitive rejection)Customer/Supplier (we are the Customer)
customer-ordering (network)PlaceOrderCommandREST POST /checkout through the ACL (internal/adapters/outbound/customerordering); Idempotency-Key is the sessionId; shipToAddressId (NG1), never an inline addressOpen Host Service behind an Anti-Corruption Layer; we are the Customer
shopping-cart, customer-paymentsCheckoutCompletedEventKafka retailnetwork.checkout.events, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutCompletedCustomer/Supplier (we are the Supplier)
analytics onlyCheckoutOpenedEventKafka retailnetwork.checkout.analytics, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutOpenedanalytics stream
analytics onlyCheckoutDeclinedEventKafka retailnetwork.checkout.analytics, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutDeclinedanalytics stream
analytics onlyCheckoutRequoteRequiredEventKafka retailnetwork.checkout.analytics, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutRequoteRequiredanalytics stream
analytics onlyCheckoutFailedEventKafka retailnetwork.checkout.analytics, com.retailnetwork.storefront.checkout.checkoutsession.CheckoutFailedanalytics stream

What the neighbours do with them: the cart closes on CheckoutCompleted (CloseOnCheckoutCompleted); customer-payments binds the order to the session's authorization on it (BindOrderOnCheckoutCompleted) and applies any parked fulfilment facts. Relationship evidence: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Checkout Session, Place-Order Step (the network's "Checkout"), In-Doubt Placement, Requote, Allocation.

Business Decisions​

  1. Money flow (D5). Authorize before placing the order; capture per shipment group on FulfillmentShipped; release on FulfillmentCancelled; refund on PackageLost or PackageReturned.
  2. The network's "Checkout" is the place-order step, reached through an Anti-Corruption Layer in internal/adapters/outbound/customerordering, the only place that knows network wire names.
  3. A decline keeps the session open for another token while the price quote is valid; a definitive 409 voids the authorization and asks for a requote; a 422 is a contract bug: void, FAILED, alert.
  4. A 503 or timeout leaves the session PLACING, answers 202, and ResolveInDoubtPlacements replays the stored body with the same Idempotency-Key until a definitive answer; alert at 20 h, before the network's 24 h idempotency window.
  5. The cart must be ready, the quote unexpired. ErrCartNotCheckoutReady at open, ErrPriceQuoteExpired (422) at confirm, and ExpireOnQuoteExpiry ends an open or declined session with its quote.
  6. The authorized amount equals the quote total (ErrAuthorizationMismatch): a mismatch returns the session to DECLINED with the void owed and answers 409; a new confirm is refused with 409 void-pending until the void has succeeded.
  7. A closed session never changes (ErrSessionClosed): COMPLETED, EXPIRED, FAILED and REQUOTE_REQUIRED allow no transition out.
  8. No PII. The session holds shopperId and shipToAddressId; the stored placement request is PII-free.

Assumptions​

  • The BFF mints the Idempotency-Key for every write and reads GET /checkout-sessions/{sessionId} to poll a PLACING session after a 202 (REST contract description).
  • customer-ordering replays the first response to a repeated Idempotency-Key (the policy ResolveInDoubtPlacements says so), and the network's idempotency window is 24 h (decision text; see Open Questions).
  • The network exposes shipToAddressId on POST /checkout (the EXTEND NG1), and its wire names (Checkout, offer-not-quotable, requotedOffers) stay inside the ACL.
  • customer-payments returns a decline as a definitive answer and a successful void as a definitive answer; the session records both.
  • Every write route is idempotent on Idempotency-Key; every published event leaves through the transactional outbox.
  • One configured currency everywhere; the session records currency and totalMinor from the quote, and an amountMinor per group.

Verification Metrics​

MetricTarget (proposed)Source
Sessions confirmed to COMPLETED over sessions confirmedtracked; the conversion signalCheckoutCompleted and CheckoutOpened counts
Share of confirms ending DECLINEDtracked; alert on a spikeCheckoutDeclined
Share of sessions ending REQUOTE_REQUIREDlow; a rise means offers expire between cart and confirmCheckoutRequoteRequired
FAILED sessions (contract bug)0; each one alertsCheckoutFailed
Sessions in PLACING and their age0 older than 20 h; alert at 20 h, before the network's 24 h windowcheckout_sessions.state, updated_at
Sessions with an authorization and no orderId after a definitive answer0authorizationId vs orderId
Authorization/void calls per sessionone authorization key per attempt (<sessionId>:auth:<authAttempt>)customer-payments metrics
Outbox age of the oldest unpublished checkout eventbelow 5 soutbox_events.created_at

Open Questions​

  • Where does DECLINED go when the quote expires? The policy ExpireOnQuoteExpiry covers an OPEN or DECLINED session, but the transition list holds only OPEN → EXPIRED (hotspot H1 on EventStorming).
  • What key does the second authorize use? Resolved (hotspot H2): AuthorizePayment is keyed <sessionId>:auth:<authAttempt>; authAttempt starts at 0 and grows on each DECLINED → AUTHORIZING, so a retry with another token is a new attempt while a stuck call replays the same key.
  • What if the pre-check fails before authorizing? Resolved (hotspot H3): offer-not-quotable (422) at open, no session and no state change. The check is not repeated at confirm; an offer that expires between open and confirm comes back from customer-ordering as a PLACING-time 409, the only way to REQUOTE_REQUIRED.
  • What ends AUTHORIZING if the authorize outcome is unknown? No transition leaves AUTHORIZING for a timeout; customer-payments only voids unbound authorizations after 24 h (hotspot H4).
  • A failed void. REQUOTE_REQUIRED and FAILED follow a successful void (REST contract); the model does not say what a failed void does (hotspot H5).
  • The resolver and the 24 h void race. ResolveInDoubtPlacements may still be replaying near the 24 h mark at which customer-payments voids an authorization without CheckoutCompleted (hotspot H6).
  • Silent outcomes. ExpireSession and RecordPlacementInDoubt publish nothing, so analytics cannot see expiry or in-doubt volume (hotspot H7).
  • The network contract (hotspot H8): resolved. shipToAddressId, offer-not-quotable and requotedOffers are now in the network model (customer-ordering) and in customer-ordering's apis/openapi.yaml on develop (POST /checkout, 409 offer-not-quotable with requotedOffers).
  • The stored placement request has no name. Its shape, its retention ("for the idempotency window") and its purge are unnamed (hotspot H9).
  • How does the cart take the requoted offers? The REST contract says the BFF writes them into the cart as a new quote, yet the cart's commands only quote through delivery-promise (QuoteDelivery); none accepts an offer set from outside (hotspot H10). The model now has AcceptRequotedOffers, and as built shopping-cart serves POST /carts/{cartId}/delivery-requote-acceptances (acceptRequotedOffers), but storefront-bff exposes no route that calls it, so the requote path is not reachable from the web app yet.