SR-022 — Warehouse Master: Administration System Requirements

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

Traces back to BRD-021.

This document covers inventory-service’s WarehouseService (Go, PostgreSQL, Echo REST, /inventory/admin/api/v1/warehouses) and the ui-admin-application’s features/warehouse/ admin UI that drives it. It does not restate SR-019’s stock-balance mechanics or SR-020’s stock-entry mechanics, both of which reference a warehouse by ID but assume this document’s records already exist.


Functional Requirements

Warehouse List Page (WarehousePage.tsx / WarehouseController.ts, route /warehouses)

FR-01 (List & Filter): The list page retrieves every warehouse for the caller’s tenant via GET /inventory/admin/api/v1/warehouses, displaying each row’s warehouse code, lifecycle status (as a color-coded status dot), and description. A text-search box and a status-value dropdown filter the list; no column sort is offered.

Warehouse Entry/Edit Form (pages/WarehouseFormPage.tsx / pages/WarehouseFormController.ts, route /warehouses/new and /warehouses/:id/edit)

FR-02 (Basic Info Section): The form’s Basic Info section captures warehouse_code (required) and description. warehouse_code must be unique per tenant, enforced by a unique constraint on "inventory-service".warehouse.

FR-03 (Address Section, PII-Service-Backed): The form’s Address section (address1, address2, city, place, land_mark, zip_code, country, state) is never persisted in inventory-service’s own warehouse table. On save, these fields are sent via gRPC UpsertAttributes to pii-service, correlated by the warehouse’s own UUID as entity_id with PiiEntityType = "warehouse", per ADR-00019. On load, GetAttributes is called and the returned values are flattened back into the form alongside the local row’s fields — the two are never persisted together.

FR-04 (Contact Section, PII-Service-Backed): The form’s Contact section (contact_person, contact_number1, contact_number2) follows the identical UpsertAttributes/GetAttributes path as FR-03, under the same entity_id/PiiEntityType.

FR-05 (Client-Side Field Validation): WarehouseFormController.ts enforces all Basic Info/Address/Contact fields as required, plus phone-number and pincode format checks on the Contact/Address fields. (Gap — the backend only validates warehouse_code non-empty; every other field’s “required”/format rule is enforced on the client only, see Technical Debt — TD-00016.)

FR-06 (Create): Submitting a new warehouse calls POST /inventory/admin/api/v1/warehouses, inserting the local row with status = DRAFT, then performing the pii-service upsert from FR-03/FR-04 against the newly-created warehouse’s UUID.

FR-07 (Update): Submitting an edit calls PUT /inventory/admin/api/v1/warehouses/:id, updating the local row’s Basic Info fields and re-running the pii-service upsert for Address/Contact.

FR-08 (Publish): A DRAFT or ARCHIVED warehouse is made available for use via POST /inventory/admin/api/v1/warehouses/:id/publish, transitioning status to PUBLISHED, per the lifecycle decided in ADR-00037.

FR-09 (Archive): A PUBLISHED warehouse is retired via PATCH /inventory/admin/api/v1/warehouses/:id/archive, transitioning status to ARCHIVED. No other transition reaches ARCHIVED.

FR-10 (Delete, Draft-Only): DELETE /inventory/admin/api/v1/warehouses/:id is permitted only while status = DRAFT; it deletes the local row and compensates by deleting the correlated pii-service attributes via DeleteAttributes. (Gap — if the pii-service delete call itself fails after the local row is already gone, the failure is not retried, see Technical Debt — TD-00016.)

FR-11 (Primary Warehouse Flag, No Admin Surface): Every warehouse row carries is_main (boolean), with at most one is_main = true row per tenant enforced by the uq_warehouse_tenant_main unique constraint — this is how BRD-021 BR-04’s “exactly one primary warehouse” requirement is satisfied at the database level. (Gap — no create/edit/list surface in WarehouseFormPage.tsx or WarehousePage.tsx lets an administrator view or change which warehouse is flagged is_main, see Technical Debt — TD-00016.)

FR-12 (Downstream Consumers): A published warehouse’s row is read by the stock-ledger (inventory_balances, keyed by (sku_id, warehouse_id), per SR-019) and by checkout’s shipping-cost/GST calculation, which resolves fulfillment to whichever warehouse has is_main = true — not a destination-based choice among several published warehouses, per the known v1 simplification documented in inventory-service’s own warehouse-resolution notes.


Non-Functional Requirements

Composition & Reuse

ui-admin-application’s features/warehouse/WarehouseRepository.ts is the only file in the feature that imports apiClient, per the admin app’s Feature Triad convention (ui-admin-application/CLAUDE.md). inventory-service’s repository layer wraps the pii-service gRPC calls the same way it wraps its own Postgres access — service/warehouse/ never holds a raw gRPC client directly.

Multi-Tenancy & Auth Propagation

Every REST call carries the caller’s tenant/user/role via the standard AuthClaims header contract; tenant_id/created_user_id/updated_user_id on the warehouse row are sourced from the auth context, never the request body, per the mandatory five-field audit contract. The gRPC call to pii-service propagates tenant_id/user_id/role as outbound metadata, never in the request payload, per the monorepo’s security rules (.claude/rules/06-security.md).

Client-Side Validation Caveat

FR-05’s field-format validation (required fields, phone/pincode formats) runs only in WarehouseFormController.ts — a caller bypassing the admin UI and calling the REST API directly can persist a warehouse with an empty address or a malformed phone number. This is tracked, not silently assumed away, in Technical Debt — TD-00016.