Skip to main content

Bounded Context Canvas

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.

Following the ddd-crew Bounded Context Canvas v5. Every message row maps to a rest route, an inbound row, a publishes or a consumes entry of contexts[last-mile-delivery] in the model.

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 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 or apps; blue = sibling bounded context; dashed = published with no context consumer (analytics only). Channel names on the arrows are abbreviated (REST, Kafka); the Inbound and Outbound Communication tables carry the exact route, topic and CloudEvents type for every message.

Inbound​

Derived from: model.yaml → contexts[last-mile-delivery].inbound, .rest, .consumes, .purpose, .roles, .business_decisions.

Outbound​

Derived from: model.yaml → contexts[last-mile-delivery].publishes (consumers), .sync_calls (empty).

Both diagrams omit assumptions, verification metrics, open questions and the ubiquitous language (sections below), and the relationship pattern per message (see the tables). The outbound picture has no command or query arrow because the model gives this context no sync_calls.

Name​

Last-Mile Delivery (last-mile-delivery, code LM, CloudEvents tier logistics).

Purpose​

Runs each delivery station: publishes delivery waves (induct cutoff, delivery window, stop capacity) that the promise relies on, plans routes for delivery service partners, and records every delivery attempt.

In practice the context:

  • keeps one DeliveryWave per dispatch slot of a station and service date, and publishes its capacity for delivery-promise and order-sourcing;
  • inducts every package of a load that arrives at a station into the earliest eligible wave (InductOnArrival);
  • plans one Route per DSP van in a wave, never above the van's stop capacity;
  • records each attempt, re-inducts a failed package into the next wave (RetryNextWave), and tells shipping-and-tracking what happened.

It never sees an address (ADR 0006).

Strategic Classification​

AxisVerdict
DomainSupporting See Core Domain Chart.
Business ModelCost reducer and experience creator (the doorstep).
EvolutionCustom-built.

Domain Roles​

RoleApplies?Evidence in the model
Execution (routes and attempts)Yes, primaryRoute with PlanRoute, StartRoute, RecordAttempt, CompleteRoute; DeliveryWave with InductPackage, DispatchWave
Specification (wave capacity)YesDeliveryWave publishes inductCutoffAt, the window and stopCapacity; two Core contexts plan on it
Gateway / ACLNoIt talks to no external system. The DSP driver app calls its REST API
AnalysisNoNo scorecard or optimisation is modelled

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
Station planner (person)ScheduleWaveCommandREST POST /wavesUI on Open Host
Station plannerCloseInductionCommandREST POST /waves/{waveId}/induction-closuresUI on Open Host
Station plannerDispatchWaveCommandREST POST /waves/{waveId}/dispatchesUI on Open Host
Station plannerPlanRouteCommandREST POST /routesUI on Open Host
Station plannerList wavesQueryREST GET /waves?stationNodeId=&serviceDate=UI on Open Host
Station plannerContractPartnerCommandREST POST /partnersUI on Open Host
DSP driver app (external organisation)StartRouteCommandREST POST /routes/{routeId}/startsUI on Open Host
DSP driver appRecordAttemptCommandREST POST /routes/{routeId}/attemptsUI on Open Host
linehaul-transportationLoadArrivedEventKafka retailnetwork.linehaul-transportation.events, type com.retailnetwork.logistics.linehaul-transportation.load.LoadArrivedCustomer/Supplier (we are the Customer)
node-topologyNodeRegisteredEventKafka retailnetwork.node-topology.events, type com.retailnetwork.logistics.node-topology.node.NodeRegisteredConformist
node-topologyServiceAreaAssignedEventKafka retailnetwork.node-topology.events, type com.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssignedConformist

The model's planner inbound row names ScheduleWave, PlanRoute and DispatchWave. The CloseInduction, list-waves and ContractPartner rows come from the context's rest list, which has no matching inbound row. The caller shown for them is this page's reading and is listed as an open question below.

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
delivery-promise, order-sourcingDeliveryWaveScheduledEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduledOpen Host + Published Language (they are Conformist)
delivery-promise, order-sourcingDeliveryWaveCapacityChangedEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChangedOpen Host + Published Language (they are Conformist)
analytics onlyDeliveryWaveCancelledEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCancelledPublished Language, no context consumer
analytics onlyRoutePlannedEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.RoutePlannedPublished Language, no context consumer
shipping-and-trackingPackageOutForDeliveryEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.PackageOutForDeliveryOpen Host + Published Language (it is Conformist)
shipping-and-trackingDeliveryAttemptedEventKafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.DeliveryAttemptedOpen Host + Published Language (it is Conformist)
—(no synchronous call)—sync_calls: []—

Full message details: Domain Events. Relationship reasoning: Context Map.

Ubiquitous Language​

Full glossary: Ubiquitous Language. Top terms: Last Mile, Delivery Wave (induct cutoff, delivery window, stop capacity), Induction, Route, Delivery Service Partner (DSP), Delivery Attempt (DELIVERED or FAILED).

Business Decisions​

  1. Earliest eligible wave. A package joins the earliest wave whose induct cutoff it arrived before and that has stop capacity left (InductOnArrival; ErrInductionClosed, ErrWaveFull).
  2. Van capacity is a hard limit. A route never exceeds its van's stop capacity (ErrRouteOverCapacity), and a partner's van capacity is greater than zero (ErrInvalidVanCapacity).
  3. Delivered once. A package is delivered at most once (ErrAlreadyDelivered). An attempt is recorded only on a route that is out for delivery (ErrRouteNotStarted).
  4. Fail forward. A FAILED attempt re-inducts the package into the next wave. Three failures return it to sender (RetryNextWave).
  5. Waves are well-formed. inductCutoffAt < windowStart < windowEnd (ErrInvalidWaveTimes), and assigned stops never exceed stops (ErrWaveFull).
  6. Capacity is published, never asked for. The promise and sourcing contexts read waves from events; there is no query on their hot path (model integration rule).

Assumptions​

  • LoadArrived with a destinationNodeId that is a delivery station is the only signal that packages are at the station. There is no station-side arrival scan in the model.
  • NodeRegistered (nodeType = DELIVERY_STATION) is enough to know which nodes are stations. The model feeds no node status events to this context.
  • A partner has one van capacity, expressed in stops ("van capacity of the partner").
  • The DSP driver app can reach the REST API while on the road. The model has no offline or batch attempt upload.
  • Every consumer is idempotent on the CloudEvents id, and every published event leaves through a transactional outbox (model integration_rules).
  • A package whose destination postal prefix is a CARRIER_HANDOFF service area is never inducted into a wave: it takes no stop capacity and raises no event, and the counter last_mile_delivery.carrier_area.skipped counts it (last-mile-delivery ADR 0015).

Verification Metrics​

MetricDefinitionSource
Induction lag p95DeliveryWaveCapacityChanged.time − LoadArrived.arrivedAt, per packageoutbox + inbox timestamps
Earliest-wave hit rateshare of inducted packages placed in the earliest wave whose inductCutoffAt they arrived beforeInboundPackagesView vs induction
Uninducted packagespackages in InboundPackagesView with no wave after their arrivalInboundPackagesView
Wave fillassignedStops / stopCapacity at CloseInductionDeliveryWave
Route utilisationstopCount / van capacity per RoutePlannedRoute, DeliveryServicePartner
First-attempt successshare of tracking numbers whose first DeliveryAttempted has outcome = DELIVEREDDeliveryAttempted
Return-to-sender rateshare of tracking numbers with three FAILED attemptsDeliveryAttempted
Rejected commandscount of ErrWaveFull, ErrRouteOverCapacity, ErrAlreadyDelivered per dayproblem responses
Outbox lag p95outbox published_at − created_atoutbox_events

Open Questions​

  • Who triggers CompleteWave, CancelWave and CompleteRoute? (resolved) CancelWave is the station planner's POST /waves/{waveId}/cancellations. CompleteWave and CompleteRoute have no caller: a route completes after the attempt that records its last package (ADR 0002 A16) and a wave completes with its last route, or at once when dispatched with no route (A9).
  • Who calls POST /partners and GET /waves? The routes are in rest but no inbound row names a caller. CloseInduction has a route but is missing from the planner's inbound row.
  • How does a package map to stops? (resolved, G11). Wave capacity and van capacity are counted in stops, and induction is per package. Packages are grouped into stops by the stopKey of LabelIssued, an opaque keyed hash of the normalized address, so this context never receives an address (ADR 0006). A package for a stop already in the wave takes no capacity. How the driver learns the address is not decided: no address route is built.
  • What happens when no wave is eligible? If every wave is full or closed, InductPackage fails with ErrWaveFull or ErrInductionClosed. No event tells delivery-promise that the witness wave was missed. Today only shipping-and-tracking's ExceptionOnSilence would surface it later.
  • Does delivery-promise learn that a wave was cancelled? Yes: DeliveryWaveCancelled goes to the integration stream and delivery-promise and order-sourcing consume it (ADR 0002 A22; last-mile-delivery ADR 0003 addendum).
  • Who records the third failure and the return to sender? RetryNextWave needs a failure count per package across routes and waves. No aggregate holds that count, and no event carries "return to sender" to shipping-and-tracking, whose ReturnToSender has no trigger from this context.
  • What happens to packages in a cancelled wave? (resolved, ADR 0002 A10) CancelWave is allowed only from OPEN. In the same transaction every inducted package is re-inducted onto the next eligible wave; one with no eligible wave is unplaced and raises PackageInductionDeferred.
  • Is a station still active? StationView is fed by NodeRegistered and ServiceAreaAssigned only. NodeSuspended and NodeRetired do not reach this context, so a wave can be scheduled at a suspended station.