Demand Forecast

ERP: _estimate of units_sold per product from the season and last year's sales for the same month, measured on six held-out months against same-month-last-year and the trailing three-month average. E-commerce: next month's sales range per product scored against a naive last-month rule on Model checks, and seasonal category peaks via _relate on Patterns. The demo's Supply view reorders on observed sales, because the forecast did not beat the naive rule. No separate forecasting model.

📋 ERP🛒 E-commerce_estimate_relate_evaluateERPE-commerce
In the demoIn the ERP demo, _estimate forecasts six held-out months per product: 16.8%, 18.8% and 20.4% error (WAPE) on the three profiles, against 29.2%, 24.0% and 23.9% for the trailing three-month average an ERP reorder rule runs on; same month last year stays ahead on two of the three. The e-commerce demo scores its own forecast of next month's sales range on seven held-out months: it ties a naive last-month rule (41 % against 39 %) and is 22 points ahead of always guessing the most common range, so its Supply view reorders on observed sales. No separate forecasting model, no retraining schedule.

The problem

Demand forecasting in an ERP traditionally requires a separate forecasting model: time-series ARIMA, exponential smoothing, or a more sophisticated ML pipeline that someone has to train, deploy, and retrain quarterly. The cost of building that pipeline is what keeps demand forecast as a specialist feature in a corner of the ERP, not an everyday tool. Smaller-scale teams either go without — and overstock or stockout — or buy a separate demand-forecast SaaS that does not integrate cleanly with the operational data already in the ERP.

The data the forecast needs is already in the ERP: monthly units_sold history, seasonality, supplier lead times, project pipeline. The conditional structure is there. What is missing is a way to predict units_sold without buying a separate model and retraining it monthly.

How it works

Aito's _estimate on the monthly demand table returns units_sold conditioned on the SKU, the season, and what the product sold in the same month last year, as a band. Seasonality comes from the history itself — there is no separate seasonal decomposition step — and the why lists the past months the estimate weighted. The forecast updates live as new sales land; no retraining schedule, no batch job, no quarterly tuning.

The ERP demo holds out the last six months and shows every forecast next to what actually sold and next to the two forecasts a buyer already has: same month last year, and the trailing three-month average. It is 15–42% closer than the trailing average and roughly on par with same month last year. The inventory-intelligence view uses the same estimate to ask whether stock on hand, plus what is on order, covers demand until the next delivery could arrive, checked against the held-out months.

{
  "from": "monthly_demand",
  "estimate": "units_sold",
  "where": {
    "sku": "SKU-2983",
    "season": "autumn",
    "last_year_band": "270-359"
  },
  "select": [
    "estimate",
    "why"
  ]
}

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 ERP. For the whole picture, see predictive e-commerce.

See it live

This use case runs in 2 live demos today, the 📋 ERP and 🛒 E-commerce demos. Each link opens the view that shows it, where you can 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.

Demand forecast: a prompt for Claude Code
Add demand forecast to this codebase using Aito, a predictive database. The feature: forecast next month's demand per product from our order history, with a range.

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/demand-forecast/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-erp-demo/blob/main/src/demand_service.py and https://github.com/AitoDotAI/aito-erp-demo/blob/main/src/aito_client.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. Measure before wiring the UI: hold out the latest months and report the error against simple baselines (the trailing average and the same month last year).
7. In the UI, show the range, not only the number, and let a person adjust it before anything is ordered or planned from it.

Ask me before changing anything outside the new feature.

Frequently asked

How does this compare to dedicated forecasting tools like Prophet or ARIMA?

Dedicated tools optimize for forecast accuracy on a specific time-series shape. Aito's prediction is more general — it works across SKUs, customers, segments, and projects in a single query. The e-commerce demo measures its own forecast: on next month's sales range, held-out accuracy ties a naive last-month rule. A simple baseline like that is the bar to check against before claiming an edge.

What if our demand is project-driven (lumpy, irregular)?

Add the project pipeline to the where clause and the estimate conditions on it, so the forecast reflects the projects in flight, not just the historical baseline. For very lumpy demand (one-off engineering builds) there are few comparable months to estimate from, and the why shows how few — the system honestly says it has little to go on, which is the right behavior.

How quickly do new SKUs reach useful forecast accuracy?

A few months of stable demand on the new SKU is usually enough to move its estimate away from the category's, and the $why shows when it has. For SKUs with similar attributes to existing SKUs, even the first observation can carry useful signal through similarity (_relate). Cold-start on completely novel SKUs follows the same path as any prediction with no history — the system says it doesn't know yet.

Does this support multi-tenant demand forecasting (per-customer SaaS)?

Yes. Add customer_id to the where clause; the conditional probability is computed only over that tenant's rows. Same engine, different forecast per tenant, no per-tenant model. The accounting demo runs 255 simulated customer companies on one shared Aito instance using this exact pattern.