RetailSense is an autonomous AI decision-intelligence system built for multi-channel retail and Consumer Packaged Goods (CPG) networks. Rather than stopping at passive sales forecasts, RetailSense synthesizes 9 disparate enterprise signals across the connected decision chain to prescribe, explain, and execute measurable store-level business actions.
The platform follows a closed-loop Observe β Predict β Reason β Decide β Act β Measure architecture designed for enterprise scalability:
βββββββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββββββββββ
β Data Sources β βββββΊ β Data Processing β βββββΊ β FastAPI Backend β
β β’ POS Sales β β β’ Unobserved β β β’ Orchestration β
β β’ Live Stock β β Demand Recon β β β’ Business Rules β
β β’ Promos/Lead β β β’ Anomaly Clamp β β β’ JWT Auth & Security β
βββββββββββββββββββ ββββββββββββββββββββββ βββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββββ βββββββββββββββββββββββββ βββββββββββββββββββββββββ
β Forecasting Module β β Inventory Optimizationβ βDecision Recommendationβ
β β’ ARIMA Baseline β β β’ Stockout Detection β β β’ 7 Canonical Actions β
β β’ LightGBM / XGBoost β β β’ Dynamic Safety Stockβ β β’ Capacity Guardrails β
β β’ P10-P90 Fan Charts β β β’ EOQ & Reorder Point β β β’ Trade-off Rationale β
βββββββββββββ¬ββββββββββββ βββββββββββββ¬ββββββββββββ βββββββββββββ¬ββββββββββββ
β β β
ββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββ
β Explainability & SHAP β
β β’ Feature Importance β
β β’ Expected Impact β
βββββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββββββββ
β Multi-Channel Action β
β β’ Web Console β
β β’ WhatsApp Alert Bot β
β β’ Automated PO Exportβ
βββββββββββββββββββββββββ
Retail decisions never operate in silos. A single merchandising discount ripples across the entire enterprise:
Demand βββΊ Inventory βββΊ Replenishment βββΊ Logistics βββΊ Margin βββΊ Customer Experience
- Demand Lift: Festival promotions or heatwaves increase consumer velocity (+35% to +160%).
- Inventory Strain: Days of cover collapse below supplier lead time.
- Replenishment Trigger: The system evaluates order batch sizes, supplier MOQs, and lead times.
- Logistics Coordination: Intra-district store transfers or regional DC cross-docking avoid expedited freight surcharges.
- Margin Protection: Dynamic price markdown clears aging lots before write-off, recovering tied working capital.
- Customer Experience: Shelves remain 96.8%+ stocked, eliminating walked sales and brand churn.
RetailSense strictly prescribes one of 7 canonical business decisions for every store and SKU:
| # | Action | Purpose & Trigger Condition | Typical Impact |
|---|---|---|---|
| 1 | Replenish |
Days of cover < supplier lead time; demand lift exceeds safe inventory buffer. | Prevents critical stockout; protects βΉ38,000+ lost margin per incident. |
| 2 | Transfer Inventory |
District store A has surplus stock (>45 days) while adjacent store B faces stockout (<2 days). | Balances network inventory with $0 new manufacturer PO spend. |
| 3 | Increase Allocation |
Weather anomaly or local stadium event creates extreme localized demand spike. | Captures incremental margin via central DC priority slotting. |
| 4 | Markdown |
Inventory shelf-life expires in <30 days with run-rate leaving unsold deadstock. | Recovers 70% cost basis before 100% total perishable spoilage write-off. |
| 5 | Adjust Promotion |
Upstream supplier delays risk premature stockout under active promo discounts. | Dampens discount from 20% to 10%, stretching run-rate by 6 days. |
| 6 | Substitute Product |
Primary brand SKU suffers national supplier stockout. | Cross-merchandises equivalent substitute on front endcaps (70% conversion recovery). |
| 7 | Take No Action |
Inventory run-rate and supplier lead times operate within optimal safety bands. | Eliminates unnecessary labor churn and logistics overhead. |
- SKU Sales Velocity: Historical sales run-rate, unconstrained baseline velocity, and hourly POS trends.
- Inventory On-Hand: Current shelf stock, backroom storage, safety stock, and days of cover.
- Promotions & Marketing Elasticity: Active flyer features, digital coupons, and historical price elasticity.
- Unit Pricing & Margin Structure: Cost of goods sold (COGS), list price, current gross margin, and salvage value.
- Supplier Lead Times & Reliability: Vendor fulfillment lead times (days), minimum order quantities (MOQ), and variance history.
- Store Location & Channel Format: Express convenience, downtown hub, suburban hypermarket, or dark store / e-commerce DC.
- Local Events: Stadium sports matches, cultural festivals, public holidays, and marathon footfall.
- Weather Anomalies: Heatwaves (+14Β°F above norm), unseasonal rains, cold snaps, and storm warnings.
- Competitor Benchmarks: Competing supermarket price points and weekly promotional flyers.
Replayed over a 6-week historical holdout backtest across 120 retail SKUs:
| Metric | Traditional Forecasting Baseline | RetailSense AI Decision Engine | Delta / Improvement | Business Value |
|---|---|---|---|---|
| Stockout Rate | 14.8% |
4.2% |
-71.6% | 10.6% fewer out-of-stock incidents |
| Service Level (In-Stock SLA) | 85.2% |
96.8% |
+11.6% | Exceeds 95% enterprise customer availability SLA |
| Excess Deadstock Working Capital | βΉ24,500 |
βΉ7,800 |
-68.2% | βΉ16,700 unlocked cash per store cluster |
| Gross Margin Rate | 18.2% |
23.4% |
+5.2% | +βΉ16,429 net profit expansion |
| Annualized Working Capital Savings | β | βΉ4,12,000 / store | 4.8x ROI | Substantial inventory holding cost reduction |
Raw enterprise POS feeds are frequently corrupt or incomplete. RetailSense embeds an automated data cleaning and reconstruction audit ledger:
- Unconstrained Lost Demand Reconstruction: When a SKU records 0 sales because on-hand stock was 0, traditional models assume zero demand. RetailSense automatically reconstructs true latent demand (~42 units on Basmati Rice) to prevent perpetual under-ordering.
- Negative Stock Anomaly Clamping: POS sync glitches recording negative on-hand quantities (e.g.
-3) are clamped to0and recorded in the audit ledger. - Lead Time Variance Buffering: Supplier delays dynamically adjust safety stock buffers rather than triggering premature expediting penalties.
-
Live Decision Intelligence Studio (9 Signals β 6 Stages):
- Interactive workbench allowing operators to tune all 9 real-world enterprise signals live.
- Real-time execution of the 6-stage lifecycle: Observe β Predict β Reason β Decide β Act β Measure.
- Outputs one of the 7 canonical actions with action rationale, connected decision chain ripple narrative, and side-by-side comparison with the traditional forecasting baseline.
- 1-click Commit & Dispatch Live Decision workflow pushing authorized orders into the PO queue.
-
Groq LLM Connected Decision Chain Copilot (
qwen/qwen3.8-27b):- Explain with AI: Natural language synthesis of multi-signal enterprise tradeoffs across
Demand β Inventory β Replenishment β Logistics β Margin β Customer Experience. - AI What-If Copilot: Simulates supply chain shocks (e.g. monsoon delays + marathon footfall) with rupee-quantified business outcomes.
- Explain with AI: Natural language synthesis of multi-signal enterprise tradeoffs across
-
4 Role-Adaptive Enterprise Workspaces:
- Store Manager (Priya Sharma): Store floor prescriptions, shelf stockout triage, backtest proof, interactive WhatsApp simulator, and floor staff execution checklist.
- Supply Chain Lead (Marcus Vance): District lateral store-to-store transfers (4-hour transit), Central DC capacity slotting, and Supplier OTIF reliability scorecards.
- Category Lead (Elena Rostova): Dynamic markdown elasticity optimizer slider, promo dampener, brand substitution matrix, and competitor price matching.
- Executive Cockpit (David Sterling): Omnichannel performance cockpit, district network heatmaps, and Connected Decision Chain ripple simulator.
-
WhatsApp Bot Simulator:
- Interactive conversational bot simulation (
/api/v1/whatsapp/chat). - Push stockout alerts directly to store managers with quick-tap ordering commands (
Approve/Reject).
- Interactive conversational bot simulation (
-
Purchase Order Exporter:
- 1-click CSV export of approved purchase orders ready for ERP ingestion (
/api/v1/export/purchase-orders).
- 1-click CSV export of approved purchase orders ready for ERP ingestion (
| Role | Persona | Password | Primary Workflow | |
|---|---|---|---|---|
| Store Manager | Priya Sharma | manager@retailchain.com |
Password123! |
Shelf triage, stockouts, staff checklist |
| Supply Chain Lead | Marcus Vance | supplychain@retailchain.com |
Password123! |
Lateral transfers, DC slotting, OTIF |
| Category Lead | Elena Rostova | category@retailchain.com |
Password123! |
Markdowns, promo dampening, pricing |
| Executive VP | David Sterling | executive@retailchain.com |
Password123! |
Omnichannel cockpit, network heatmaps |
- Frontend:
- React 19, Vite, Tailwind CSS
- Lucide React icons, Plotly.js (
plotly.js-dist-min) - Google OAuth (
@react-oauth/google) - Dev Port:
http://localhost:5174/(or5173)
- Backend:
- FastAPI (Python 3.12+), Pydantic v2
- PostgreSQL (
voiceofcustomer_dbonlocalhost:5432) - SQLAlchemy 2.0 ORM, PyJWT (Dual Access & Refresh Tokens), bcrypt
- Uvicorn on Port 8001:
http://localhost:8001/
- Node.js 18+ and npm
- Python 3.12+
- PostgreSQL running locally on port
5432
cd server
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start FastAPI server on Port 8001
uvicorn app.main:app --host 0.0.0.0 --port 8001 --reloadInteractive API docs available at: http://localhost:8001/docs
cd client
# Install packages
npm install
# Run frontend development server
npm run devOpen your browser at: http://localhost:5174/
# Frontend ESLint verification (0 errors, 0 warnings enforced)
cd client && npm run lint
# Production bundle build test
cd client && npm run build
# Backend API health test
curl -s http://localhost:8001/api/v1/dashboard/kpis | jq
curl -s http://localhost:8001/api/v1/recommendations | jq- Dual-Token Authentication:
- Access Token: 60-minute expiry (
type: access). - Refresh Token: 7-day expiry (
type: refresh). - Refresh tokens are rejected on protected decision endpoints.
- Access Token: 60-minute expiry (
- Zero Secrets in Git: Local
.envfiles are ignored by both root and client.gitignore. - Single-Viewport Auth Experience: Login and signup pages are constrained to fit within standard desktop viewports (
100vh) with zero vertical scrollbars.
RetailSense is developed for the AI for Business (Retail / CPG) Decision Intelligence Challenge. Released under the MIT License.
