Skip to main content

Aggregate Design 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 Aggregate Design Canvas v1.1. The model gives this context four aggregate roots: Node, Lane, ServiceArea and Region. Each section below is one canvas.

Node​

1. Name​

Node (proposed package internal/domain/node), identified by nodeId.

2. Description​

One physical building in the network: its type, operator, region, time zone and declared operational profile. It holds no child entity. Its value objects are:

Value objectFields
OperationalProfileprofileRevision, timezone, operatingHoursByDay, holidays[], handlingTime, cutoffs[CutoffSlot], throughputCap, sortDwellMinutes (sort centres and air hubs only), declaredBy (VENDOR or NETWORK_OPS), declaredAt
operatingHoursByDay{monday … sunday: {start, end}}, times as HH:mm; a missing day is closed
holidays[]ISO dates; the node is closed all day
CutoffSlotlocalTime (HH:mm), days[] (default: every operating day), maxOrders (optional)
ThroughputCapvalue (integer above zero), timeUnit (HOUR or DAY), unit = ORDER
NodeCapabilitiesoutbound, inbound, returns, sort, lastMile, air
GeoLocationpostalCode, countryCode, lat, lon
VendorRefvendorId, vendorNodeCode

3. State Transitions​

Derived from: model.yaml → contexts[node-topology].aggregates[Node].states, .transitions, .commands, .invariants.

Omitted: the model lists no transition into PROPOSED; it is drawn as the entry state because it is the only state with no incoming transition and RegisterNode is the only creating command. DeclareOperationalProfile does not change the state, so it is a note rather than an edge; it is refused on a RETIRED node by ErrNodeRetired.

4. Enforced Invariants​

InvariantEnforced by
The operator must be allowed for the node type; parcel nodes are NETWORK-operatedRegisterNode → ErrOperatorNotAllowedForNodeType
vendorNodeCode is unique per vendorRegisterNode → ErrVendorNodeCodeTaken (spans all Node aggregates; backed by a unique index, see Entity Relationship)
The profile revision strictly increasesDeclareOperationalProfile → ErrStaleProfileRevision
A FULFILLMENT_CENTER profile declares at least one cutoff and a handlingTime above zero before activation, and every later revision of an ACTIVE FULFILLMENT_CENTER keeps bothActivateNode, DeclareOperationalProfile → ErrIncompleteOperationalProfile
Every day of a cutoff falls inside the operating hours of that dayDeclareOperationalProfile → ErrCutoffOutsideOperatingHours
The node's regionId names a defined RegionRegisterNode → ErrUnknownRegion
subtype, when given, is one of the node type's subtypes in node_typesRegisterNode → ErrSubtypeNotAllowed
sortDwellMinutes is declared only by SORTATION_CENTER and AIR_HUB nodesDeclareOperationalProfile → ErrSortDwellNotAllowed
RETIRED is terminalActivateNode, SuspendNode, RetireNode, DeclareOperationalProfile → ErrNodeRetired

5. Corrective Policies​

  • DefaultCapabilitiesByType (this context): node capabilities are derived from the node type, never typed by hand. RegisterNode sets NodeCapabilities from node_types.
  • SuspendedEndpointsUnusable (this context): suspending or retiring a node closes nothing. Its OPEN lanes and ASSIGNED service areas stay as they are, and consumers treat them as unusable while the node is not ACTIVE (they react to NodeSuspended and NodeRetired).
  • SuppressOnNodeUnavailable (offer-availability): on NodeSuspended or NodeRetired every listing of the node is suppressed; on NodeActivated the listings suppressed for that reason are restored.
  • PickupFromCutoffs (linehaul-transportation): on NodeOperationalProfileDeclared the pickup departures for every cutoff of the horizon are (re)generated; on NodeSuspended or NodeRetired future pickups are cancelled.
  • RepromiseOnRisk (delivery-promise): a cancelled departure on a promise's witness path, for example a pickup cancelled after a suspension, makes the promise be recomputed and revised.
  • Demand only while ACTIVE (business decision 2): delivery-promise and order-sourcing read node status from their own NodeProfileView, so a node that is not ACTIVE stops being a witness or a candidate without any call to this context.

6. Handled Commands​

CommandInbound routeIssued by
RegisterNodePOST /nodesvendor-connectivity (vendor node), network-ops planner (network node)
DeclareOperationalProfilePUT /nodes/{nodeId}/operational-profilevendor-connectivity (declaredBy VENDOR), network-ops planner (declaredBy NETWORK_OPS)
ActivateNodePOST /nodes/{nodeId}/activationsnetwork-ops planner
SuspendNodePOST /nodes/{nodeId}/suspensionsnetwork-ops planner
RetireNodePOST /nodes/{nodeId}/retirementsnetwork-ops planner

7. Created Events​

EventRaised whenFull CloudEvents type
NodeRegisteredRegisterNode is saved (state PROPOSED)com.retailnetwork.logistics.node-topology.node.NodeRegistered
NodeOperationalProfileDeclareda new profile revision is savedcom.retailnetwork.logistics.node-topology.node.NodeOperationalProfileDeclared
NodeActivatedActivateNode is saved (from PROPOSED or SUSPENDED)com.retailnetwork.logistics.node-topology.node.NodeActivated
NodeSuspendedSuspendNode is savedcom.retailnetwork.logistics.node-topology.node.NodeSuspended
NodeRetiredRetireNode is savedcom.retailnetwork.logistics.node-topology.node.NodeRetired

8. Throughput​

Estimate (model): low, tens of writes per day. Contention on one node is practically nil: a vendor's profile declaration and a planner's state change can race, which an optimistic-concurrency version check resolves.

9. Size​

Estimate (model): one row plus one profile row per revision; about 10^3 nodes. Events per node over its life: one NodeRegistered, one NodeOperationalProfileDeclared per revision, and a handful of activations, suspensions and one retirement.

Lane​

1. Name​

Lane (proposed package internal/domain/lane), identified by laneId.

2. Description​

A directed, mode-specific connection between two nodes with a nominal transit time. Its scheduled departures belong to linehaul-transportation. Value objects: NominalTransit{minutes} and LaneMode (GROUND or AIR). As built (node-topology ADR 0014) the lane carries costPerUnitCents: the planner's declared marginal cost of moving one package-unit across the lane on one departure, an integer of cents from 0 to 10000000, default 0, with no currency field. It is a declaration, never a quote, an invoice or a measurement; 0 is a legal declaration, and a lane never declared on also reads 0 but publishes nothing. As built (node-topology ADR 0018) the lane also carries emissionPerUnitG: the planner's declared carbon emission of moving one package-unit across the lane on one departure, an integer of grams of CO2-equivalent from 0 to 10000000, default 0. It is a declaration, never a measurement; 0 is a legal declaration, and a lane never declared on also reads 0 but publishes nothing.

3. State Transitions​

Derived from: model.yaml → contexts[node-topology].aggregates[Lane].states, .transitions, .commands.

Omitted: nothing. There is no reopen; a new lane is opened instead.

4. Enforced Invariants​

InvariantEnforced by
Origin and destination differOpenLane → ErrLaneLoop
(origin type, destination type) is an allowed pair (model lane_rules.allowed)OpenLane → ErrLaneTypePairNotAllowed
Both ends are ACTIVE when openingOpenLane → ErrLaneEndpointNotActive (reads both Node aggregates)
At most one OPEN lane per (origin, destination, mode)OpenLane → ErrDuplicateLane (spans Lane aggregates; backed by a partial unique index)
A declared cost is an integer from 0 to 10000000 centsDeclareLaneCost → ErrValidation (422 validation-failed)
A cost is declared on an OPEN lane onlyDeclareLaneCost → ErrIllegalTransition (409 illegal-transition)
A declared emission is an integer from 0 to 10000000 grams of CO2-equivalentDeclareLaneEmission → ErrValidation (422 validation-failed)
An emission is declared on an OPEN lane onlyDeclareLaneEmission → ErrIllegalTransition (409 illegal-transition)

5. Corrective Policies​

  • SuspendedEndpointsUnusable (this context, see Node): the OPEN lanes of a suspended or retired node are not closed; consumers treat them as unusable while an endpoint is not ACTIVE.
  • Consumers react: linehaul-transportation refuses to schedule on a closed lane (ErrLaneClosed, its own invariant) and keeps a LaneView; delivery-promise and order-sourcing keep LaneView and NetworkGraphView.

6. Handled Commands​

CommandInbound routeIssued by
OpenLanePOST /lanesnetwork-ops planner
CloseLanePOST /lanes/{laneId}/closuresnetwork-ops planner
DeclareLaneCostPOST /lanes/{laneId}/cost-declarationsnetwork-ops planner
DeclareLaneEmissionPOST /lanes/{laneId}/emission-declarationsnetwork-ops planner

7. Created Events​

EventRaised whenFull CloudEvents type
LaneOpenedOpenLane is savedcom.retailnetwork.logistics.node-topology.lane.LaneOpened
LaneClosedCloseLane is savedcom.retailnetwork.logistics.node-topology.lane.LaneClosed
LaneCostDeclaredDeclareLaneCost is saved (every declaration)com.retailnetwork.logistics.node-topology.lane.LaneCostDeclared
LaneEmissionDeclaredDeclareLaneEmission is saved (every declaration)com.retailnetwork.logistics.node-topology.lane.LaneEmissionDeclared

8. Throughput​

Estimate (model): low.

9. Size​

Estimate (model): about 10^4 lanes. Two events per lane over its life.

ServiceArea​

1. Name​

ServiceArea (proposed package internal/domain/servicearea), identified by postalPrefix.

2. Description​

Which delivery station (and therefore which region) serves a postal prefix, versioned by assignmentVersion.

3. State Transitions​

Derived from: model.yaml → contexts[node-topology].aggregates[ServiceArea].states, .transitions, .initial_state, .commands, .invariants.

The model gives ServiceArea one state, ASSIGNED, which is also its initial state, and one transition: ASSIGNED → ASSIGNED on AssignServiceArea. A prefix is reassigned to another station under a higher assignmentVersion (ErrStaleAssignmentVersion). There is no unassign.

Omitted: nothing.

4. Enforced Invariants​

InvariantEnforced by
The assigned node is an ACTIVE DELIVERY_STATIONAssignServiceArea → ErrNotADeliveryStation (reads the Node aggregate)
The assignment version strictly increasesAssignServiceArea → ErrStaleAssignmentVersion
The assigned region is a defined Region and matches the station's regionAssignServiceArea → ErrUnknownRegion (reads the Region and Node aggregates)

5. Corrective Policies​

  • SuspendedEndpointsUnusable (this context, see Node): the ASSIGNED service areas of a suspended or retired station are not unassigned; consumers treat them as unusable while the station is not ACTIVE.
  • The region of the prefix is published in ServiceAreaAssigned and must match the station's regionId.
  • Consumers react: delivery-promise (RegionAndServiceAreaView), order-sourcing (NetworkGraphView), last-mile-delivery (StationView).

6. Handled Commands​

CommandInbound routeIssued by
AssignServiceAreaPUT /service-areas/{postalPrefix}network-ops planner

7. Created Events​

EventRaised whenFull CloudEvents type
ServiceAreaAssignedeach saved assignment versioncom.retailnetwork.logistics.node-topology.servicearea.ServiceAreaAssigned

8. Throughput​

Estimate (model): low; bulk at network redesign.

9. Size​

Estimate (model): about 10^4 prefixes. One event per assignment version.

Region​

1. Name​

Region (proposed package internal/domain/region), identified by regionId.

2. Description​

A largely self-sufficient partition of the network. Nodes and service areas belong to exactly one region. A region has a code and a name.

3. State Transitions​

Derived from: model.yaml → contexts[node-topology].aggregates[Region].states, .commands.

DEFINED is the initial state. Omitted: nothing. The model has no rename and no removal.

4. Enforced Invariants​

InvariantEnforced by
The region code is uniqueDefineRegion → ErrRegionCodeTaken (spans Region aggregates; backed by a unique index)

5. Corrective Policies​

None.

6. Handled Commands​

CommandInbound routeIssued by
DefineRegionPOST /regionsnetwork-ops planner

7. Created Events​

EventRaised whenFull CloudEvents type
RegionDefinedDefineRegion is savedcom.retailnetwork.logistics.node-topology.region.RegionDefined

8. Throughput​

Estimate (model): rare.

9. Size​

Estimate (model): single digits (eight in the reference network). One event per region.

Read models​

The model gives this context no read model (read_models: []). The four query routes (GET /nodes/{nodeId} is GetNode, GET /nodes?type=&region=&status= is ListNodes, GET /lanes?origin=&destination= is ListLanes, GET /service-areas/{postalPrefix} is ResolveServiceArea) read the aggregates' own tables directly. That is enough here because:

  • the write rate is low, so the query load never contends with writes;
  • each query is a lookup or a filter on one aggregate type, never a join of facts from several contexts;
  • the neighbours that need these facts on a hot path keep their own event-fed read models (NodeProfileView, LaneView, RegionAndServiceAreaView, NetworkGraphView, NodeStatusView, VendorNodeView, StationView), so this context is never on that path.

The three uniqueness rules that span aggregates (ErrVendorNodeCodeTaken, ErrDuplicateLane, ErrRegionCodeTaken) are enforced by unique indexes in the same database, not by a read model and not by a bigger aggregate.

Inbound limits and the INBOUND capability​

Built, ADR 0009 as realized by node-topology ADR 0007 (inbound limits on the operational profile). This section is the delta the seller-inbound design added to this page; where the service decided differently, the text below says so. Not built: the INBOUND capability of FULFILLMENT_CENTER and the capability gate ErrInboundLimitsNotAllowed; the service value-checks the limits (ErrValidation) on any node type (gap G64).

  • OperationalProfile gains an optional inbound{maxCartonWeightG, maxCartonDimsMm{l,w,h}, acceptsPallets, requiresSscc}. Like the rest of the profile it is versioned by profileRevision and never edited in place.
  • Invariant ErrInboundLimitsNotAllowed (422 inbound-limits-not-allowed, service ADR 0015): inbound is declared only by nodes whose type has the INBOUND capability. DeclareOperationalProfile checks it before the value checks; a stored revision that already carries limits on another type stays restorable. When the type has INBOUND, the limits are value-checked with ErrValidation (422 validation-failed, service ADR 0007): every number set is a positive integer, the three maxCartonDimsMm edges are all-or-none, and an inbound that declares nothing is refused.
  • FULFILLMENT_CENTER has the INBOUND capability as well as OUTBOUND, because a seller's cartons are received at the building that stores them; INBOUND_CROSS_DOCK already had it. As built (service ADR 0015) GET /nodes/{nodeId} reports inbound: true for every fulfillment centre, derived on read, so no data moved (gap G64, closed).
  • NodeOperationalProfileDeclared carries inbound. seller-inbound keeps it in NodeInboundView and checks carton weight and size against it; node-topology does not know sellers.