Bounded Context Canvas
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
DeliveryWaveper dispatch slot of a station and service date, and publishes its capacity fordelivery-promiseandorder-sourcing; - inducts every package of a load that arrives at a station into the earliest
eligible wave (
InductOnArrival); - plans one
Routeper 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 tellsshipping-and-trackingwhat happened.
It never sees an address (ADR 0006).
Strategic Classification
| Axis | Verdict |
|---|---|
| Domain | Supporting See Core Domain Chart. |
| Business Model | Cost reducer and experience creator (the doorstep). |
| Evolution | Custom-built. |
Domain Roles
| Role | Applies? | Evidence in the model |
|---|---|---|
| Execution (routes and attempts) | Yes, primary | Route with PlanRoute, StartRoute, RecordAttempt, CompleteRoute; DeliveryWave with InductPackage, DispatchWave |
| Specification (wave capacity) | Yes | DeliveryWave publishes inductCutoffAt, the window and stopCapacity; two Core contexts plan on it |
| Gateway / ACL | No | It talks to no external system. The DSP driver app calls its REST API |
| Analysis | No | No scorecard or optimisation is modelled |
Inbound Communication
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
| Station planner (person) | ScheduleWave | Command | REST POST /waves | UI on Open Host |
| Station planner | CloseInduction | Command | REST POST /waves/{waveId}/induction-closures | UI on Open Host |
| Station planner | DispatchWave | Command | REST POST /waves/{waveId}/dispatches | UI on Open Host |
| Station planner | PlanRoute | Command | REST POST /routes | UI on Open Host |
| Station planner | List waves | Query | REST GET /waves?stationNodeId=&serviceDate= | UI on Open Host |
| Station planner | ContractPartner | Command | REST POST /partners | UI on Open Host |
| DSP driver app (external organisation) | StartRoute | Command | REST POST /routes/{routeId}/starts | UI on Open Host |
| DSP driver app | RecordAttempt | Command | REST POST /routes/{routeId}/attempts | UI on Open Host |
linehaul-transportation | LoadArrived | Event | Kafka retailnetwork.linehaul-transportation.events, type com.retailnetwork.logistics.linehaul-transportation.load.LoadArrived | Customer/Supplier (we are the Customer) |
node-topology | NodeRegistered | Event | Kafka retailnetwork.node-topology.events, type com.retailnetwork.logistics.node-topology.node.NodeRegistered | Conformist |
node-topology | ServiceAreaAssigned | Event | Kafka retailnetwork.node-topology.events, type com.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssigned | Conformist |
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
| Collaborator | Message | Type | Channel | Relationship |
|---|---|---|---|---|
delivery-promise, order-sourcing | DeliveryWaveScheduled | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveScheduled | Open Host + Published Language (they are Conformist) |
delivery-promise, order-sourcing | DeliveryWaveCapacityChanged | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCapacityChanged | Open Host + Published Language (they are Conformist) |
| analytics only | DeliveryWaveCancelled | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.wave.DeliveryWaveCancelled | Published Language, no context consumer |
| analytics only | RoutePlanned | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.RoutePlanned | Published Language, no context consumer |
shipping-and-tracking | PackageOutForDelivery | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.PackageOutForDelivery | Open Host + Published Language (it is Conformist) |
shipping-and-tracking | DeliveryAttempted | Event | Kafka retailnetwork.last-mile-delivery.events, type com.retailnetwork.logistics.last-mile-delivery.route.DeliveryAttempted | Open 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
- Earliest eligible wave. A package joins the earliest wave whose induct
cutoff it arrived before and that has stop capacity left
(
InductOnArrival;ErrInductionClosed,ErrWaveFull). - 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). - Delivered once. A package is delivered at most once
(
ErrAlreadyDelivered). An attempt is recorded only on a route that is out for delivery (ErrRouteNotStarted). - Fail forward. A
FAILEDattempt re-inducts the package into the next wave. Three failures return it to sender (RetryNextWave). - Waves are well-formed.
inductCutoffAt < windowStart < windowEnd(ErrInvalidWaveTimes), and assigned stops never exceed stops (ErrWaveFull). - 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
LoadArrivedwith adestinationNodeIdthat 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 (modelintegration_rules). - A package whose destination postal prefix is a
CARRIER_HANDOFFservice area is never inducted into a wave: it takes no stop capacity and raises no event, and the counterlast_mile_delivery.carrier_area.skippedcounts it (last-mile-delivery ADR 0015).
Verification Metrics
| Metric | Definition | Source |
|---|---|---|
| Induction lag p95 | DeliveryWaveCapacityChanged.time − LoadArrived.arrivedAt, per package | outbox + inbox timestamps |
| Earliest-wave hit rate | share of inducted packages placed in the earliest wave whose inductCutoffAt they arrived before | InboundPackagesView vs induction |
| Uninducted packages | packages in InboundPackagesView with no wave after their arrival | InboundPackagesView |
| Wave fill | assignedStops / stopCapacity at CloseInduction | DeliveryWave |
| Route utilisation | stopCount / van capacity per RoutePlanned | Route, DeliveryServicePartner |
| First-attempt success | share of tracking numbers whose first DeliveryAttempted has outcome = DELIVERED | DeliveryAttempted |
| Return-to-sender rate | share of tracking numbers with three FAILED attempts | DeliveryAttempted |
| Rejected commands | count of ErrWaveFull, ErrRouteOverCapacity, ErrAlreadyDelivered per day | problem responses |
| Outbox lag p95 | outbox published_at − created_at | outbox_events |
Open Questions
- Who triggers
CompleteWave,CancelWaveandCompleteRoute? (resolved)CancelWaveis the station planner'sPOST /waves/{waveId}/cancellations.CompleteWaveandCompleteRoutehave 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 /partnersandGET /waves? The routes are inrestbut noinboundrow names a caller.CloseInductionhas a route but is missing from the planner'sinboundrow. - 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
stopKeyofLabelIssued, 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,
InductPackagefails withErrWaveFullorErrInductionClosed. No event tellsdelivery-promisethat the witness wave was missed. Today onlyshipping-and-tracking'sExceptionOnSilencewould surface it later. - Does
delivery-promiselearn that a wave was cancelled? Yes:DeliveryWaveCancelledgoes to the integration stream anddelivery-promiseandorder-sourcingconsume it (ADR 0002 A22; last-mile-delivery ADR 0003 addendum). - Who records the third failure and the return to sender?
RetryNextWaveneeds a failure count per package across routes and waves. No aggregate holds that count, and no event carries "return to sender" toshipping-and-tracking, whoseReturnToSenderhas no trigger from this context. - What happens to packages in a cancelled wave? (resolved, ADR 0002 A10)
CancelWaveis allowed only fromOPEN. In the same transaction every inducted package is re-inducted onto the next eligible wave; one with no eligible wave is unplaced and raisesPackageInductionDeferred. - Is a station still active?
StationViewis fed byNodeRegisteredandServiceAreaAssignedonly.NodeSuspendedandNodeRetireddo not reach this context, so a wave can be scheduled at a suspended station.