Autonomous Supply Intelligence for MSMEs β Global events β Local decisions, instantly.
ResilientAI is a Decision Intelligence platform that converts global supply chain disruptions into real-time, actionable recommendations for small and micro businesses (MSMEs). If the Strait of Hormuz closes today, a kirana owner in Pune shouldn't have to wait 3 weeks to see prices spike β ResilientAI predicts the cost impact immediately and surfaces the single best action to take.
"If Bloomberg Terminal is for Wall Street, ResilientAI is for Main Street."
- The Problem
- Core Features
- Technology Stack
- Repository Structure
- API Endpoints
- Quick Start Guide
- Environment Variables
- Running Tests
- Typical Demo Flow
- Deployment
- Roadmap
- License
63 million MSMEs in India operate with zero access to real-time supply intelligence. When global disruptions occur β geopolitical conflicts, energy crises, commodity shocks β the impact cascades rapidly from global trade routes to local shelves, but small business owners find out weeks too late.
| What MSMEs Have Today | What ResilientAI Provides |
|---|---|
| WhatsApp rumours | Verified, AI-qualified risk alerts |
| Reactive pricing | Predictive, data-driven recommendations |
| Gut-instinct decisions | Quantum-optimized trade-off analysis |
| No foresight tools | Global β local impact mapping in seconds |
Example chain: Strait of Hormuz closure β LPG price +20% β Transport cost +12% β Product margin -8% β Recommended action delivered in < 5 minutes.
- Autonomously scans global news feeds and geopolitical datasets via NewsAPI.
- Performs NLP keyword extraction and named entity recognition using spaCy.
- Classifies events as
LOW,MEDIUM, orHIGHrisk with a confidence score. - Tags affected commodity classes (LPG, fuel, FMCG, pharma, agri).
- Powered by a LangChain ReAct agent with optional OpenAI / Gemini backends.
- Maps global risk events directly to quantified local business cost impacts (in βΉ and %).
- Models cascading factor effects through causal chains (e.g., LPG drop β transport rise β margin compression).
- Computes city-level impact comparisons across logistics hubs.
- Outputs predictions with a confidence interval for transparency.
- Evaluates competing multi-variable trade-off strategies using Qiskit QAOA.
- Considers price delta, inventory delta, supplier switching costs, and demand elasticity.
- Objective: maximise expected 7-day profit per decision.
- Automatic NumPy classical fallback if Qiskit runtime exceeds 10 seconds.
- Returns a ranked list of actions with human-readable rationale.
- Fully interactive MapLibre GL 3D globe visualization in the Next.js dashboard.
- Compare city-specific resilience metrics, vulnerability scores, and logistics hub exposure in real time.
- Ask supply chain questions in plain language or Hindi (e.g., "Gas price badhega kya?").
- SpeechRecognition for STT + gTTS for audio response synthesis.
- Integrated with language detection and impact engine queries.
- Proactive push alerts via Meta WhatsApp Business API.
- Sends risk alerts and recommended actions directly to MSME owners' phones.
- Webhook-based two-way messaging support.
- Simulate "what-if" scenarios: price increase, inventory stock-up, supplier switch.
- Visualises projected revenue, profit, and margin for each strategy.
- Price forecaster for key commodity categories.
- Exportable report generation per disruption event.
| Layer | Technology |
|---|---|
| Frontend | Next.js 16 Β· React 19 Β· TypeScript Β· Tailwind CSS v4 Β· shadcn/ui |
| Geospatial | MapLibre GL 5 (3D globe) |
| Charts | Recharts |
| Backend API | FastAPI Β· Python 3.11 Β· Uvicorn |
| AI Agent | LangChain (ReAct) Β· OpenAI Β· Google Gemini Β· Nebius AI |
| NLP | spaCy (en_core_web_sm) Β· langdetect |
| Optimization | Qiskit 1.0 (QAOA) Β· Qiskit Aer Β· NumPy (classical fallback) |
| Voice | SpeechRecognition Β· gTTS Β· PyAudio |
| Database | Supabase (PostgreSQL) |
| Messaging | Meta WhatsApp Business API |
| Data Sources | NewsAPI Β· Custom commodity CSV baselines |
| Deployment | Vercel |
ResilientAI/
βββ .env.example # Environment variable template
βββ vercel.json # Vercel deployment configuration
βββ requirements.txt # Python dependencies
βββ pytest.ini # Pytest configuration
β
βββ agents/ # AI Risk Detection & News Intelligence
β βββ news_fetcher.py # NewsAPI integration & headline polling
β βββ nlp_classifier.py # spaCy NLP keyword extraction & classification
β βββ risk_agent.py # LangChain ReAct agent for risk scoring
β
βββ api/ # FastAPI Backend
β βββ main.py # App entry point & middleware configuration
β βββ models.py # Pydantic request/response data models
β βββ routes/ # API route handlers
β βββ alerts.py # GET /api/v1/alerts
β βββ impact.py # POST /api/v1/impact
β βββ recommend.py # POST /api/v1/recommend
β βββ simulate.py # POST /api/v1/simulate
β βββ voice.py # POST /api/v1/voice
β βββ decisions.py # GET/POST /api/v1/decisions
β βββ cities.py # GET /api/v1/cities
β βββ forecast.py # GET /api/v1/forecast
β βββ whatsapp.py # POST /api/v1/whatsapp (webhook)
β βββ report.py # GET /api/v1/report
β
βββ engines/ # Core Intelligence Engines
β βββ impact_engine.py # Global risk β local cost impact calculator
β βββ optimizer.py # Qiskit QAOA optimizer + NumPy fallback
β βββ risk_scorer.py # Risk level scoring logic
β βββ city_impact.py # City-level comparative impact engine
β βββ price_forecaster.py # Commodity price forecasting
β βββ supplier_engine.py # Alternative supplier recommendations
β βββ report_generator.py # PDF/JSON report generation
β βββ user_store.py # User business profile management
β βββ database.py # Supabase database client
β
βββ data/ # Seed Data & Baselines
β βββ commodity_baselines.csv # Baseline prices for key commodities
β βββ impact_rules.json # Causal chain rules for impact calculation
β βββ seed_events.json # Pre-seeded disruption events for demo mode
β βββ suppliers.json # Supplier directory dataset
β
βββ frontend/ # Next.js Web Dashboard
β βββ app/ # Next.js App Router pages
β βββ components/ # Reusable React components
β βββ lib/ # Shared utilities and API client
β βββ middleware.ts # Next.js middleware (auth, routing)
β βββ public/ # Static assets
β
βββ tests/ # Pytest Test Suite
β βββ test_impact_engine.py # Impact engine unit tests
β βββ test_optimizer.py # Qiskit optimizer unit tests
β βββ test_risk_agent.py # Risk detection agent tests
β βββ test_meta_whatsapp.py # WhatsApp webhook integration tests
β
βββ voice/ # Voice Processing Module
βββ whatsapp.py # STT / TTS pipeline & voice query handler
Base URL: http://localhost:8000/api/v1
Interactive docs: http://localhost:8000/docs
| Method | Endpoint | Description |
|---|---|---|
GET |
/alerts |
Returns current active risk alerts |
POST |
/impact |
Calculate business impact from a risk event |
POST |
/recommend |
Get quantum-optimized decision recommendation |
POST |
/simulate |
Run profit simulation for a proposed action |
POST |
/voice |
Submit a voice/text query and get audio + text response |
GET/POST |
/decisions |
Log and retrieve accepted decisions |
GET |
/cities |
City-level resilience and impact comparison data |
GET |
/forecast |
Commodity price forecast for selected categories |
POST |
/whatsapp |
Meta WhatsApp webhook for push alerts |
GET |
/report |
Generate disruption impact report |
Example: POST /impact
Request:
{ "event_id": "evt_001", "business_type": "kirana" }Response:
{
"LPG_price_change": 0.20,
"transport_cost_change": 0.12,
"product_margin_change": -0.08,
"demand_change": -0.05,
"confidence_interval": 0.03
}Example: POST /recommend
Request:
{ "impact_id": "imp_001" }Response:
{
"action": "Stock 10 extra units + raise price by βΉ2",
"reason": "Minimizes expected loss, maximizes 7-day profit",
"profit_impact_inr": 1200,
"generated_by": "quantum",
"alternatives": [
{ "action": "Price increase only", "profit_impact": "+βΉ600" },
{ "action": "Switch supplier", "profit_impact": "+βΉ400", "risk": "HIGH" }
]
}Example: POST /voice
Request:
{ "query": "Gas price badhega kya?", "lang": "hi" }Response:
{
"text": "Haan, LPG price 20% badhega. 10 unit extra stock karo.",
"audio_base64": "<base64_mp3>"
}- Python 3.11+
- Node.js 20+
- API keys (see Environment Variables)
git clone https://github.com/Charmiseera/ResilientAI.git
cd ResilientAI# Create and activate virtual environment
python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows
.venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Download the spaCy NLP model
python -m spacy download en_core_web_smcp .env.example .env
# Edit .env and fill in your API keys (see section below)Demo Mode: Set
USE_SEED_DATA=trueandDEMO_MODE=truein.envto run fully on pre-seeded data without any external API keys.
uvicorn api.main:app --reload --port 8000- API base:
http://localhost:8000 - Interactive docs (Swagger UI):
http://localhost:8000/docs
cd frontend
npm install
npm run dev- Dashboard:
http://localhost:3000
Copy .env.example to .env and populate the following:
| Variable | Required | Description |
|---|---|---|
USE_SEED_DATA |
No | true = use mock seeded data (safe for demo) |
DEMO_MODE |
No | true = run in full demo mode |
DEMO_SCENARIO |
No | Default scenario (e.g. hormuz_disruption) |
GEMINI_API_KEY |
For AI | Google AI Studio |
NEBIUS_API_KEY |
For AI | Nebius AI |
NEWS_API_KEY |
For live news | newsapi.org (free tier) |
SUPABASE_URL |
For DB | Your Supabase project URL |
SUPABASE_KEY |
For DB | Supabase anon or service role key |
NEXT_PUBLIC_SUPABASE_URL |
Frontend | Same as SUPABASE_URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Frontend | Supabase anon key |
IBM_QUANTUM_TOKEN |
For Qiskit | quantum.ibm.com (free) |
QUANTUM_TIMEOUT_SECONDS |
No | Fallback timeout (default: 10) |
WHATSAPP_TOKEN |
For WhatsApp | Meta Business API token |
WHATSAPP_PHONE_NUMBER_ID |
For WhatsApp | Meta phone number ID |
WHATSAPP_BUSINESS_ACCOUNT_ID |
For WhatsApp | Meta business account ID |
NEXT_PUBLIC_GOOGLE_MAPS_KEY |
Frontend map | Google Maps API key |
NEXT_PUBLIC_API_URL |
Frontend | Backend URL (default: http://localhost:8000/api/v1) |
# Run the full test suite
pytest
# Run a specific test file
pytest tests/test_impact_engine.py -v
pytest tests/test_optimizer.py -v
pytest tests/test_risk_agent.py -v
pytest tests/test_meta_whatsapp.py -v- Open
http://localhost:3000in your browser. - In the Intelligence Panel, select a simulated global event (e.g., Hormuz Disruption).
- The Risk Detection Agent scores the event:
Risk: HIGH | Confidence: 92%. - The Impact Engine calculates: LPG +20% Β· Transport +12% Β· Margin -8%.
- The Quantum Optimizer recommends: "Stock 10 extra units + raise price by βΉ2 β Est. +βΉ1,200/week".
- Switch to the City Comparisons tab for the interactive 3D MapLibre globe showing affected regions.
- Use the Voice panel to ask: "Gas price badhega kya?" and hear an audio response.
- Use the Simulation panel to model alternative pricing or inventory strategies.
ResilientAI is a full-stack application with a Python backend and a Next.js frontend. For the best performance and reliability:
- Backend (API): Deployed on Render (Web Service).
- Frontend (Dashboard): Deployed on Vercel (Next.js).
- Connect Repository: Create a new Web Service on Render and connect it to your GitHub repository.
- Blueprint (Recommended): Render will automatically detect the
render.yamlfile and configure the service. - Manual Configuration (If not using Blueprint):
- Runtime:
Python - Build Command:
pip install -r requirements.txt && python -m spacy download en_core_web_sm - Start Command:
gunicorn -k uvicorn.workers.UvicornWorker app:app
- Runtime:
- Environment Variables: Add all required keys from
.env.examplein the Render dashboard. - Health Check: Your API will be live at
https://your-backend.onrender.com. Verify by visitinghttps://your-backend.onrender.com/health.
- Import Project: In Vercel, create a new project and select the
frontenddirectory as the Root Directory. - Environment Variables:
- Set
NEXT_PUBLIC_API_URLto your Render backend URL (e.g.,https://your-backend.onrender.com/api/v1). - Add Supabase and other frontend-specific keys.
- Set
- Deploy: Vercel will build and deploy the Next.js app natively.
Tip: Ensure
NEXT_PUBLIC_API_URLends with/api/v1to match the backend routes.
MVP (Now) v1.5 (Month 3) v2.0 (Month 6) v3.0 (Year 2)
ββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
Kirana stores + Pharma stores + Agri / logistics Global expansion
Next.js dashboard + WhatsApp alerts + Native mobile app Multi-country data
Qiskit simulator + Real-time pricing + Real quantum HW Enterprise SaaS
3 core decisions + Supplier directory + Predictive trends Platform API
Sector Expansion Path:
- Now: Kirana / general retail
- Month 3: Pharmaceutical distributors
- Month 6: Restaurants, food & beverage
- Year 2: Agri-logistics, manufacturing MSMEs
Built for real-world impact. See ResilientAI_PRD.md for the full Product Requirements Document.