Skip to main content

Order Sourcing

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. It also has an analytics read side (order-sourcing ADR 0013): cmd/os-projector projects this context's own topics into a separate analytical database, and cmd/os-reports serves the read-only /reports/... routes on :8092.

Core

Order Sourcing (order-sourcing, code OS, CloudEvents tier commerce) decides, as late as the promise allows, which node and path will actually fulfil each shipment group of a customer order. It owns one aggregate, FulfillmentAssignment. Assignments wait in a virtual queue where they are re-optimised against current capacity and cost until their release point. At release the group is sent to one vendor node, which for a vendor node means a purchase order issued through vendor-connectivity. A rejection or an expiry moves the group to another node. The node's acceptance locks the assignment for good. When no node can still meet the promise's deliverByLatest, the group becomes UNSOURCEABLE and goes back to delivery-promise for a re-promise. Sourcing never breaks a promise silently.

Two operator levers sit on top. A versioned SourcingPolicy (a second, small aggregate) adds a cross-region surcharge to the effective cost of a candidate and lets an in-region candidate within a deviation percent of the cheapest win. And groups of one shopper and one address that chose the opt-in CONSOLIDATED delivery day can be merged at release into one carrier release with followers, when the policy allows it. Both are inert until a policy is published: with no policy the ordering, the events and the views are unchanged.

What this pack describes
  • Inbound: nine Kafka topics of sibling contexts (orders, promises, purchase-order outcomes, delivery, topology, availability, departures, waves, scorecards) and a small REST surface for the network-ops planner (GET /assignments, GET /assignments/{assignmentId}, POST /assignments/{assignmentId}/reoptimisations) and for the sourcing policy (GET /sourcing-policy, PUT /sourcing-policy).
  • Outbound: fifteen CloudEvents types: nine integration events (com.retailnetwork.commerce.order-sourcing.assignment.*, among them the consolidation event FulfillmentReleaseWithdrawn) on retailnetwork.order-sourcing.events, and six analytics-only events (AssignmentsConsolidated, AssignmentsDeconsolidated, the policy event SourcingPolicyPublished and three of the assignment events) on retailnetwork.order-sourcing.analytics. No synchronous call to any other context (sync_calls: []).
  • Not here: the promise itself (Delivery Promise), the purchase-order protocol and its clock (Vendor Connectivity), and picking and packing, which the vendor does in its own building.

This context's pages​

PageWhat it coversddd-crew tool it follows
Business ContextThe sourcing problem in plain language, actors, decisions, the real fulfillment networks, scope— (narrative)
Ubiquitous LanguageEvery term of this context and the neighbour terms it usesglossary, from the DDD Starter Modelling Process (Define step)
Core Domain ChartWhy this context is Corecore-domain-charts
Bounded Context CanvasPurpose, classification, roles, every inbound and outbound message, decisions, open questionsbounded-context-canvas v5
Context MapEvery upstream and downstream neighbour with its pattern and channelcontext-mapping
Aggregate Design CanvasFulfillmentAssignment: states, invariants, policies, commands, events, read modelsaggregate-design-canvas v1.1
Domain EventsThe 15 published events with data fields and consumers; the 34 consumed events— (CloudEvents catalogue)
Domain Message FlowHappy path, refusal and re-promise, cancellation, across contextsdomain-message-flow-modelling
EventStormingProcess-level boards with hotspotseventstorming-glossary-cheat-sheet
Use CasesOne section per command: trigger, adapter, flow, errors, events, idempotency— (application layer)
Class DiagramProposed domain classes and the hexagonal ports and adapters— (UML)
Entity RelationshipProposed Postgres schema, read-model and infrastructure tables— (UML / ER)
Sequence DiagramsOne runtime sequence per command use case, with outbox and version checks— (UML)

The REST contract is apis/order-sourcing/openapi.yaml (proposed, OpenAPI 3.0.3), rendered under the API reference.

Service and operations​

  • Service: IQVO/order-sourcing on develop (62a2e03, 2026-10-26): binaries cmd/api (REST) and cmd/mcp (read-only MCP), and the console remote in web/.
  • Deployment: wired in warehouse-infra develop: a terraform/apps.yaml entry (database: true, frontend_remote: order_sourcing_mfe) and helm-values/order-sourcing.yaml (MCP enabled, gateway path /api/mcp/order-sourcing). The cluster itself was not checked in this refresh.
  • Observability: service ADR 0008, Adopt the fleet observability standard, Accepted 2026-10-26. Logs, metrics and traces leave over OTLP to the otel-collector (OTEL_EXPORTER_OTLP_ENDPOINT, chart default otel-collector.observability.svc.cluster.local:4317; OTEL_SERVICE_NAME). The Tier-2 business counter is sourcing.groups.sourced (unit {group}, in internal/adapters/outbound/telemetry/sourcing_metrics.go), with attribute outcome = queued, released, unsourceable or failed and reason on the outcomes that are not a success. The dashboard queries it as sourcing_groups_sourced_total in warehouse-infra's terraform/dashboards/contexts/order-sourcing.json, by outcome.

Elsewhere​