A full-stack inventory planning application built with Django REST Framework and React. It tracks daily consumption, monitors stock health, and runs machine learning forecasts to support reorder decisions.
- JWT-based authentication with role-based access (
admin,analyst) - Master data modules for items, stocks, suppliers, and users
- Consumption logging with automatic stock adjustment
- Forecasting pipeline with model comparison (Linear Regression, Random Forest, Prophet)
- Dashboard with KPI cards, priority queue, and visual charts (bar + donut)
- Forecast screen with confidence bands and CSV export
- Clean frontend service layer using
axiosvia a shared API client
- Django
5.2.12 - Django REST Framework
3.17.1 - SimpleJWT
5.5.1 - SQLite (dev), PostgreSQL-compatible config for production
- scikit-learn, pandas, numpy, Prophet
- React
19.2.4 - React Router
7.14.0 - Recharts
3.8.1 - Axios
1.14.0 - Vite
5.4.x
Inventory_demand_forecasting/
|- backend/
| |- accounts/ # custom user model + auth APIs
| |- consumption/ # consumption CRUD + stock sync logic
| |- dashboard/ # aggregated dashboard APIs
| |- forecasting/ # forecast APIs + ML pipeline
| | \- ml/
| |- inventory/ # items and stocks
| |- suppliers/ # supplier CRUD
| |- utils/management/commands/
| | |- load_synthetic_data.py
| | \- run_forecasts.py
| |- resources/data/ # synthetic dataset generator + JSON files
| |- core/ # settings + root urls
| \- manage.py
\- frontend/
|- src/
| |- components/
| | \- dashboard/DashboardCharts.jsx
| |- context/
| |- hooks/
| |- layouts/
| |- pages/
| |- routes/
| |- services/ # separated API modules, shared apiClient
| \- styles/
|- .env.example
\- package.json
- Landing page: Overview, Features, Workflow sections
- Dashboard: KPIs, top consumption chart, stock status donut, supplier value chart, action queue
- Forecasts: model comparison + forecast confidence visualization + CSV export
- Items and Stocks: full inventory lifecycle
- Suppliers: directory and edits
- Consumption: create/read/update/delete with stock impact
- User Management: admin creates analysts
The following screenshots show the main operational modules in the app UI.
Shows KPI cards, action-ready stock alerts, and visual charts for demand, stock status, and supplier exposure.
Capture daily consumption entries and review recent usage history with filters.
Model-driven demand forecast view with horizon selection, confidence bands, and reorder guidance.
Item master data management including search/filter and admin-only create/update controls.
Stock threshold management for reorder level, safety stock, and max stock settings.
Supplier directory with contact details, lead times, and minimum order quantity.
Admin-only analyst account creation and analyst user listing.
| Capability | Admin | Analyst |
|---|---|---|
| View dashboard/forecasts/items/stocks/suppliers/consumption | Yes | Yes |
| Create analysts | Yes | No |
| Create/update/delete items | Yes | No |
| Update stocks | Yes | No |
| Create consumption entries | Yes | Yes |
| Update/delete consumption entries | Yes | No |
| Create/update/delete suppliers | Yes | No |
Base URL (default): http://127.0.0.1:8000/api
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /login/ |
Login and get access + refresh token | Public |
| POST | /logout/ |
Blacklist refresh token | Authenticated |
| GET | /analysts/ |
List analysts | Admin |
| POST | /analysts/ |
Create analyst | Admin |
| GET | /test/ |
JWT test endpoint | Authenticated |
| Method | Endpoint | Access |
|---|---|---|
| GET | / |
Admin + Analyst |
| GET | /:id/ |
Admin + Analyst |
| POST | / |
Admin |
| PUT/PATCH | /:id/ |
Admin |
| DELETE | /:id/ |
Admin |
| Method | Endpoint | Access |
|---|---|---|
| GET | /items/, /items/:id/ |
Admin + Analyst |
| POST/PUT/PATCH/DELETE | /items/, /items/:id/ |
Admin |
| GET | /stocks/, /stocks/:id/ |
Admin + Analyst |
| POST/PUT/PATCH/DELETE | /stocks/, /stocks/:id/ |
Admin |
| Method | Endpoint | Access |
|---|---|---|
| GET | /, /:id/ |
Admin + Analyst |
| POST | / |
Admin + Analyst |
| PUT/PATCH/DELETE | /:id/ |
Admin |
| Method | Endpoint | Description |
|---|---|---|
| GET | /stock-overview/ |
stock status snapshot |
| GET | /consumption-summary/?days=7 |
per-item consumption summary |
| GET | /low-stock-alerts/ |
reorder-risk items |
| GET | /supplier-summary/ |
supplier-level value summary |
| Method | Endpoint | Description |
|---|---|---|
| GET | /results/?days=30 |
forecast rows for horizon |
| GET | /results/?item_id=101&days=30 |
forecast rows for one item |
| GET | /performance/ |
model performance list |
| GET | /performance/compare/?item_id=101 |
best model + per-model metrics |
Run from backend/:
python manage.py run_forecastsUseful options:
python manage.py run_forecasts --item-id 101
python manage.py run_forecasts --days 30What it does:
- Loads historical consumption by item
- Builds engineered features (date, lag, rolling, holidays)
- Trains 3 models
- Evaluates MAPE/RMSE/MAE
- Marks best model per item
- Saves forecasts to
ForecastResult
git clone https://github.com/HarshAI-ML/Inventory_demand_forecasting.git
cd Inventory_demand_forecastingcd backend
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserverBackend default: http://127.0.0.1:8000
cd frontend
npm install
npm run devFrontend default: http://127.0.0.1:5173
ENV=development
DJANGO_SECRET_KEY=change-me
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1
# Used when ENV=production
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=5432VITE_API_BASE_URL=http://127.0.0.1:8000/apiFrom backend/:
python resources/data/generate_data.py
python manage.py load_synthetic_data
# optional reset + reload
python manage.py load_synthetic_data --flushThe frontend keeps concerns separated:
src/services/apiClient.js: shared axios request wrapper, token/header handling, error normalizationsrc/services/*.js: domain services (authService,dashboardService,inventoryService, etc.)
erDiagram
Supplier ||--o{ Item : "supplies"
Item ||--|| InventoryStock : "tracked in"
Item ||--o{ Consumption : "consumed as"
Item ||--o{ ForecastResult : "forecasted for"
Item ||--o{ ModelPerformance : "evaluated for"
User {
int id PK
string username
string email
string role
string phone
string department
}
Supplier {
int supplier_id PK
string supplier_name
string location
int lead_time
int minimum_order_quantity
}
Item {
int item_id PK
string item_name
string category
int supplier_id FK
decimal cost_per_unit
int shelf_life_days
}
InventoryStock {
int stock_id PK
int item_id FK
int quantity_available
int reorder_level
int safety_stock
int max_stock_level
}
Consumption {
int consumption_id PK
int item_id FK
int quantity_used
date date
string department
bool holiday_flag
}
ForecastResult {
int id PK
int item_id FK
date forecast_date
float predicted_qty
float lower_bound
float upper_bound
string model_used
}
ModelPerformance {
int id PK
int item_id FK
string model_name
float mape
float rmse
bool is_best_model
}
# backend tests
cd backend
python manage.py test
# frontend lint
cd frontend
npm run lint
# frontend production build
npm run build





