Skip to content

About

RetailSense: AI Decision-Intelligence System for Retail & CPG. Synthesizes 9 enterprise signals across the connected decision chain to prescribe, explain, and execute measurable store-level business actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RetailSense β€” AI Decision Intelligence for Retail & CPG

FastAPI React Tailwind CSS PostgreSQL Python Theme

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.


πŸ›οΈ System Architecture

RetailSense End-to-End System Architecture

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β”‚
                                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”— The Connected Decision Chain

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.

⚑ The 7 Canonical Business Actions

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.

πŸ“‘ 9 Enterprise Signals Synthesized

  1. SKU Sales Velocity: Historical sales run-rate, unconstrained baseline velocity, and hourly POS trends.
  2. Inventory On-Hand: Current shelf stock, backroom storage, safety stock, and days of cover.
  3. Promotions & Marketing Elasticity: Active flyer features, digital coupons, and historical price elasticity.
  4. Unit Pricing & Margin Structure: Cost of goods sold (COGS), list price, current gross margin, and salvage value.
  5. Supplier Lead Times & Reliability: Vendor fulfillment lead times (days), minimum order quantities (MOQ), and variance history.
  6. Store Location & Channel Format: Express convenience, downtown hub, suburban hypermarket, or dark store / e-commerce DC.
  7. Local Events: Stadium sports matches, cultural festivals, public holidays, and marathon footfall.
  8. Weather Anomalies: Heatwaves (+14Β°F above norm), unseasonal rains, cold snaps, and storm warnings.
  9. Competitor Benchmarks: Competing supermarket price points and weekly promotional flyers.

πŸ“ˆ Proven Success Measures (AI vs Baseline Proof)

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

πŸ›‘οΈ Data Quality & Audit Ledger

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 to 0 and recorded in the audit ledger.
  • Lead Time Variance Buffering: Supplier delays dynamically adjust safety stock buffers rather than triggering premature expediting penalties.

πŸ“± Multi-Channel Action Execution & Live Decision Studio

  1. 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.
  2. 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.
  3. 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.
  4. 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).
  5. Purchase Order Exporter:

    • 1-click CSV export of approved purchase orders ready for ERP ingestion (/api/v1/export/purchase-orders).

πŸ‘₯ Demo Enterprise Personas & Credentials

Role Persona Email 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

πŸ› οΈ Tech Stack & Ports

  • 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/ (or 5173)
  • Backend:
    • FastAPI (Python 3.12+), Pydantic v2
    • PostgreSQL (voiceofcustomer_db on localhost:5432)
    • SQLAlchemy 2.0 ORM, PyJWT (Dual Access & Refresh Tokens), bcrypt
    • Uvicorn on Port 8001: http://localhost:8001/

πŸš€ Quickstart Guide

1. Prerequisites

  • Node.js 18+ and npm
  • Python 3.12+
  • PostgreSQL running locally on port 5432

2. Backend Setup

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 --reload

Interactive API docs available at: http://localhost:8001/docs

3. Frontend Setup

cd client

# Install packages
npm install

# Run frontend development server
npm run dev

Open your browser at: http://localhost:5174/

4. Running Verification Checks

# 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

πŸ”’ Security & Git Hygiene Standards

  • 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.
  • Zero Secrets in Git: Local .env files 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.

πŸ“„ License

RetailSense is developed for the AI for Business (Retail / CPG) Decision Intelligence Challenge. Released under the MIT License.

About

RetailSense: AI Decision-Intelligence System for Retail & CPG. Synthesizes 9 enterprise signals across the connected decision chain to prescribe, explain, and execute measurable store-level business actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages