Skip to main content

Bounded context canvas

Following the ddd-crew Bounded Context Canvas v5. Every message row below maps to a route in apis/openapi.yaml, an event in apis/asyncapi.yaml or a consumer in internal/adapters/inbound/kafka/handlers.go.

Canvas at a glance​

Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt). The Inbound and Outbound Communication tables carry the exact route, topic and CloudEvents type for every message.

Inbound​

Source: internal/adapters/inbound/http/server.go (routes), internal/adapters/inbound/kafka/handlers.go (consumers), internal/scheduler/scheduler.go and internal/application/usecases/sweep.go (silence sweep).

Outbound​

Source: internal/adapters/outbound/customerordering/gateway.go, internal/adapters/outbound/kafka/encoder.go, and the consumer lists in apis/asyncapi.yaml. The diagram omits the synchronous reply POST /labels returns to vendor-connectivity. PackageScanned has no named consumer beyond customer-ordering's tracking view. All Kafka topics are retailnetwork.<producer>.events.

Name​

Shipping & Tracking (shipping-and-tracking, CloudEvents tier logistics).

Purpose​

To issue the shipping label for every package and to own each package's journey. The context:

  • issues a label with a network-wide unique tracking number when vendor-connectivity asks for one in-organisation;
  • reads the ship-to address from customer-ordering at that moment and keeps only an AES-256-GCM encrypted snapshot needed to print it;
  • consolidates the vendor's shipment confirmation, the pickup scan, linehaul load departures and arrivals, and last-mile out-for-delivery, attempt and return facts into one customer-visible, forward-only timeline;
  • ends that timeline in delivered, returned, lost or voided, and raises an exception when a package goes silent.

It is the only context outside customer-ordering that ever sees a ship-to address, and it publishes none.

Strategic classification​

AxisVerdict
DomainGeneric subdomain. See Core domain chart
Business modelCompliance and experience (labels and the tracking timeline)
EvolutionCommodity: a candidate to buy rather than build, behind an anti-corruption layer that keeps the published event names

Domain roles​

RoleApplies?Evidence
Execution (labels)YesShippingLabel with IssueLabel and VoidLabel; uniqueness of (poNumber, packageNo) and of trackingNumber
Analysis (timeline)YesPackageJourney turns six foreign event types into one state machine; the handover instant and the silence policy derive facts nobody else publishes
GatewayNoIt guards personal data but translates no external model. The vendor reaches it only through vendor-connectivity
SpecificationNoIt declares nothing other contexts plan against

Inbound communication​

CollaboratorMessageTypeChannelRelationship
vendor-connectivityIssueLabelCommandREST POST /labelsCustomer/Supplier (vendor-connectivity is the customer)
vendor-connectivityVendorShipmentConfirmedEventKafka retailnetwork.vendor-connectivity.events, com.retailnetwork.partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmedConformist
linehaul-transportationLoadDepartedEventKafka retailnetwork.linehaul-transportation.events, com.retailnetwork.logistics.linehaul-transportation.load.LoadDepartedConformist
linehaul-transportationLoadArrivedEventsame topic, ...load.LoadArrivedConformist
last-mile-deliveryPackageOutForDeliveryEventKafka retailnetwork.last-mile-delivery.events, com.retailnetwork.logistics.last-mile-delivery.route.PackageOutForDeliveryConformist
last-mile-deliveryDeliveryAttemptedEventsame topic, ...route.DeliveryAttemptedConformist
last-mile-deliveryPackageReturnInitiatedEventsame topic, ...packageattempthistory.PackageReturnInitiated (the route spelling is accepted)Conformist
offer-availabilityCatalogItemCreatedEventKafka retailnetwork.offer-availability.events, com.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreatedConformist
Shoppers, customer-ordering, console, agentsGetJourneyQueryREST GET /journeys/{trackingNumber}, MCP and A2A get_journeyOpen host
Not namedRecordScanCommandREST POST /journeys/{trackingNumber}/scansNo named caller
Not namedVoidLabelCommandREST POST /labels/{labelRef}/voidsNo named caller
ItselfRaiseException, DeclareLostCommandthe silence-sweep jobInternal

Outbound communication​

CollaboratorMessageTypeChannelRelationship
customer-orderingGetShipToQuery (synchronous)REST GET {CUSTOMER_ORDERING_URL}/orders/{orderId}/ship-toCustomer/Supplier (this context is the customer)
linehaul-transportation, customer-ordering, last-mile-deliveryLabelIssuedEventKafka retailnetwork.shipping-and-tracking.events, com.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedPublished language
customer-ordering, linehaul-transportationLabelVoidedEventsame topic, ...label.LabelVoidedPublished language
none named beyond customer-ordering's tracking viewPackageScannedEventsame topic, ...journey.PackageScannedPublished language
node-performancePackageHandedOverEventsame topic, ...journey.PackageHandedOverPublished language
delivery-promise, order-sourcing, customer-orderingPackageDeliveredEventsame topic, ...journey.PackageDeliveredPublished language
delivery-promise, customer-orderingPackageExceptionRaisedEventsame topic, ...journey.PackageExceptionRaisedPublished language
delivery-promisePackageReturnedEventsame topic, ...journey.PackageReturnedPublished language
delivery-promisePackageLostEventsame topic, ...journey.PackageLostPublished language

Message details: Domain events and the event catalogue. Relationship evidence: Context map. The consumer names come from apis/asyncapi.yaml; this repository does not verify that each consumer is deployed.

Ubiquitous language​

Full glossary: Ubiquitous language. Top terms: Tracking Number, Shipping Label (not the Vendor API Label), Package Journey, Scan, Handover (not VendorShipmentConfirmed), ship-to snapshot.

Business decisions​

  1. A tracking number is unique network-wide and a label is issued once per package (label.ErrLabelAlreadyIssued, label.ErrTrackingNumberTaken).
  2. The address is fetched from customer-ordering at issue time and never published. Only the sealed snapshot needed to print is kept, until 30 days after the journey closes (usecases.ShipToRetention). No event, response or read model carries it; what leaves is an opaque stopKey and a postal prefix on LabelIssued (TestContractsCarryNoShipToField).
  3. The journey only moves forward. A duplicate scan is refused (ErrDuplicateScan), an out-of-order scan is stored but not applied (ErrScanOutOfOrder), and DELIVERED, RETURNED, LOST and VOIDED are terminal (ErrJourneyClosed).
  4. Handover is the network's observation. The first pickup departure scan at the vendor node is the handover instant, not the vendor's VendorShipmentConfirmed.
  5. Silence is an exception. No applied scan within the window of the state and tier raises PackageExceptionRaised with reason NO_SCAN; 48 hours unanswered on an in-transit package declares it lost.

Assumptions​

  • vendor-connectivity asks for a label only for a purchase order it has accepted; this context does not re-check.
  • customer-ordering answers GetShipTo inside the label request. If it does not, no label is issued (ship-to-unavailable).
  • Every tracking number named on a load or route event is one this context issued; an unknown number is counted and acknowledged.
  • The scan time a producer reports (departedAt, arrivedAt, at, shippedAt) is the time order the journey applies. Kafka order across topics is not.
  • A LoadDeparted whose departureKind is PICKUP is that package's pickup departure at the vendor node; without a kind, the event counts as a pickup only while the journey is still LABELLED.

Verification metrics​

What exists today, from internal/adapters/outbound/telemetry: the counter shipping.labels.issued with attribute outcome (issued or rejected) and reason. See Observability.

Not instrumented in this repository, and therefore not claimed: label issue latency, scan-refusal rates by producer, journeys stuck in LABELLED, NO_SCAN false-alarm rate and consumer lag. The consumer and job outcomes are visible only in logs (counts of duplicate, out-of-order, unknown and closed outcomes per event).

Decisions taken since the model​

The answers the code gives to questions the central model left open:

  • Who calls RecordScan and VoidLabel over REST? The routes exist and are unauthenticated; no caller is named in the code or the contracts.
  • What does IssueLabel carry? poNumber, packageNo, assignmentId, orderId and tier; the orderId is an additive field (ADR 0002).
  • Node types. LoadArrived carries nodeType, so a delivery station is told from a sortation centre without a node-topology event.
  • Direct injection. An arrival at a delivery station straight after handover is allowed (HANDED_OVER to AT_STATION).
  • Expected leg time. Fixed silence windows per tier and state: 6, 24, 48 or 72 hours, and 12 hours out for delivery.
  • Triggers of ReturnToSender, DeclareLost and StartJourney. A consumed PackageReturnInitiated; the silence sweep after 48 hours unanswered; IssueLabel itself.
  • What VoidLabel does to the journey. It closes a LABELLED journey as VOIDED in the same transaction.
  • Snapshot retention. 30 days after the journey closes, deleted by the ship-to-purge job.
  • Still open. No route renders a printable label, and nothing in this repository names the caller of RecordScan and VoidLabel.