Inventory-Service — SKU Variants, Stock, Pricing & Package Data

By Engineering Team•September 25, 2026•6 min read

Responsibility

inventory-service owns everything about a product’s buyable SKUs that product-catalog itself never stores.

  • Variant Builder — defines the buyable SKUs of a product (e.g. size/color combinations), each independently toggleable active/inactive.
  • Stock & Threshold (Opening Entry) — per-SKU, per-warehouse safety-stock and maximum-capacity thresholds, with a validation rule that safety stock can never exceed maximum capacity for any SKU × warehouse cell.
  • Volumetric Specs — per-SKU physical dimensions and weight.
  • Compliance & Pricing — per-SKU price, applicable tax, and returns policy; required for every active SKU before a product can be published.
  • Package Map — maps each SKU to a valid shipping package.
  • Completion events — publishes one independent, best-effort Pub/Sub event per step (variant-builder-upserted, opening-entry-upserted, sku-dimension-upserted, sku-compliance-pricing-upserted, sku-box-mapping-upserted) that product-catalog consumes to update its own sync markers. Of these five, only sku-compliance-pricing-upserted is also consumed by a second subscriber.
  • Search index publisher — publishes two additional, search-only Pub/Sub events not part of the five step-completion topics above: inventory-search-event (coarse price/stock summary) and stock-balance-status-changed (ordered, per-SKU stock-status flips, keyed by product ID) — both consumed only by search-service. Combined with its own subscription to sku-compliance-pricing-upserted (ordered, keyed by transaction ID, filtered to status == "COMPLETED"), this gives search-service three of its four sync streams from inventory-service — see SR-006 FR-15–FR-17 and ADR-00017.
  • Storefront pricing/availability — shop-service reads live price/stock data from here (gRPC) when assembling curated storefront sections.
  • Order-driven stock reservation & consumption — StockBalanceService’s ReserveInventory/ReleaseInventory/ConsumeInventory gRPC methods, called by order-service’s checkout saga, set stock aside at order placement and permanently deduct it only once payment and fulfillment have both succeeded — see SR-019 for the full reservation/consumption/concurrency contract.
  • Stock Entry (admin movement recording & approval) — StockEntryService’s Create/Update/Approve/Reject/Clone surface records every non-checkout warehouse stock movement (Purchase, Returns, Adjustment, Opening Entry, Internal Loss, Damage Stock) as a PENDING transaction with zero immediate balance effect; only an explicit Approve mutates inventory_balances and writes a permanent stock_ledger_entries row, reusing the same balance-mutation routine checkout consumption uses. A database trigger makes the ledger unconditionally un-editable and un-deletable once written. See SR-020 for the full contract.
  • Opening-Entry bulk initialization — domain/stockentryprocess/’s PUT/POST /sku-opening-entry[/process] endpoints initialize a batch of SKU × warehouse pairs in one call, each pair going through the same Create-then-Approve shape as a single Opening Entry movement, guarded against double-initialization at the database level. Called both by an operator directly and, as a second real automated caller, by the tenant-catalog-migration pipeline (tenant-migration → Pub/Sub → tenant-migration-orchestrator) during a bulk CSV import — not by the gRPC/product-catalog-publish trigger the code’s own doc-comment describes, which was never built. See SR-020 FR-15 and Technical Debt — TD-00014, TD-03.
  • Warehouse Master (admin master data) — WarehouseService’s Create/Update/Publish/Archive/Delete surface maintains the tenant’s directory of fulfillment locations, through the shared DRAFT/PUBLISHED/ARCHIVED lifecycle (ADR-00037). Basic Info (code, description, is_main) is local to "inventory-service".warehouse; Address and Contact fields are stored in pii-service via gRPC, keyed by the warehouse’s UUID as entity_id with PiiEntityType = "warehouse". See SR-022 for the full contract.
  • Package Master (admin master data) — PackageMasterService’s Create/Update/Publish/Archive/Delete surface maintains the tenant’s catalog of shippable container types (external/internal dimensions, tare/max weight, material type), sharing Warehouse Master’s DRAFT/PUBLISHED/ARCHIVED lifecycle but fully local to "inventory-service".package_master — no pii-service dependency. A published packaging type is read by product-catalog’s product-setup wizard Step 8 and by checkout’s volumetric-weight calculation. See SR-023 for the full contract.

Tech Stack

Concern Choice
Language Go
Data store PostgreSQL — see ADR-00008 for why this differs from product-catalog’s MongoDB
gRPC Server — shop-service (storefront pricing/availability) and order-service (checkout saga’s StockBalanceService.ReserveInventory/ReleaseInventory/ConsumeInventory); see ADR-00009 for why gRPC rather than REST
REST Admin wizard’s Variant Builder / Stock & Threshold / Volumetric Specs / Compliance & Pricing / Package Map steps
Messaging Firebase Pub/Sub — publisher of five step-completion topics (consumed by product-catalog; only sku-compliance-pricing-upserted also has a second, search-service subscription) plus two dedicated search-only topics, inventory-search-event and stock-balance-status-changed (consumed only by search-service)
Dependency injection Uber Fx
Template @templates/go-postgres-microservice, gRPC layer composed from @templates/go-grpc-microservice

API Endpoints (Admin Wizard)

Step Endpoint
Variant Builder PUT /inventory/admin/api/v1/variant-builder
Stock & Threshold (Opening Entry) PUT / GET /inventory/admin/api/v1/sku-opening-entry
Volumetric Specs PUT /inventory/admin/api/v1/sku-dimensions
Compliance & Pricing PUT /inventory/admin/api/v1/sku-compliance-pricing
Package Map Package-mapping endpoint, same request/response shape convention as the above

API Endpoints (Stock Entry)

Action Endpoint
Create / List POST / GET /inventory/admin/api/v1/stock-entries
Get / Update GET / PUT /inventory/admin/api/v1/stock-entries/:id
Approve POST /inventory/admin/api/v1/stock-entries/:id/approve
Reject POST /inventory/admin/api/v1/stock-entries/:id/reject
Clone POST /inventory/admin/api/v1/stock-entries/:id/clone
Opening-Entry bulk initialization PUT /inventory/admin/api/v1/sku-opening-entry, POST /inventory/admin/api/v1/sku-opening-entry/process

API Endpoints (Warehouse Master)

Action Endpoint
Create / List POST / GET /inventory/admin/api/v1/warehouses
Get / Update GET / PUT /inventory/admin/api/v1/warehouses/:id
Publish POST /inventory/admin/api/v1/warehouses/:id/publish
Archive PATCH /inventory/admin/api/v1/warehouses/:id/archive
Delete (DRAFT only) DELETE /inventory/admin/api/v1/warehouses/:id

API Endpoints (Package Master)

Action Endpoint
Create / List POST / GET /inventory/admin/api/v1/package-masters
Get / Update GET / PUT /inventory/admin/api/v1/package-masters/:id
Publish POST /inventory/admin/api/v1/package-masters/:id/publish
Archive PATCH /inventory/admin/api/v1/package-masters/:id/archive
Delete (DRAFT only) DELETE /inventory/admin/api/v1/package-masters/:id

Implementation Notes

  • Each completion event is scoped to exactly one wizard step — there is no single aggregate “product ready” event; product-catalog is responsible for combining all five into its own readiness state.
  • sku-compliance-pricing-upserted’s status field takes three literal values published at different points of the same UpsertSkuCompliancePricing call — "PROCESSING" on entry, "FAILED" on validation/repo error, "COMPLETED" only after a successful repo upsert. product-catalog’s subscriber and search-service’s subscriber both receive all three; search-service filters to "COMPLETED" only (see SR-006 FR-17).
  • SkuCompliancePricingUpsertedEventPublisher’s publish call is synchronous but swallows errors — logged only, never surfaced to the caller or the HTTP response — the same best-effort/no-re-drive gap tracked in Technical-Debt-00006, TD-06.
  • Order-driven reservation uses a non-blocking conditional UPDATE ... WHERE quantity_available >= :qty guard (not a version column or an explicit lock); consumption reuses the admin Stock Entry flow’s own pessimistic row lock (INSERT ... ON CONFLICT (warehouse_id, sku_id) DO UPDATE ... RETURNING) rather than a separate SELECT ... FOR UPDATE or a second mutation path — see ADR-00035 for why these two mechanisms deliberately differ.
  • Reservation/release/consumption state is tracked as append-only guard rows in order_inventory_reservations (RESERVED → RELEASED or RESERVED → CONSUMED, never mutated in place), each status enforced unique per (tenant_id, order_id, sku_id, warehouse_id) via its own partial index — this is what makes a Temporal saga-activity retry of ReserveInventory/ReleaseInventory a safe no-op rather than a duplicate mutation. See SR-019 FR-07–FR-09.
  • No in-memory, pre-database fast-reject layer (e.g. Redis/token-bucket) exists yet for a much larger simultaneous-demand burst than ordinary contention — tracked as a deliberately deferred scaling decision, not an oversight, in Technical Debt — TD-00013.
  • inventory-service/CLAUDE.md is known to describe a ValidateAndCreateSkus gRPC endpoint that does not exist in the real gRPC surface — no synchronous publish-time validation call from product-catalog exists. See Technical Debt — Product Catalog Admin-to-Mobile Gaps, TD-03.
  • Stock Entry’s ApproveStockEntry defers every balance mutation until explicit approval — CreateStockEntry alone never touches inventory_balances — and a BEFORE UPDATE OR DELETE database trigger makes stock_ledger_entries unconditionally immutable, rather than relying on application code alone to never issue one; see ADR-00036 for why both were chosen over an immediate-apply/reverse-on-rejection design and an application-only immutability convention, respectively.
  • CloneStockEntry creates a new PENDING header but never copies the source movement’s line items, and RequiresSupervisorCheck is stored and displayed but not yet enforced as an actual approval-role gate — both named, tracked gaps, not silent limitations. See Technical Debt — TD-00014.
  • Warehouse Master’s Address/Contact fields live entirely in pii-service, correlated only by the warehouse UUID as an opaque entity_id — "inventory-service".warehouse itself never stores personal data. Field-shape validation for those fields runs only in the admin UI, not server-side, and a failed compensating DeleteAttributes call on delete is not retried — see Technical Debt — TD-00016.
  • Package Master’s package_material_type enum is validated only in domain/packagemaster_validation.go, with no backing database CHECK constraint — see Technical Debt — TD-00017.

Admin UI Walkthrough: 07-ui-admin. Architecture overview: Architecture: Product Catalog — Admin to Mobile Flow. Order-driven reservation/consumption: BRD-018, SR-019, ADR-00035, Architecture — Inventory Stock Reservation, Consumption, and Concurrency Control, Technical Debt — TD-00013, Architecture — Checkout Completion: Payment Capture and Fulfillment Handoff. Admin Stock Entry movement recording & approval: BRD-019, SR-020, ADR-00036, Architecture — Warehouse Stock Entry: Creation, Approval-Gated Balance Mutation, and Immutable Ledger, Technical Debt — TD-00014. Warehouse Master: BRD-021, SR-022, ADR-00037, ADR-00019, Architecture — Warehouse Master: Administration Console and PII-Backed Address Storage, Technical Debt — TD-00016, Admin UI Walkthrough. Package Master: BRD-022, SR-023, Architecture — Package Master: Administration Console, Technical Debt — TD-00017, Admin UI Walkthrough.