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. There are three aggregate roots: CatalogItem, Listing and InventoryFeed. Sections 8 and 9 are estimates from the model, not measurements.

CatalogItem​

1. Name​

CatalogItem (proposed Go type catalog.Item), identified by catalogItemId.

2. Description​

The network's own item master entry: title, dimensions, weight and handling flags (hazmat, fragile). It is independent of who ships the item. Vendors refer to it through a listingId, never by their own SKU.

3. State Transitions​

Derived from: model.yaml → contexts[offer-availability].aggregates[CatalogItem].states, .transitions, .commands.

Omitted: nothing. The creation edge from [*] is the CreateCatalogItem command; the model lists no transition out of DISCONTINUED, so it is drawn as terminal.

4. Enforced Invariants​

InvariantEnforced by
Dimensions and weight are positiveCreateCatalogItem → ErrInvalidItemDimensions

5. Corrective Policies​

  • None inside this context. The model does not say whether discontinuing an item suppresses its listings (see Open Questions on the canvas).
  • Neighbours react to CatalogItemDiscontinued: delivery-promise and order-sourcing update their AvailabilityView.

6. Handled Commands​

CommandIssued byInbound adapter
CreateCatalogItemNetwork merchandisingREST POST /catalog-items
DiscontinueItemNetwork merchandisingREST POST /catalog-items/{catalogItemId}/discontinuations

7. Created Events​

EventRaised whenFull CloudEvents type
CatalogItemCreatedafter CreateCatalogItem commitscom.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemCreated
CatalogItemDiscontinuedafter DiscontinueItem commitscom.retailnetwork.commerce.offer-availability.catalogitem.CatalogItemDiscontinued

8. Throughput​

Estimate (model: "low"). Writes come from merchandising, one item at a time. Reads (GET /catalog) dominate.

9. Size​

Estimate (model: "~10^6 items"). One row of scalar fields per item, two events in a lifetime.

Listing​

1. Name​

Listing (listing.Listing), identified by listingId. Natural key (catalogItemId, nodeId).

2. Description​

One catalogue item offered from one node, with the node's claimed available quantity, its basis and the feed it came from. It holds one value object, Availability{availableQty, basis(PHYSICAL|THROUGHPUT_CONSTRAINED|UNKNOWN), asOf, feedId}.

3. State Transitions​

Derived from: model.yaml → contexts[offer-availability].aggregates[Listing].states, .transitions, .commands, .value_objects.

Omitted: the model gives no initial state. The page draws CreateListing into LIVE; by the invariant "a listing on a non-ACTIVE node is SUPPRESSED", a listing created for a node that is not ACTIVE should start SUPPRESSED. That case is a model gap and is not drawn. No terminal state exists in the model.

4. Enforced Invariants​

InvariantEnforced by
availableQty >= 0ApplyAvailability → ErrNegativeAvailability
An update with asOf not after the current asOf is ignored (monotonic per listing)ApplyAvailability → ErrStaleAvailability (the line is ignored, not applied)
A listing on a non-ACTIVE node is SUPPRESSEDRestoreListing → ErrNodeNotSellable (checked against the local NodeStatusView)
One listing per (catalogItemId, nodeId)CreateListing → ErrDuplicateListing (backed by a unique key)

5. Corrective Policies​

  • SuppressOnNodeUnavailable: on NodeSuspended or NodeRetired, suppress every listing of the node; on NodeActivated, restore those suppressed for that reason.
  • FullFeedZeroing: a full feed sets availableQty=0 on every listing of the node it omits.
  • Neighbours: delivery-promise and order-sourcing fold every listing event into their AvailabilityView; vendor-connectivity adds each new listing to its ListingView.

6. Handled Commands​

CommandIssued byInbound adapter
CreateListingNetwork merchandisingREST POST /listings
ApplyAvailabilityApplyInventoryFeed use case, once per feed line and once per listing zeroed by FullFeedZeroingnone of its own (inside POST /inventory-feeds)
SuppressListingSuppressOnNodeUnavailable policyKafka consumer of retailnetwork.node-topology.events
RestoreListingSuppressOnNodeUnavailable policyKafka consumer of retailnetwork.node-topology.events

7. Created Events​

EventRaised whenFull CloudEvents type
ListingCreatedafter CreateListing commitscom.retailnetwork.commerce.offer-availability.listing.ListingCreated
ListingAvailabilityChangedafter ApplyAvailability changes the Availability (not when the line is stale)com.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChanged
ListingSuppressedafter SuppressListing commits; carries reasoncom.retailnetwork.commerce.offer-availability.listing.ListingSuppressed
ListingRestoredafter RestoreListing commitscom.retailnetwork.commerce.offer-availability.listing.ListingRestored

8. Throughput​

Estimate (model: "high: one update per feed line; bursty"). Every feed line is a write on one listing. Contention on one listing is low (one node, one vendor), but a full feed writes many listings of one node at once. Proposed optimistic concurrency: a version per listing.

9. Size​

Estimate (model: "items x nodes, sparse"). One row per listing with the current Availability only; history lives in the events, not on the row.

InventoryFeed​

1. Name​

InventoryFeed (feed.InventoryFeed), identified by feedId.

2. Description​

One vendor inventory submission for one node, full or partial (fullUpdate), applied atomically. vendor-connectivity owns the Vendor API transaction that carries it; this aggregate records that the feed was received and whether it was applied.

3. State Transitions​

Derived from: model.yaml → contexts[offer-availability].aggregates[InventoryFeed].states, .transitions, .commands.

Omitted: nothing. Every edge belongs to the one command: the feed is recorded RECEIVED and resolved in the same apply. APPLIED and SUPERSEDED are terminal; a FAILED feed may be resubmitted (FAILED → RECEIVED, ADR 0002 A11).

4. Enforced Invariants​

InvariantEnforced by
Every line names a listing of the feed's nodeApplyInventoryFeed → ErrListingNotOnNode (the feed ends FAILED, no line applied)
A feed is applied at most onceApplyInventoryFeed → ErrFeedAlreadyApplied (an APPLIED or SUPERSEDED feedId; a FAILED one may be sent again)
(carried from Listing) every line's availableQty >= 0ApplyAvailability → ErrNegativeAvailability (proposed: the feed ends FAILED, because it is applied atomically)

5. Corrective Policies​

  • FullFeedZeroing: when fullUpdate is true, every listing of the node the feed omits gets availableQty=0 in the same apply.
  • Neighbours: node-performance records an observation from InventoryFeedApplied (feed freshness). vendor-connectivity turns the call's answer into its Submission outcome (SUCCESS or FAILURE).

6. Handled Commands​

CommandIssued byInbound adapter
ApplyInventoryFeedvendor-connectivity (processing a vendor SubmitInventory)REST POST /inventory-feeds (in-org)

7. Created Events​

EventRaised whenFull CloudEvents type
InventoryFeedAppliedafter the feed reaches APPLIEDcom.retailnetwork.commerce.offer-availability.inventoryfeed.InventoryFeedApplied

A FAILED or SUPERSEDED feed raises no event.

8. Throughput​

Estimate (model: "medium: per vendor node every few minutes"). Proposed assumption: feeds for one node arrive one at a time; two concurrent feeds for the same node are serialised by the listing version check.

9. Size​

Estimate (model: "retained 30 days"). One header row plus one row per line, kept 30 days; one event per applied feed.

Read models​

Read modelSource eventsUsed forWhy it is not an aggregate
NodeStatusViewnode-topology NodeRegistered, NodeActivated, NodeSuspended, NodeRetiredErrNodeNotSellable on RestoreListing; deciding which listings SuppressOnNodeUnavailable acts onIt holds no rule of its own; it is a local copy of node-topology's facts, rebuilt from the topic, and this context never changes it by command.

Packaging hierarchy and owner​

Built, ADR 0009 as realized by offer-availability ADR 0006 (catalogue GTIN and packaging hierarchy, and the optional owner of a listing). This section is the delta the seller-inbound design added to this page; where the service decided differently, the text below says so.

CatalogItem gains optional Identifiers{gtin} (the each-level GTIN) and a PackagingHierarchy of PackLevelDef{level, gtin, childGtin?, unitsPerPack, dimsMm?, grossWeightG?, active}. New commands: DeclarePackaging, RetirePackLevel. New events: CatalogItemPackagingDeclared, CatalogItemPackLevelRetired.

InvariantError
A GTIN is 8, 12, 13 or 14 digits with a valid mod-10 check digit, stored as 14 digitsErrInvalidGTIN
A GTIN identifies exactly one (item, level)ErrGtinAlreadyAssigned
Once a level is active its unitsPerPack never changes for that GTIN: a new quantity is a new GTIN at that level and a re-declaration of every level above, and the old level is retiredErrPackQuantityImmutable
A level's child level is lower than the level itselfErrPackLevelOrder
unitsPerPack is at least 2 for every level above EACH and 1 for EACHErrInvalidPackQuantity
Variable-measure GTINs (indicator digit 9) are rejected (as built, as an invalid GTIN)ErrInvalidGTIN

Listing gains an optional OwnerRef. The invariant ErrDuplicateListing becomes "one listing per (catalogItemId, nodeId, ownerRef)"; an absent ownerRef is its own owner. The policy SegregatedByOwner states that availability is per listing and never summed, merged or moved between owners. A listing whose owner is a suspended seller is SUPPRESSED with reason OWNER_SUSPENDED, read from the local SellerStatusView fed by SellerSuspended and SellerReinstated; a listing shows its highest active cause, DISCONTINUED > NODE_NOT_SELLABLE > OWNER_SUSPENDED (service ADR 0013, gap G48, closed). Received seller stock (InboundShipmentReceived received lines) creates the owner's listing at availability 0 / UNKNOWN (service ADR 0014, gap G51, closed). ADR 0013 first recorded this rule 8 as blocked on the producer payload; ADR 0014 supersedes that and builds rule 8 as written, so ADR 0014 is the current state.