Skip to main content

Bounded context canvas

Synced from inbound-receiving

This page is a copy of docs/docs/ddd/bounded-context-canvas.md on develop, derived from that repository's code. Edit it there, then re-sync.

DockAppointment moved (ADR 0019)

The dock appointment is owned by dock-scheduling since ADR 0019. This context keeps a read-only local copy fed by dock-scheduling's DockAppointmentBooked / DockAppointmentCancelled, no longer books, checks in, cancels or completes appointments, and no longer raises the four DockAppointment* events (the one-shot api republish-appointments backfill that re-announced them was removed, ADR 0022). Where this page describes those commands, rules or events, read it as the pre-transfer design; the page is not yet rewritten.

Following the ddd-crew Bounded Context Canvas v5. Every message row below maps to a route in NewRouter (internal/adapters/inbound/http/server.go) or to a topic and CloudEvents type in internal/adapters/inbound/kafka/{product_consumer,dock_door_consumer}.go / internal/adapters/outbound/kafka/encoder.go.

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; double border = external system or platform; grey = this context's own projector, reports or dead-letter path; dashed = published today with no consumer. Channel names on the arrows are abbreviated (REST, MCP, Kafka, HTTP, port); the Inbound and Outbound Communication tables carry the exact route, tool, topic and CloudEvents type for every message.

Inbound​

Outbound​

Source: the Inbound Communication and Outbound Communication tables of this page, which map to internal/adapters/inbound/{http,kafka,mcp} and internal/adapters/outbound/. The diagram omits assumptions, verification metrics, open questions and the ubiquitous language (sections below), the relationship pattern per message (OHS, ACL, Conformist, Customer/Supplier - see the tables) and anything the tables mark as deprecated or platform-only (health probes).

Name​

Inbound Receiving (inbound-receiving, Go module github.com/claudioed/inbound-receiving, GitHub IQVO/inbound-receiving).

Purpose​

Own the inbound dock workflow up to, and not including, stock placement: the supplier's announcement of a delivery (ASN), the carrier's booked door window (dock appointment) and the counted receipt with the discrepancies found when it closes. Publish every accepted change so inventory-storage can book received Good units as staged stock without a request-time call. It answers no "where" or "how many are in stock" question (ADR 0001).

Strategic Classification​

AxisVerdictEvidence
DomainSupportingADR 0001 "Classification"; see the core domain chart
Business modelCost reduction / compliance: an accurate receipt and discrepancy recordwarehouse-docs contexts table; the receipt is the dock's source of truth for what arrived
EvolutionCustom-built (genesis)Created 2026-10-08 (ADRs 0001-0004)

Domain Roles​

RoleApplies?Notes
Execution contextYes (primary, document-level)Dock staff record what arrived; it moves no stock itself.
Specification contextPartlyThe ASN is the supplier's specification of what should arrive.
Gateway / Open Host ServiceYesREST plus the warehouse.inbound-receiving.events Published Language.
Analysis contextNoDiscrepancy is a per-line comparison on close.
Analytics / reportingYes (own read side, ADR 0006)cmd/inbound-projector projects warehouse.inbound-receiving.analytics into a separate analytical database; cmd/inbound-reports serves receiving performance and freshness.

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Supplier-facing operatorRegister ASNCommandREST POST /asns (Idempotency-Key required)This context is the OHS
OperatorCancel ASNCommandREST POST /asns/{asnNumber}/cancellationsOHS
Dock plannerBook dock appointmentCommandREST POST /appointments (Idempotency-Key required)OHS
Dock planner / gateCheck in, cancel appointmentCommandREST POST /appointments/{appointmentId}/check-ins, .../cancellationsOHS
Dock staffOpen receiptCommandREST POST /receipts (Idempotency-Key required)OHS
Dock staffReceive a quantity against a lineCommandREST POST /receipts/{receiptId}/lines (Idempotency-Key required)OHS
Dock staffClose receiptCommandREST POST /receipts/{receiptId}/closuresOHS
Operator, console, agentGet / list ASNs, appointments, receiptsQueryREST GET /asns, /asns/{asnNumber}, /appointments, /appointments/{appointmentId}, /receipts, /receipts/{receiptId}OHS
Operator, console, agentList known inbound dock doorsQueryREST GET /docksOHS
warehouse-ops-agentGet / list ASNs, appointments, receipts; list docksQueryMCP (cmd/mcp, Streamable HTTP): get_asn, list_asns, get_appointment, list_appointments, get_receipt, list_receipts, list_docksOHS, read-only (ADR 0005)
Dock manager, consoleReceiving performance per day; projection freshnessQueryREST GET /reports/receiving-performance, GET /reports/freshness on cmd/inbound-reportsOHS over the analytical database (ADR 0006)
product-masterProductRegisteredEventKafka warehouse.product-master.events, com.warehouse.wms.product-master.product.ProductRegisteredConformist with a local copy (known_skus); group PRODUCT_CONSUMER_GROUP
facility-layoutLocationSlotRegisteredEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredConformist with a local copy (dock_doors); group DOCK_DOOR_CONSUMER_GROUP
facility-layoutLocationSlotDecommissionedEventKafka warehouse.facility.events, com.warehouse.wms.facility-layout.locationslot.LocationSlotDecommissionedConformist; same group

No REST endpoint or MCP tool is authenticated (fleet-wide revert of 2026-09-11; TestNoAuthMiddlewareReintroduced fails the build if auth middleware returns). The MCP server is read-only: writes stay on REST.

Outbound Communication​

The context makes no synchronous call to any sibling and has no outbound HTTP client (ADR 0001). Everything outbound leaves through the transactional outbox and the relay in cmd/api.

CollaboratorMessageTypeChannelRelationship
inventory-storageReceiptLineReceived, ReceiptCartonReceivedEventKafka warehouse.inbound-receiving.events, com.warehouse.wms.inbound-receiving.receipt.*This context upstream, OHS + Published Language; inventory-storage books condition=Good only (its ADR 0037) and links the carton identity (its ADR 0045)
yard-managementASNRegistered, ASNCancelled, ReceiptOpened, ReceiptClosedEventsame topic, ...asn.* and ...receipt.*OHS + PL; group INBOUND_RECEIVING_CONSUMER_GROUP
dock-schedulingASNRegistered, ASNCancelledEventsame topic, ...asn.*OHS + PL; group ASN_CONSUMER_GROUP
network-fulfillmentReceiptCartonReceived, CartonDiscrepancyRaised, ReceiptClosedEventsame topic, ...receipt.*OHS + PL; group INBOUND_RECEIPT_CONSUMER_GROUP
exception-managementCartonDiscrepancyRaisedEventsame topic, ...receipt.CartonDiscrepancyRaisedOHS + PL; group CARTON_DISCREPANCY_CONSUMER_GROUP
none todayReceiptStowCompletedEventsame topic, ...receipt.ReceiptStowCompletedOHS + PL
this context's own inbound-projectorall eight events, same type and id (it folds six of them plus the four historical dockappointment types and ignores the two carton types)EventKafka warehouse.inbound-receiving.analytics (DLQ .dlq), dataschema=urn:warehouse:inbound-receiving:analytics:<EventName>:v1internal data stream, not an integration contract (ADR 0006)

The four dockappointment.DockAppointment* types are not an outbound message any more: ADR 0022 retired them and no sibling's dispatch code reads them. The full list with payloads is on Domain events.

Ubiquitous Language​

Full glossary with code identifiers: Ubiquitous language. Top terms: ASN, Dock appointment, Door, Window, Check-in, Receipt, Line, Condition (Good / Damaged), Discrepancy (Short / Over / Damaged), Walk-in, Snapshot, Local copy, Version.

Business Decisions​

  1. A receipt is opened against a snapshot of the ASN; the ASN must be Registered or Receiving (ADR 0002).
  2. Over-receipt is accepted, never refused: it is physically there, and shows as an Over discrepancy on close (ADR 0002).
  3. Closing a receipt with nothing received is allowed; every line is then Short (ADR 0002).
  4. A door window is half-open, at most 4 hours, may not start in the past, and two active appointments may not overlap on one door (ADR 0002).
  5. Check-in is allowed from 30 minutes before the window starts until it ends (ADR 0002).
  6. At most one open receipt per ASN (ADR 0002).
  7. Only Good units are handed to inventory-storage; Damaged units are recorded and counted in the discrepancies but not booked, and stow stays an RF action there (ADR 0003).
  8. Every difference is reported; there is no tolerance policy in v1 (ADR 0002).
  9. SKU and door checks always read the local copies (PRODUCT_MODE / DOCK_DOOR_MODE are kafka, the only mode; ADR 0003, ADR 0011).

Assumptions​

  • ASNs arrive through the REST API already structured: no EDI parsing, purchase orders or supplier master data here (ADR 0001).
  • Consumers of the receipt events can rely on per-ASN order: all eight published types are keyed by asn_number (asnRow and receiptRow in the encoder). The four retired dockappointment types were keyed by appointment_id, so their order relative to receipt events was never guaranteed (ADR 0004).
  • The far side handles its own failures (inventory-storage skips and logs); this context has no compensation flow in v1 (ADR 0003).

Verification Metrics​

  • Golden exact-JSON tests per published type (TestEncoderGoldenAsnEvents, TestEncoderGoldenReceiptEvents, internal/adapters/outbound/kafka/encoder_test.go).
  • TestEventCatalogueMatchesContract checks ADR 0004 against apis/asyncapi.yaml; TestHexagonalArchitecture enforces the layering.
  • Outbox atomicity and relay delivery proven with testcontainers Postgres and Kafka (TestUseCasesCommitStateAndOutboxAtomically, TestRelayRealPostgresAndKafkaPublishesCloudEventsWithTheRightTypeAndKey, TestProductConsumerEndToEnd, TestDockDoorConsumerEndToEnd), plus the integration suites for the use-case wiring, pgtx, the Kafka publisher, the REST adapter, MCP over Streamable HTTP and the analytics read side end to end (analytics_e2e_integration_test.go).
  • One open receipt per ASN proven against Postgres (TestReceiptRepoAtMostOneOpenReceiptPerAsn).
  • The receiving KPIs (receipts closed, units good versus damaged, discrepancies by kind, receipt cycle time, dock dwell, appointment milestones) are served by GET /reports/receiving-performance (ADR 0006); the one business counter, inbound_receiving.receipts.units_received (units by outcome), is the only receiving figure emitted as telemetry.

Open Questions​

  • None about the warehouse-planning edge: it is built (warehouse-planning ADR 0017). The one limit that remains on the Kafka side is the kafka-go behaviour of ADR 0011: a group consumer started before its topic exists does not pick the topic up later (see Troubleshooting).
  • A tolerance policy for over-receipt, and a quarantine flow for Damaged units, are later, separately decided changes (ADR 0002, ADR 0001).