Architecture — Warehouse Master: Administration Console and PII-Backed Address Storage

By Engineering Team•October 9, 2026•6 min read
Metadata Details
System inventory-service — Warehouse Master
Document ID ARCH-2026-INV-003
Author Engineering Team
Status Approved

Implements SR-022, per the decisions in ADR-00037 (lifecycle) and ADR-00019 (why address/contact data lives in pii-service).


Components

Component Language/Runtime Role
WarehousePage.tsx / WarehouseController.ts React (admin UI) List + filter warehouses
pages/WarehouseFormPage.tsx / pages/WarehouseFormController.ts React (admin UI) Create/edit form (Basic Info, Address, Contact sections)
WarehouseRepository.ts React/Axios (admin UI) Sole apiClient consumer for this feature
transport/api/warehouse/ Go (Echo REST) inventory-service’s warehouse controller
service/warehouse/ Go Orchestrates the local Postgres write and the pii-service gRPC call per request
repository/warehouse/ Go (PostgreSQL) "inventory-service".warehouse persistence — code, description, status, is_main, audit fields
pii-service (gRPC client call) Go → Rust (gRPC) UpsertAttributes/GetAttributes/DeleteAttributes against address/contact fields, keyed by the warehouse’s UUID as entity_id, PiiEntityType = "warehouse"

End-to-end flow (A) — Create a warehouse

  1. Admin fills the Basic Info/Address/Contact sections in WarehouseFormPage.tsx (SR-022 FR-02–FR-04) and submits.
  2. WarehouseRepository.ts calls POST /inventory/admin/api/v1/warehouses with the full payload.
  3. transport/api/warehouse/ maps the request into a domain DTO and calls service/warehouse/Create.
  4. service/warehouse/Create inserts the local row (status = DRAFT, tenant_id/created_user_id/created_at from AuthClaims) via repository/warehouse/, receiving back the new warehouse’s UUID (SR-022 FR-06).
  5. In the same request, service/warehouse/Create calls pii-service’s UpsertAttributes with the Address/Contact fields, entity_id = <warehouse UUID>, PiiEntityType = "warehouse".
  6. The combined (local-row + confirmed-PII-write) result is returned to the admin UI; the warehouse now exists in DRAFT.

End-to-end flow (B) — Load and edit a warehouse

  1. WarehouseFormPage.tsx calls GET /inventory/admin/api/v1/warehouses/:id on load.
  2. service/warehouse/Get reads the local row from repository/warehouse/, then calls pii-service’s GetAttributes for the same entity_id/PiiEntityType.
  3. The two results are flattened into one response object — Basic Info from the local row, Address/Contact from pii-service — and returned; they are never persisted together, only combined at this response-assembly point (SR-022 FR-03/FR-04).
  4. On submit, PUT /inventory/admin/api/v1/warehouses/:id repeats flow (A)‘s steps 3–5 as an update rather than an insert (SR-022 FR-07).

End-to-end flow (C) — Publish / Archive / Delete

  1. Publish (POST .../:id/publish): service/warehouse/Publish transitions status from DRAFT or ARCHIVED to PUBLISHED (SR-022 FR-08) — a local-row-only update, no pii-service call.
  2. Archive (PATCH .../:id/archive): service/warehouse/Archive transitions status from PUBLISHED to ARCHIVED (SR-022 FR-09) — local-row-only.
  3. Delete (DELETE .../:id, DRAFT only): service/warehouse/Delete deletes the local row, then calls pii-service’s DeleteAttributes for the same entity_id as a compensating step (SR-022 FR-10).

Why this separates cleanly, and what it does not yet guarantee

Splitting the warehouse row (identity, lifecycle, is_main) from its PII payload (address/contact) means inventory-service’s own schema never has to classify or protect personal data itself — that responsibility stays entirely inside pii-service’s AES-256-GCM-backed EAV store, correlated purely by the warehouse UUID as an opaque entity_id. A reader of "inventory-service".warehouse alone sees no personal data at all.

This flow does not yet guarantee: (a) that every Address/Contact field is actually present and well-formed — that validation runs only in the admin UI’s WarehouseFormController.ts, not in service/warehouse/; (b) that a failed DeleteAttributes call in flow (C)‘s delete step is retried — a local row can be deleted while its pii-service attributes remain orphaned; (c) that an administrator can view or reassign which warehouse is flagged is_main. All three are tracked in Technical Debt — TD-00016.