Last-Mile Delivery
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 (last-mile-delivery ADR 0012): cmd/lm-projector projects this context's own topics into a separate analytical database, and cmd/lm-reports serves the read-only /reports/... routes on :8092, including the day-of ETA-window report of ADR 0013.
Supporting tier logistics · code LM
Last-Mile Delivery runs each delivery station of the network. A delivery
station is a network-operated node (see
ADR 0004). The context
publishes delivery waves: dispatch slots with an induct cutoff, a delivery
window and a stop capacity. delivery-promise and order-sourcing plan the
last leg of every path on those waves. When a load arrives at a station from
linehaul-transportation, the context inducts each package into the earliest
wave that still has room. It plans routes for independent Delivery Service
Partners (DSPs) within each van's stop capacity, and it records every
delivery attempt as DELIVERED or FAILED, with an optional
driver-reported category (outcomeDetail, last-mile-delivery ADR 0014). A
failed package goes into the next wave. After three failures it goes back to
the sender. At route start it assigns each stop a day-of ETA window of at
most two hours, spread linearly over what is left of the wave's delivery
window (ADR 0013), and it learns a delivery-point profile per opaque stop
key that flags a point after two counted failed attempts. The context owns
four aggregates: DeliveryWave, Route, DeliveryServicePartner and
DeliveryPointProfile.
- Inbound: REST commands from the station planner (
/waves,/routes) and from the DSP driver app (/routes/{routeId}/starts,/routes/{routeId}/attempts);LoadArrivedfromlinehaul-transportation;NodeRegisteredandServiceAreaAssignedfromnode-topology. - Outbound: eleven CloudEvents types on
retailnetwork.last-mile-delivery.events.delivery-promiseandorder-sourcingconsume the wave events.shipping-and-trackingconsumes the out-for-delivery, stop-ETA-window, attempt and delivery-point-flag events. The context makes no synchronous call. - Not here: addresses and other PII (confined to
customer-orderingandshipping-and-tracking, ADR 0006), the customer-visible timeline, and the promise itself. A flagged delivery point changes no route, no ETA and no promise, and the day-of window never reachesdelivery-promise.
This context's pages
| Page | ddd-crew tool / notation | What it answers |
|---|---|---|
| Business Context | Business context (DDD Starter Modelling Process, Understand / Discover) | Why the doorstep is its own context, who acts, what is out of scope |
| Ubiquitous Language | Glossary (Bounded Context Canvas, Ubiquitous Language) | Delivery Wave, Induction, Route, DSP, Delivery Attempt and the neighbour terms used here |
| Core Domain Chart | Core Domain Charts | Why the context is Supporting |
| Bounded Context Canvas | Bounded Context Canvas v5 | Purpose, roles, every inbound and outbound message, decisions, open questions |
| Context Map | Context Mapping | Every upstream and downstream neighbour, with pattern and channel |
| Aggregate Design Canvas | Aggregate Design Canvas v1.1 | DeliveryWave, Route, DeliveryServicePartner, DeliveryPointProfile: states, invariants, commands, events |
| Domain Events | CloudEvents catalogue (event standard) | The eleven published and three consumed events, with full types and payloads |
| Domain Message Flow | Domain Message Flow Modelling | Arrival to doorstep, and the failed-attempt path |
| EventStorming | EventStorming glossary & cheat sheet | Process-level boards with policies, read models and hotspots |
| Use Cases | Application services (hexagonal) | One section per command: trigger, adapter, flow, errors, events, idempotency |
| Class Diagram | UML class diagram + ports and adapters | The proposed Go domain model and package layout |
| Entity Relationship | ER diagram | The proposed Postgres schema, outbox and inbox |
| Sequence Diagrams | UML sequence diagrams | Adapter → use case → aggregate → repository → outbox for every command |
Service and operations
- Service:
IQVO/last-mile-deliveryondevelop(f77cc6a, 2026-10-26): binariescmd/api(REST) andcmd/mcp(read-only MCP), and the console remote inweb/. - Deployment: wired in warehouse-infra develop: a
terraform/apps.yamlentry (database: true,frontend_remote: last_mile_mfe) andhelm-values/last-mile-delivery.yaml(MCP enabled, gateway path/api/mcp/last-mile-delivery). 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 defaultotel-collector.observability.svc.cluster.local:4317;OTEL_SERVICE_NAME). The Tier-2 business counter islast_mile_delivery.package.attempted(unit{package}, ininternal/adapters/outbound/telemetry/attempt_metrics.go), with attributeoutcome=delivered,failedorrejectedandreasonon the outcomes that are not a success. The dashboard queries it aslast_mile_delivery_package_attempted_totalin warehouse-infra'sterraform/dashboards/contexts/last-mile-delivery.json, byoutcome.
Elsewhere
- Read-only MCP server (service ADR 0006):
cmd/mcp, a second binary serving Streamable HTTP on:8090with no auth; it sources this context's own reads and nothing that writes. Three tools:get_route,get_wave_stops,list_waves. The gateway (Kong) exposes it at/api/mcp/last-mile-delivery, rewritten to the server's/mcpmount. - Console remote (service ADR 0007):
web/, a Vite + React Module Federation remote — federation containerlast_mile_mfe, gateway mount/mfes/last-mile-delivery/, dev/preview port4014— read-only screens over the existing REST reads, calling only this context's API. - REST contract (as built, from the service repository):
apis/last-mile-delivery/openapi.yaml, listed under the API reference. - Strategic view: context map, subdomain classification, domain message flows.
- How waves enter a promise: promise model and ADR 0008.
- Station nodes and service areas: node model.