02 — System Diagram

🔍 Open the Interactive Diagram Viewer — pan, mouse-wheel zoom, fit-to-screen, full-screen, per-area tabs, the full ERD, and a focus mode that draws one model and its neighbours at a chosen depth. StockLocation is the hub table, so its links can be hidden to declutter the overview.

Regenerate the viewer after any DSL, menu_config.yaml or diagram_config.yaml change: python scripts/build_diagram_viewer.py inventory.

Stock and receiving

flowchart TD
  LOC[StockLocation]
  POL[InventoryPolicy]
  BAL[StockBalance]
  TX[InventoryTransaction]
  RES[InventoryReservation]
  GR[GoodsReceipt]
  GRL[GoodsReceiptLine]
  INSP[ReceiptInspection]
  SC[StockCount]
  SCL[StockCountLine]

  LOC --> POL
  LOC --> BAL
  LOC --> TX
  LOC --> RES
  LOC --> GR
  GR --> GRL
  GRL --> INSP
  LOC --> SC
  SC --> SCL
  TX -. updates .-> BAL
  RES -. reserve / release .-> TX
  GRL -. receipt / quarantine .-> TX

Answering a material requirement (R1 / R2)

sequenceDiagram
  participant W as Work Management
  participant O as Orchestrator
  participant I as Inventory
  participant P as Purchasing
  W->>O: work.material_requirement_created (MR-…, item, quantity)
  O->>I: deliver
  I->>I: find the location with the most available stock
  alt enough stock (R2)
    I->>I: reservation RES-… reserved, balance reserved += qty, transaction "reserve"
    I->>O: inventory.item_reserved
    O->>W: deliver
  else not enough (R1)
    I->>I: reservation RES-… unavailable, nothing held
    I->>O: inventory.item_unavailable
    O->>W: deliver
    O->>P: deliver
  end

The reservation, the balance change, the ledger entry and the outgoing event are one database transaction; a repeated delivery of the same message is answered from the record of the first and changes nothing.

Reservation lifecycle

stateDiagram-v2
  [*] --> requested
  requested --> reserved: stock available
  requested --> unavailable: not enough stock
  reserved --> issued
  reserved --> released: released / requirement cancelled
  unavailable --> released: requirement cancelled
  issued --> [*]
  released --> [*]