Skip to main content

Business Context

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.

The business problem​

A promise is only as good as its last leg. delivery-promise quotes a delivery date only when it can show a witness path: a node cutoff, the scheduled departures, and a delivery wave at the destination station (WitnessPath{nodeId, pickupDepartureId, legs[departureId], deliveryWaveId}). order-sourcing chooses the real path the same way (Candidate{..., deliveryWaveId, ...}). Both need to know, ahead of time and without a call, three things about every station:

  • when a package must be at the station to make a given wave (the induct cutoff);
  • when that wave delivers (the delivery window);
  • how many more stops the wave can take (its stop capacity).

Last-Mile Delivery is the context that owns those facts and keeps them true. It also does the work behind them. It inducts arriving packages into waves, plans van routes for delivery service partners, and records what happened at each door.

The model states the context's purpose as:

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.

Actors​

ActorKind (model external)What they do here
Station plannerpersonSchedules waves, closes induction, plans routes and dispatches waves (REST /waves, /routes)
Delivery service partner driver appexternal organisation (driver app)Starts a route and records each delivery attempt (REST /routes/{routeId}/starts, /routes/{routeId}/attempts)
linehaul-transportationsibling contextTells the station that a load has arrived, with its tracking numbers (LoadArrived)
node-topologysibling contextTells the station which nodes exist and which postal prefixes it serves (NodeRegistered, ServiceAreaAssigned)
delivery-promise, order-sourcingsibling contextsRead the published waves to quote and source on them
shipping-and-trackingsibling contextTurns out-for-delivery and attempt facts into the customer-visible timeline

Decisions this context makes​

The model's business_decisions:

  1. A package joins the earliest wave whose induct cutoff it arrived before and that has stop capacity left (policy InductOnArrival, invariants ErrInductionClosed, ErrWaveFull).
  2. A route never exceeds its van's stop capacity (ErrRouteOverCapacity).
  3. A package is delivered at most once; a failed attempt returns it to the station for the next wave (ErrAlreadyDelivered, policy RetryNextWave; after three failures the package is returned to sender).

Two more rules follow from the aggregates: a wave's times are ordered (inductCutoffAt < windowStart < windowEnd, ErrInvalidWaveTimes), and an attempt is recorded only on a route that is out for delivery (ErrRouteNotStarted).

Why it is its own context​

  • Different clock, different capacity unit. The middle mile counts packages on departures. The last mile counts stops in waves and in vans. Mixing them would put two capacity rules in one model.
  • Different collaborators. DSPs are independent businesses with their own vans and drivers. Contracting them and keeping each route within a van's capacity is a station concern.
  • The promise needs a stable, published fact. Wave capacity is consumed by two Core contexts as an event-fed read model. A context that owns waves can publish them as a Published Language, and it can change how it plans routes without touching the promise.

Relation to the real fulfillment networks​

The network is modelled on a large-scale logistics network with network-operated delivery stations and independent delivery partners. The facts behind that, with citations, are on public fulfillment-network research. The vendor platform API surface that a vendor sees, and which never exposes the last mile, is mapped on the vendor platform API surface map. This page does not restate either. The model makes no claim about any real company's internal service names.

Deliberately out of scope​

Out of scopeWhere it lives
Ship-to addresses and any other PIIcustomer-ordering and shipping-and-tracking only (ADR 0006)
The customer-visible timeline, PackageDelivered, returns to sender as a journey stateshipping-and-tracking (PackageJourney)
Which delivery station serves a postal prefixnode-topology (ServiceArea)
Middle-mile departures and loadslinehaul-transportation
Quoting, holding and judging promisesdelivery-promise
Customer returns routing to a returns centrefuture context customer-returns
Customer notifications on deliveryfuture context customer-notification
Anything in the warehouse-systems fleetNo edge. A delivery station is network-operated; the fleet's facility-layout DELIVERY_STATION row is a reference mirror only (model fleet_site_role_mapping). The only seam between the organisations is the Vendor API, which this context does not touch