Skip to main content

Customer Ordering

customer-ordering is the Generic bounded context that turns a shopper's cart into a customer order. It belongs to the retail network's commerce tier (CloudEvents segment commerce, the Storefront side of the portfolio): it obtains a delivery promise for every shipment group at checkout, records the order with the shopper and ship-to address (synthetic PII held only here), shows the order's status and tracking, and handles customer cancellation. Shoppers and their saved addresses live here too.

Cart-to-order is commodity commerce, so the context is kept thin: the promise that makes the network different is owned by delivery-promise, and the choice of the building that ships is owned by order-sourcing (Subdomain classification, ADR 0001). The context is an Open Host Service: REST plus a published CloudEvents language on retailnetwork.customer-ordering.events.

:::info What runs on develop Three binaries over one Postgres database: cmd/api (REST, the transactional outbox relay and three Kafka consumers in one process), and the read-only cmd/mcp (ADR 0005) and cmd/a2a (ADR 0008). All run on real Postgres; the API also on real Kafka and a real delivery-promise endpoint. There is no in-memory mode. web/ is the customer_ordering_mfe console remote (ADR 0006). A Helm chart, charts/customer-ordering, packages them (mcp, a2a and frontend are optional components, off by default). :::

What the context owns​

ConceptWhere it livesRule in one line
CustomerOrder (aggregate)internal/domain/customerorderLines, one promise per shipment group, the ship-to, and the customer-facing status derived from the group states. Every line is in exactly one group; the promise destination matches the ship-to; status only moves forward.
Shopper (aggregate)internal/domain/shopperA registered, synthetic shopper with a unique lower-cased e-mail and at most 20 saved addresses.
ShipTo (value object)internal/domain/shiptoThe delivery address. Synthetic PII, served by one restricted route and never carried by an event; events carry only the destination postal prefix.
Order tracking (read model)tables group_signals, tracking_packages, tracking_package_groups, assignment_linksEvent-fed: promise signals, verdicts, packages, scans, exceptions and outcomes of every group.
Inbox, idempotency, outboxtables processed_events, idempotency_keys, outbox_eventsAt-most-once consumption, replayed POSTs for 24 h, at-least-once publication.

What it does NOT own​

Not hereOwner
Computing delivery dates, holding capacity, judging a promise kept or brokendelivery-promise (called synchronously at checkout; events consumed afterwards)
Choosing the shipping node, locking the assignment, accepting or refusing a cancelorder-sourcing
Labels, scans, deliveries, the package journeyshipping-and-tracking (the only reader of the ship-to address, for the label)
Carts, catalogue, prices, availabilitythe other Storefront contexts
Payments, refunds, returns after the lockother contexts: customer-payments (storefront, built on its develop) and returns-processing (WMS, built on its develop) exist, but this context has no edge to either: no call, no consumed or published event type of theirs
Invoices, tax, notificationsno context found in the IQVO organisation, and none here
Authenticationnothing: REST, MCP and A2A are unauthenticated fleet-wide; the shopper's identity is only a shopperId in the request

This context never calls order-sourcing or shipping-and-tracking. Its one outbound call is to delivery-promise (Integration).

Main capabilities​

  1. Checkout (POST /checkout): quote check, make and confirm a promise per group at delivery-promise, then store the order and publish CustomerOrderPlaced in one transaction. A failed confirm places nothing and cancels the promises of the same checkout that were already confirmed. An expired offer answers 409 with fresh offers.
  2. Order history and status: GET /orders?shopperId= (newest first, keyset cursor, answered as {items, nextCursor}), GET /orders/{orderId}, GET /orders/{orderId}/tracking.
  3. Cancellation (POST /orders/{orderId}/cancellations): a request to order-sourcing for every unlocked group; order-sourcing accepts or refuses. An unkeepable promise cancels its group by policy.
  4. Ship-to: GET /orders/{orderId}/ship-to, the one restricted route that returns the address (Cache-Control: no-store).
  5. Shoppers and saved addresses: register, look up by id or e-mail, add up to 20 saved addresses; checkout may use shipToAddressId instead of an inline shipTo.
  6. Read-only agent surfaces: three MCP tools and two A2A skills over the same read use cases (MCP tools, API overview).
  7. Events: publishes CustomerOrderPlaced and CustomerOrderCancelled; consumes five delivery-promise, five order-sourcing and seven shipping-and-tracking events (Event catalogue).

Where to go next​

You want toRead
See the layers, packages, binaries and the rules that police themArchitecture, Runtime
Run it and make the first callsQuickstart
Know every settingConfiguration
Deploy and operate itRunbook, Observability, Before the first release
Fix something that brokeTroubleshooting
Know what tests and CI gates existTesting
See who talks to whomIntegration
See the application use cases and their invariantsUse cases
Read the design in ddd-crew artifactsDDD artifacts, Ubiquitous language
Read the contractsAPI overview, Event catalogue, MCP tools
Read the decisionsADR index

Published at https://iqvo.github.io/customer-ordering/.

Disclaimer

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic.