Skip to main content

Aggregate Design Canvas

As built

Derived from network/model/model.yaml. This context's service is built (IQVO/seller-inbound, designed by ADR 0009); the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses. Where the model left a choice open, the service's own ADRs 0002 to 0005 record what it does.

Following the ddd-crew Aggregate Design Canvas v1.1. Three aggregate roots: SellerAccount, InboundPlan and InboundShipment (with the Carton entity). Go packages (as built): internal/domain/seller, internal/domain/inboundplan and internal/domain/inboundshipment, with the read-model value types in internal/domain/network and the GS1 value objects in internal/domain/shared/gs1.

SellerAccount​

Description. A seller organisation and the owner of the stock it sends. Identified by sellerId; ownerRef equals it.

InvariantError
sellerId is uniqueErrSellerExists
A suspended seller creates no plan, shipment or carton and ships nothingErrSellerSuspended

Commands: OnboardSeller, SuspendSeller, ReinstateSeller. Events: SellerOnboarded, SellerSuspended, SellerReinstated. Throughput: rare. Size: tens to thousands.

InboundPlan​

Description. What a seller intends to send to one node, in eaches, and how it will pack it. Value objects: PackingOption(INDIVIDUAL|CASE_PACKED), PlanLine{catalogItemId, gtin, qtyEaches, unitVolumeDm3?}. As built (service ADR 0015) the plan also carries PlacementOption(SELLER_SPLIT|NETWORK_SPLIT), for NETWORK_SPLIT only the recorded RedistributionLine{nodeId, lineNo, qtyEaches} list and PlacementFeeBasis{basis, month, dm3, nodeIds} (a fact, never a charge), and capacityEnforced: whether the monthly capacity gate was actually applied.

InvariantError
Destination node is ACTIVE with the INBOUND capability (and accepts pallets when palletised)ErrNodeCannotReceive
The seller is ACTIVE when the plan is created and confirmedErrSellerSuspended
1 to 500 lines, one per catalogue item; every line names a catalogItemId, a valid GTIN and qtyEaches > 0 (whether the item is live is not checked: no CatalogItemCreated/CatalogItemDiscontinued is consumed)ErrValidation
unitVolumeDm3, when declared, is an integer from 1 to 100000 cubic decimetresErrValidation
Monthly capacity gate, at CreateInboundPlan: when the node declares a monthly volume and every line declares unitVolumeDm3, the seller's reserved volume for the (month, node) plus the plan's volume never exceed the node's monthly volume times the seller's tier factor; either side unknown allows the plan and records capacityEnforced: falseErrInboundCapacityExceeded
The destination of a NETWORK_SPLIT plan is an ACTIVE INBOUND_CROSS_DOCKErrNetworkSplitDestination
The region of a NETWORK_SPLIT plan's destination holds at least one ACTIVE FULFILLMENT_CENTERErrNetworkSplitUnavailable

Commands: CreateInboundPlan, ConfirmInboundPlan, CancelInboundPlan. Events: InboundPlanConfirmed. Cancelling raises no event. Throughput: low to medium. Size: one row plus lines.

InboundShipment and Carton​

Description. One physical consignment of a plan to one node. The Carton entity is one SSCC logistic unit with its contents. Value objects: Sscc, Gtin, CartonKind(HOMOGENEOUS_CASE|MIXED), CartonContent{catalogItemId, gtin, qtyEaches, lot?, expiry?}, CartonReceiptStatus(RECEIVED|MISSING|UNEXPECTED|DAMAGED), Label{sscc, labelRef}.

InvariantError
A HOMOGENEOUS_CASE carton holds exactly one item, one GTIN and one quantityErrCasePackNotUniform
A HOMOGENEOUS_CASE carton's qtyEaches equals unitsPerPack of the item's declared, active CASE levelErrCaseQtyMismatchesGtin
Carton gross weight within the node's maxCartonWeightGErrCartonOverweight
Carton dimensions within the node's maxCartonDimsMmErrCartonOversize
An SSCC is unique network-wideErrSsccNotUnique
An SSCC has 18 digits and a valid mod-10 check digitErrInvalidSscc
At labelling, when this is the plan's only shipment, the eaches per item and GTIN over its cartons equal the confirmed plan's lines (every line exactly); with several shipments the plan line is a cap checked on AddCarton (every item on the plan, total over all the plan's shipments within the line)ErrCartonContentsMismatchPlan
Node ACTIVE with INBOUND when created and when shippedErrNodeCannotReceive
Seller ACTIVE when created, labelled and shippedErrSellerSuspended
No ship without a label on every cartonErrShipmentNotLabelled

Commands: CreateInboundShipment, AddCarton, LabelShipment, ShipInboundShipment, RecordInboundReceipt. Events: InboundShipmentLabelled, InboundShipmentShipped, InboundShipmentReceived, InboundDiscrepancyRecorded, SellerComplianceViolationRecorded. Throughput: medium; cartons dominate. Size: one row per shipment, its cartons and contents in a JSONB column (as built), retained for audit.

An aggregate this size is a consistency choice: carton checks need the whole carton set (uniform quantity, plan totals), so the cartons are children, not aggregates. A shipment of thousands of cartons is the cost; splitting it into several shipments of one plan is the relief valve (gap G50).

Read models​

Read modelFed by
NodeInboundViewNodeRegistered, NodeOperationalProfileDeclared, NodeActivated, NodeSuspended, NodeRetired
CatalogPackagingViewCatalogItemPackagingDeclared, CatalogItemPackLevelRetired
InboundCapacityAllocationsNo event: write-side bookkeeping keyed (seller, YYYY-MM month, node), the cubic decimetres the seller's DRAFT and CONFIRMED plans promise to the node; CreateInboundPlan reserves, CancelInboundPlan releases; read by GET /sellers/{sellerId}/capacity-allocations (service ADR 0015)
SellerScorecardNo event: this service's own facts (one row per closed shipment, one per discrepancy or violation), written with each applied receipt; read by GET /sellers/{sellerId}/scorecard (service ADR 0005)