# plugin-inventory

`@fayz-ai/plugin-inventory` · beta · Partial capability

Inventory is the universal organ — a salon counts product, a restaurant counts ingredients, a clinic counts supplies. plugin-inventory is that organ as a plugin: a product catalog, stock entry/exit/history, optional recipes (bill of materials), and a dashboard that surfaces stock value and what's running low. It's scope: universal, so it snaps into any vertical.

## Overview

Inventory and catalog: entries and exits, history, balance per location and specs (recipes). It mounts the `/inventory` page and dashboard widgets. The `recipes`, `stockLocations` and `batchTracking` (opt-in) modules are toggled by config; the default product types are supply, for sale, intermediate and asset.

On the data side, **products are the archetype** `saas_core.products`; the plugin adds extension tables in `public` — `stock_locations`, `stock_movements`, `stock_positions`, `recipes`, `recipe_ingredients`, `measurement_units` and `product_categories` — across four migrations (prefix rename, base, recipes, measurement units). Supabase provider with mock fallback.

For AI, it exposes `getLowStock` (products below their minimum). Status **beta / partial capability**.

## When to use it

- Track stock entries, exits and balance per location.
- Model recipes or specs that consume supplies.
- Get low-stock alerts, including through AI.

## Specs

- **Package:** `@fayz-ai/plugin-inventory`
- **Version:** 0.1.7
- **Status:** beta
- **Capability:** Partial capability
- **Product type:** Management (Admin/SaaS), E-commerce, Restaurant / food
- **Stable channel:** `^0.1.7`
- **Migrations:** 4 migration(s)
- **Factory:** `createInventoryPlugin()`

## Data model

Convention: plg_ + tenant_id + RLS.

- `plg_inventory_product_categories` — name, parent_id, is_active
- `plg_inventory_stock_locations` — name, description, is_active, unit_id
- `plg_inventory_stock_movements` — product_id, quantity, movement_type, unit_cost, total_cost, stock_location_id
- `plg_inventory_stock_positions` — product_id, quantity, unit_cost, stock_location_id, batch_number, expiration_date
- `plg_inventory_recipes` — name, description, product_id, yield_quantity, yield_unit_id, preparation_time_minutes
- `plg_inventory_recipe_ingredients` — recipe_id, product_id, quantity, unit_id, display_order, notes
- `plg_inventory_measurement_units` — name, abbreviation, is_active

## AI tools

| id | mode | description |
| --- | --- | --- |
| `inventory.low-stock` | read | Lists products with stock below minimum threshold. |

## Integrations

No hosted connector — external providers come in via the connector spine (`@fayz-ai/core`).

## Integrate

Add the plugin to surfaces.admin.plugins in your app's app.manifest.json and run the doctor to validate:

```json
{ "surfaces": { "admin": { "plugins": [ { "id": "inventory", "enabled": true } ] } } }
```

```bash
npx fayz doctor
```
