Skip to main content
The Inventory module gives you a live view of stock levels across all your products. Each product has exactly one inventory record that tracks its current quantity alongside configurable minimum and maximum stock thresholds.
Inventory records are linked one-to-one with products. Use stock movements to update quantities — recording a movement automatically increments or decrements the linked inventory quantity.

Inventory data model

The Inventory model in the database schema:
model Inventory {
  id        String   @id @default(uuid())
  productId String   @unique
  product   Product  @relation(fields: [productId], references: [id], onDelete: Cascade)
  quantity  Int      @default(0)
  minStock  Int      @default(10)
  maxStock  Int      @default(1000)
  tenantId  String
  tenant    Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}
The productId field has a @unique constraint, enforcing the one-to-one relationship between a product and its inventory record.

Relationship to products

Every Product record has an optional Inventory relation (inventory Inventory?). The Inventory table defaults are quantity: 0, minStock: 10, and maxStock: 1000 when a record is created.

Viewing inventory levels

Navigate to Inventory in the sidebar. The page displays a table with the following columns:
ColumnDescription
ProductThe product name
SKUThe product’s stock-keeping unit identifier
Current StockThe current quantity on hand
Min StockThe minimum stock threshold
Max StockThe maximum stock threshold
StatusLow Stock if current stock is below minStock; OK otherwise
Inventory records are fetched from the API with the product relation included:
const inventory = await prisma.inventory.findMany({
  where: { tenantId: req.tenantId },
  include: { product: true },
})

Stock threshold system

Thresholds help you monitor stock health at a glance:
  • minStock (default: 10) — the minimum acceptable quantity. When current stock falls below this value, the row is flagged as Low Stock.
  • maxStock (default: 1000) — the upper limit for stock. Useful for preventing overstock.

Updating inventory directly

You can update quantity, minStock, and maxStock for an inventory record by sending a PUT request to /api/inventory/:id:
router.put("/:id", async (req: Request, res: Response) => {
  const { id } = req.params
  const { quantity, minStock, maxStock } = req.body

  const inventory = await prisma.inventory.update({
    where: { id },
    data: { quantity, minStock, maxStock },
  })
  res.json(inventory)
})
Directly editing inventory quantities bypasses the audit trail. Use the Stock Movements module to record quantity changes — each movement automatically updates the inventory quantity and creates a traceable log entry.

API reference

MethodEndpointDescription
GET/api/inventoryList all inventory records with product details
PUT/api/inventory/:idUpdate quantity and/or stock thresholds
All endpoints require a valid JWT in the Authorization: Bearer <token> header.

Build docs developers (and LLMs) love