
The problem
Inventory arithmetic is easy: stock on hand, lead time, reorder point. The hard input is next month's demand. With a flat average, fast movers stock out and slow movers pile up, and the capital tied in overstock never shows on the same screen as the revenue lost to stockouts.
Put the demand prediction into the same arithmetic and both risks rank on one scale: euros.
How it works
The application does the stock arithmetic (days of supply, bands against the reorder point, tied capital). In the e-commerce demo the demand input is the last three months' sales: Aito's forecast was tested against that naive rule on held-out months and did not beat it, so the demo uses the simpler rule and says so. Aito's estimate is used where it helps: _estimate of units at five markdown levels for the largest overstock rows, to estimate whether a discount would clear the stock. In the ERP demo, the inventory view calls the demand forecast (_predict units_sold) for each tracked SKU.
Each markdown estimate carries its $why, so a buyer can see why a discount is or isn't expected to clear the stock.
For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive e-commerce.
See it live
This use case runs in the 🛒 E-commerce demo today. Click through to the live application and inspect the queries that produce the result.
Build it with Claude Code
Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.
Add stockout and overstock risk to this codebase using Aito, a predictive database. The feature: check our stock against reorder points and recent sales per product, and rank a reorder queue by the revenue at risk and the overstock by the capital it ties up. 1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code). 2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query. 3. Read the use-case guide: https://aito.ai/use-cases/stockout-risk/ 4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/supply_rows.py and https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/supply_service.py 5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample. 6. Check the numbers before building the view: compare a few of them against a direct count over the same rows (SQL or a short script), and report any that differ. 7. In the UI, show the evidence behind each number (the counts, the interval or $why), and leave out patterns with too little data behind them. Ask me before changing anything outside the new feature.


