An AI-powered, full-stack sales forecasting platform with five ML models,
interactive analytics, anomaly detection, inventory management, and RFM customer segmentation.
Real-time KPIs, monthly revenue trends, category breakdown, and regional sales.
Choose from 5 ML models, configure horizon & target column, and run background training jobs.
Monthly seasonality bars, day-of-week radar, Isolation Forest anomaly detection table.
Demand-based reorder alerts with safety stock, reorder points, and recommended order quantities.
RFM segmentation — Champions, Loyal, At Risk, and Churned — with lifetime value stats.
Executive summary, model performance comparison table, and one-click CSV export.
Drag-and-drop CSV/XLSX upload with auto column detection and dataset management.
| Module | What it does |
|---|---|
| Dashboard | Revenue, profit, orders, AOV, monthly trend chart, category donut, regional bar |
| Forecasting | Train Linear Regression, XGBoost, ARIMA, Prophet, or LSTM; poll job status; view predictions |
| Analytics | Seasonality patterns, anomaly detection (Isolation Forest), day-of-week radar |
| Inventory | Safety stock & reorder point calculation, demand-based order recommendations |
| Customers | RFM scoring with quartile binning; segment pie + detail cards |
| Reports | Executive summary, model metrics table (RMSE, MAE, R², MAPE), CSV export |
| Data Upload | Async file upload, column detection, multi-dataset support |
| Model | Best for | Notes |
|---|---|---|
| Linear Regression | Fast baseline | Ridge regularisation, cyclical + lag features |
| XGBoost | Tabular accuracy | Feature importance, handles non-linearity well |
| ARIMA | Stationary series | Auto ARIMA(2,1,2), classical time-series |
| Prophet | Trend + seasonality | Meta's Prophet, handles holidays & changepoints |
| LSTM | Complex patterns | TensorFlow/Keras, 30-day lookback window, CPU |
Frontend React 18 · Vite 5 · Tailwind CSS 3 · Recharts · React Query · react-hot-toast
Backend FastAPI · SQLAlchemy (async) · asyncpg · Pydantic v2 · python-jose (JWT)
ML Pandas · Scikit-learn · XGBoost · Prophet · TensorFlow-CPU · Statsmodels
Database PostgreSQL 15 (asyncpg driver)
Infra Docker · docker-compose · Nginx (reverse proxy)
git clone https://github.com/aasimansari1/Sales-Forecasting-System.git
cd Sales-Forecasting-System
cp backend/.env.example backend/.env # edit DATABASE_URL if needed
docker-compose up --buildOpen http://localhost — API docs at http://localhost/docs
Backend
cd backend
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # edit DATABASE_URL
uvicorn app.main:app --reload --port 8000Frontend
cd frontend
npm install
npm run dev # http://localhost:5173Sample data
cd data
python3 generate_sample_data.py # generates 211k-row sample_retail_sales.csvUpload the CSV via the Data Upload page to start forecasting.
| Column | Description |
|---|---|
date |
Transaction date (YYYY-MM-DD) |
revenue / sales |
Revenue amount |
product_name / product_id |
Product identifier |
category |
Product category |
region |
Geographic region |
store_id |
Store identifier |
customer_id |
Customer ID (used for RFM) |
quantity |
Units sold |
profit / cost |
Optional |
sales-forecasting/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI app entry point
│ │ ├── routes/ # auth, upload, forecast, analytics
│ │ ├── services/ # ml_service, analytics_service, data_processor
│ │ ├── models/ # SQLAlchemy ORM models
│ │ └── utils/ # JWT auth helpers
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── pages/ # Dashboard, Forecast, Analytics, Inventory, Customers, Reports
│ │ ├── components/ # Sidebar, Charts, MetricCard, FileUpload
│ │ ├── context/ # AuthContext (guest user — no login required)
│ │ └── services/ # Axios API client
│ ├── vite.config.js
│ └── Dockerfile
├── data/
│ └── generate_sample_data.py # Generates 211k retail sales records (2021–2024)
├── nginx/
│ └── nginx.conf # Reverse proxy: /api → backend, /* → frontend
├── docs/screenshots/ # App screenshots
└── docker-compose.yml
MIT





