Skip to content

RFC 003: WMS Technical Specification

The Warehouse Management System (WMS) operates high-frequency inventory tracking using class-based SQLAlchemy structures linked to PostgreSQL:

class StockEntry(BaseDocType):
"""Core inventory transaction record."""
posting_date: date
purpose: str = Field(description="Receipt, Transfer, Issue")
from_warehouse: str | None = Field(default=None, description="Source Warehouse ID")
to_warehouse: str | None = Field(default=None, description="Destination Warehouse ID")
company: str
items: list["StockEntryItem"] = Field(default=[], description="Nested child items list")
class Meta:
table_name = "stock_entry"
indexes = ["posting_date", "purpose"]
class Bin(BaseDocType):
"""Real-time inventory balance projection per Item and Warehouse."""
item_code: str = Field(max_length=50)
warehouse: str = Field(max_length=100)
actual_qty: Decimal = Field(default=Decimal("0.000"))
reserved_qty: Decimal = Field(default=Decimal("0.000"))
ordered_qty: Decimal = Field(default=Decimal("0.000"))
projected_qty: Decimal = Field(default=Decimal("0.000"))
class Meta:
table_name = "bin"
unique_together = [("item_code", "warehouse")]
indexes = ["item_code", "warehouse"]

2. Automated Replenishment & Safety Stock Formulas

Section titled “2. Automated Replenishment & Safety Stock Formulas”

To maintain optimal branch stock, the Replenishment Engine executes an asynchronous cron worker evaluating projected stock balances:

$$\text{ProjectedQty} = \text{ActualQty} + \text{OrderedQty} - \text{ReservedQty}$$

2.2 Reorder Trigger & Quantity Calculation

Section titled “2.2 Reorder Trigger & Quantity Calculation”

For every active item in a Retail Outlet:

  • If $\text{ProjectedQty} < \text{SafetyStockThreshold}$: $$\text{ReorderQuantity} = \text{MaximumAuthorizedCapacity} - \text{ProjectedQty}$$
  • The WMS automatically raises a MaterialRequest DTO containing ReorderQuantity and queues it for HQ DC distribution.

The WMS user interface is designed as an independent React/Tamagui sub-package located under libs/wms/frontend/.

graph TD
    Host[Host Gateway desk-shell] -->|Federation Load| Remote[http://wms-service:8080/mfe/remoteEntry.js]
    Remote -->|Imports Components| View[WMS Inventory Pages]

The libs/wms/frontend/vite.config.ts declares the module as a federated remote:

import { defineConfig } from "vite";
import federation from "@originjs/vite-plugin-federation";
export default defineConfig({
plugins: [
federation({
name: "wms",
filename: "remoteEntry.js",
exposes: {
"./InventoryPanel": "./src/components/InventoryPanel.tsx",
"./SupplierPortal": "./src/pages/SupplierPortal.tsx",
},
shared: ["react", "react-dom", "tamagui"],
}),
],
});

At runtime in Enterprise Mode, the Host Gateway Desk Shell queries the dynamic schema and imports these modules asynchronously via remoteEntry.js.