Real-time Predictive Early-Warning Platform for Urban Governance in India
Built for India Innovates 2026 Hackathon | Team: 404. Not Found
RajyaNET Civic MRI is a cutting-edge AI-powered platform that treats the city like a living patient receiving continuous diagnostic monitoring. It ingests unstructured civic signals from tweets, citizen complaints, and municipal reports, processes them through advanced machine learning algorithms, and generates a single actionable Civic Stress Index (CSI) that predicts municipal crises before they escalate.
Today, government departments operate in silos:
- Water crisis in Ward 14? Three people filed complaints on Twitter—nobody's coordinating action
- Electricity outages bouncing between BSES and PWD? Citizen frustration peaks by complaint #10
- Sanitation collapse brewing in 5 wards? You'll know when media breaks the story
RajyaNET delivers predictive governance:
"Ward 14 is about to have a water crisis (CSI 87/100). Dispatch emergency tankers NOW, not after 500 citizens are angry."
- Live map visualization of all 40 Delhi wards with color-coded stress levels
- Interactive 360° gauge showing city-wide Civic Stress Index (0-100)
- Top stressed wards leaderboard with drill-down capability
- Live complaint feed with real-time sentiment analysis
- 24-hour trend charts for issue breakdown analysis
- Professional government-grade interface with minimal, clean design
- Live system status indicator - Shows active monitoring
Composite metric combining three data sources:
- Complaint Volume (40% weight) - Normalized complaint frequency per ward
- Sentiment Analysis (35% weight) - Hindi/English/Hinglish negative sentiment ratio
- Anomaly Detection (25% weight) - Isolation Forest ML detecting unusual activity spikes
Score Interpretation:
- 🟢 0-25 (GREEN): Stable - Normal civic operations
- 🟡 26-50 (YELLOW): Elevated - Monitor closely
- 🟠 51-75 (ORANGE): Critical - Intervention needed
- 🔴 76-100 (RED): Emergency - Immediate action required
Intelligent conversational interface that:
- Fetches live data from CSI Engine, Anomaly Detector, Alert System, Department Tracker
- Answers questions in Hindi, English, and Hinglish
- Provides actionable recommendations with specific department actions
- Shows 4 default quick-query buttons:
- 📋 "What's the overall city civic health?"
- 📊 "Which wards have the highest stress?"
- 💧 "Show water issues across Delhi"
- 🔍 "What anomalies have been detected?"
- Data source transparency - Lists which services provided each answer
- Follow-up suggestions - Recommends related queries
- Real example: Ask "Rohini mein water crisis hai?" → Gets CSI 87/100, 18 complaints, anomaly details
- Automatic alert generation when wards cross CSI ≥ 35 (configurable)
- Severity classification:
- 🔴 Emergency (CSI 85+)
- 🟠 Critical (CSI 75-84)
- 🟡 Warning (CSI 35-74)
- Officer assignment - Specific government officer automatically assigned per alert
- WhatsApp integration - Pre-formatted alert messages ready for field officers
- Active alert tracking - Prevents duplicate alerts, tracks acknowledgment
- Real demo: 3 active alerts showing Rohini water crisis, Mustafabad electricity, Kashmere Gate sanitation
"Shame Board" feature for inter-departmental accountability:
- Complaint bouncing metrics - Tracks complaint transfers between departments
- Department statistics per department:
- Bounces initiated (how many times they passed complaint onward)
- Transfers in/out (received vs. sent)
- Penalty points (escalation violations)
- Bounce ratio % (percentage of incoming complaints bounced)
- Visual ranking - Top offenders highlighted in red with badges
- Performance tracking for: MCD, DJB, PWD, BSES, TPDDL, NDMC, DMRC
- Joint Committee escalation - Auto-escalates chronic bouncing
- Real demo: MCD shows "WORST OFFENDER - 12 bounces initiated, 15.4% bounce ratio"
Machine learning-based unusual activity detector:
- Isolation Forest algorithm - Detects spikes deviating from 7-day average
- Real-time flagging - Marks wards with unusual complaint patterns
- Impact assessment - Shows complaint volume spike percentage (e.g., "144% above average")
- Automated escalation - Triggers alerts for flagged wards
- Helps identify emerging crises before citizen frustration peaks
- Real demo: Flags 3 wards (Rohini Sector 3, Mustafabad, Kashmere Gate) for water/electricity spikes
- 40 Delhi wards with accurate administrative boundaries
- Color-coded by stress level - Green to Red gradient based on CSI score
- Professional map legend with semi-transparent backdrop and blur effect
- Ward tooltips - Hover to see ward name, CSI score, dominant issue
- Click-through to detailed ward analysis (coming soon)
- Smooth interactions - No lag on pan/zoom
Multi-language complaint analysis:
- 300+ Hindi/English/Hinglish terms in custom lexicon
- Negative sentiment detection for urgency assessment
- Issue category classification:
- Water supply & sanitation
- Electricity & power
- Roads & infrastructure
- Public safety & CCTV
- Health & sanitation
- Other civic issues
- Per-complaint sentiment scoring (-1.0 to +1.0 scale)
- Powers CSI calculation and alert severity determination
- Stress Gauge - City-wide CSI with full 360° glow effect and stress level indicator
- City Status Panel - Total wards, emergency count, critical count, live complaint count
- Top Stressed Wards - Scrollable leaderboard with CSI scores for top 5 wards
- Issue Breakdown - Pie chart of complaint categories (last 24h data)
- Live Complaint Feed - Real-time stream of incoming complaints with sentiment badges
- AI Assistant Panel - Collapsible chat with 4 quick-query buttons and real data integration
- Government-grade dark theme - High contrast for accessibility, professional appearance
- Minimal, clean interface - Focus on data insights, not visual clutter
- CSS variable theming - Professional color system with semantic naming
- Responsive layout - Optimized for desktop government dashboards (tablet support in progress)
- Smooth animations - Framer Motion transitions without distraction
- Icon clarity - Lucide React icons for instant visual recognition
- Professional color palette:
- Accent (Cyan): #0ea5e9 for interactive elements
- Red: #ef4444 for critical/emergency
- Orange: #f97316 for warnings
- Green: #22c55e for stable
- Dark surfaces: #0f1729 for contrast
- SSE (Server-Sent Events) - Live complaint streaming without polling
- 10-second refresh cycle - Fresh CSI calculations automatically
- Database-backed state - Persistent 507-complaint history
- Live indicator - Green pulse badge shows system actively monitoring
- 24-hour complaint trends - Historical analysis per ward
- Sentiment breakdown - % of negative vs. positive complaints
- Top complainers - Most active issue categories
- Ward comparison - Side-by-side analysis capability
- Anomaly details - Full timeline of unusual activity with spike percentages
When judges ask questions, the AI:
- Analyzes intent - Matches question to civic data categories
- Fetches live data - Queries CSI Engine, Anomaly Detector, Alert System, Department Tracker
- Generates response - Provides exact CSI scores, complaint volumes, anomalies, actions
- Cites sources - Shows "Data Sources: CSI Engine, Alert System, Department Tracker"
- Suggests follow-ups - Recommends related queries for deeper analysis
- City Health Summary - Overall CSI, ward breakdown, alert counts, department performance
- Highest Stress Analysis - Top 5 stressed wards with CSI scores, recommendations
- Issue-Specific Analysis - Water/electricity/sanitation crisis detailed breakdowns
- Anomaly Reports - Flagged wards with spike details and assigned officers
- Help/Guidance - Explains what the system can analyze
- Actionable recommendations - "Deploy emergency water tankers to Rohini Sector 3"
- Severity indicators -
⚠️ SPIKE badges for anomalies, 🔴 Emergency badges - Decision support - "Recommend action: Coordinate with DJB for pipeline restoration"
- Confidence scoring - Transparency about data reliability (0.85 for identified intents)
- Time-stamped data - Shows when data was last refreshed (e.g., "Data refreshed: 18:25:08")
Q: "What's the overall city civic health?"
A: City CSI 40/100 [STABLE], 0 Emergency wards, 2 Critical wards, 298 complaints tracked...
Q: "Which wards have the highest stress?"
A: Top 5 - Rohini Sector 3 (87/100 CRITICAL), Mustafabad (82/100), Kashmere Gate (79/100)...
Q: "Show water issues across Delhi"
A: Found 6 wards with water as dominant issue. ⚠️ Anomaly: Rohini shows 144% spike...
Q: "What anomalies detected?"
A: 3 wards flagged by Isolation Forest ML: Rohini (water), Mustafabad (electricity), Kashmere Gate...
When a complaint gets transferred between departments without resolution, we track it as a "bounce" or "ping-pong". This system ensures accountability:
- Bounces Initiated - How many times a department passed the complaint to another
- Transfers In - How many complaints arrived at this department
- Transfers Out - How many complaints this department transferred onward
- Bounce Ratio - (Bounces Initiated / Transfers In) × 100 = % of complaints bounced
- Penalty Points - Accumulated for bounce violations and delays
- Auto-escalation - After 3 bounces, escalates to Joint Secretary Committee
MCD (Municipal Corporation of Delhi) - WORST OFFENDER
- Bounces Initiated: 24 🔴
- Transfers In: 156 complaints
- Bounce Ratio: 15.4% (1.54:1 average)
- Penalty Points: 48
- Badge: 🔴 WORST OFFENDER
DJB (Delhi Jal Board)
- Bounces Initiated: 12
- Transfers In: 89 complaints
- Bounce Ratio: 13.5%
- Penalty Points: 24
PWD (Public Works Department)
- Bounces Initiated: 8
- Transfers In: 67 complaints
- Bounce Ratio: 11.9%
- Penalty Points: 16
GET /api/dashboard/overview- Complete dashboard snapshotGET /api/dashboard/stats- City stats (total complaints, active alerts, emergency count)GET /api/dashboard/city-csi- City-wide stress index with levelGET /api/dashboard/wards/stress-index- All 40 wards CSI scores
GET /api/dashboard/wards/{ward_id}- Detailed ward analysis with CSI, complaints, sentimentGET /api/map/wards- GeoJSON with all wards + CSI data overlay
GET /api/alerts- All alerts (acknowledged + active)GET /api/alerts/active- Only unacknowledged active alertsGET /api/alerts/critical- Most critical current alert for bannerGET /api/alerts/stats- Alert statistics (total, emergency, critical, warning)POST /api/alerts/{alert_id}/acknowledge- Mark alert as acknowledgedGET /api/alerts/{alert_id}- Detail of specific alert with officer info
POST /api/ai/chat- Send message to AI Assistant- Input:
{"message": "Which wards have water issues?"} - Output: AI response with data sources and suggested follow-ups
- Input:
GET /api/ai/suggested-queries- Get 4 default query buttons with icons
GET /api/ping-pong/departments/shame-stats- Department performance metricsGET /api/ping-pong/summary- Overall complaint bouncing statisticsGET /api/ping-pong/complaints- All tracked complaints with transfer history
GET /api/stream/live- SSE stream of live complaints in real-timeGET /api/stream/stress- SSE stream of CSI updates for gauge animation
# Clone repository
git clone https://github.com/your-org/rajya-net-mri.git
cd rajya-net-mri
# Run setup script
chmod +x setup.sh
./setup.shThe setup script will automatically:
- ✅ Create Python virtual environment
- ✅ Install all backend dependencies (FastAPI, Pydantic, Scikit-learn, etc.)
- ✅ Install all frontend dependencies (React, Vite, Recharts, etc.)
- ✅ Generate 500+ historical complaint records
- ✅ Load 40 Delhi ward boundaries from GeoJSON
- ✅ Start backend server (port 8000)
- ✅ Start frontend dev server (port 3000)
- ✅ Open dashboard in default browser
Backend Setup:
cd backend
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000Frontend Setup:
cd frontend
npm install
npm run devAccess Dashboard:
Frontend: http://localhost:3000
Backend API: http://localhost:8000
API Docs: http://localhost:8000/docs (Interactive Swagger)
# Build and run with Docker Compose
docker-compose up --build
# Access
Frontend: http://localhost:3000
Backend: http://localhost:8000rajyanet-civic-mri/
│
├── backend/
│ └── app/
│ ├── main.py # FastAPI entry point + lifespan
│ ├── config.py # Configuration & constants
│ │
│ ├── models/
│ │ ├── civic_stress.py # CSI dataclasses
│ │ └── schemas.py # Pydantic request/response models
│ │
│ ├── routers/ # API endpoint definitions
│ │ ├── dashboard.py # Dashboard data endpoints
│ │ ├── alerts.py # Alert management endpoints
│ │ ├── map.py # GeoJSON endpoints
│ │ ├── ai_chat.py # AI chat & query endpoints (REAL-TIME DATA)
│ │ ├── ping_pong.py # Department tracking
│ │ ├── ingestion.py # Complaint ingestion
│ │ └── chronic.py # Chronic failure tracking
│ │
│ ├── services/ # Core business logic
│ │ ├── stress_index.py # CSI calculation engine
│ │ ├── alert_dispatcher.py # Alert generation & management
│ │ ├── anomaly_detector.py # Isolation Forest ML detector
│ │ ├── sentiment_engine.py # Hindi/English sentiment analysis
│ │ ├── data_simulator.py # Demo data & ward metadata (507 complaints)
│ │ ├── ping_pong_tracker.py # Complaint transfer tracking
│ │ ├── knowledge_graph.py # Complaint relationship graph
│ │ └── topic_modeler.py # Issue category classification
│ │
│ └── data/
│ ├── delhi_wards.geojson # 40 wards boundaries
│ ├── seed_complaints.json # 500+ historical complaints
│ ├── issue_taxonomy.json # Issue categories
│ └── sample_alerts.json # Demo alert templates
│
├── frontend/
│ ├── src/
│ │ ├── App.jsx # Main app component
│ │ ├── main.jsx # React entry point
│ │ │
│ │ ├── pages/
│ │ │ ├── Dashboard.jsx # Main dashboard (360° gauge, leaderboard, feed)
│ │ │ ├── AlertsPage.jsx # Alerts management page
│ │ │ ├── MapView.jsx # Full-screen interactive map
│ │ │ ├── WardDetail.jsx # Ward detail view
│ │ │ ├── ChronicPage.jsx # Chronic failure tracking
│ │ │ └── PingPongPage.jsx # Department Performance Board (Shame Board)
│ │ │
│ │ ├── components/
│ │ │ ├── dashboard/
│ │ │ │ ├── StressGauge.jsx # CSI gauge (full 360° circle)
│ │ │ │ ├── WardLeaderboard.jsx # Top 5 stressed wards scrollable
│ │ │ │ ├── IssueBreakdown.jsx # Category pie chart
│ │ │ │ ├── TrendChart.jsx # 24h trend line chart
│ │ │ │ ├── AlertFeed.jsx # Active alerts list with WhatsApp preview
│ │ │ │ └── DepartmentBoard.jsx # Department shame stats
│ │ │ │
│ │ │ ├── map/
│ │ │ │ ├── CivicHeatmap.jsx # Interactive GeoJSON map with legend
│ │ │ │ └── WardTooltip.jsx # Ward info tooltip on hover
│ │ │ │
│ │ │ ├── ai/
│ │ │ │ └── CivicAssistant.jsx # AI chat panel with 4 quick buttons
│ │ │ │
│ │ │ ├── layout/
│ │ │ │ ├── Sidebar.jsx # Navigation sidebar
│ │ │ │ └── TopBar.jsx # Header with live indicator
│ │ │ │
│ │ │ └── shared/
│ │ │ ├── PulseIndicator.jsx # Live status badge
│ │ │ └── StressBadge.jsx # Stress severity badge
│ │ │
│ │ ├── hooks/
│ │ │ ├── useAIChat.js # AI chat state + real-time suggestions
│ │ │ ├── useLiveStream.js # SSE real-time streaming
│ │ │ └── useWardData.js # Ward data fetching
│ │ │
│ │ ├── styles/
│ │ │ ├── global.css # Global styles & CSS variables
│ │ │ └── themes.css # Dark theme definitions
│ │ │
│ │ └── utils/
│ │ ├── formatters.js # Data formatting helpers
│ │ └── stressColors.js # Color mapping (Green to Red)
│ │
│ ├── package.json
│ ├── vite.config.js
│ └── index.html
│
├── ml/
│ ├── sentiment/
│ │ ├── indicbert_wrapper.py # Optional BERT model wrapper
│ │ └── lexicon_fallback.py # Fallback Hindi/English lexicon
│ │
│ ├── anomaly/
│ │ └── isolation_forest.py # Scikit-learn ML detector
│ │
│ ├── stress_index/
│ │ └── composite_calculator.py # CSI formula (40/35/25 weights)
│ │
│ └── topic_modeling/
│ └── bertopic_engine.py # Issue category classification
│
├── docker-compose.yml # Container orchestration
├── setup.sh # One-click setup script
├── requirements.txt # Python dependencies
├── package.json # Node.js dependencies
└── README.md # This comprehensive documentation
CSI = (0.40 × Complaint_Volume_Normalized) +
(0.35 × Negative_Sentiment_Ratio) +
(0.25 × Anomaly_Score)
Where:
• Complaint_Volume_Normalized = (complaints_24h / max_complaints) × 100
• Negative_Sentiment_Ratio = % of complaints with negative sentiment (-0.5 to -1.0)
• Anomaly_Score = Isolation Forest deviation from 7-day trend (0-100)
Result: CSI Score 0-100
Input Data:
- Complaints (24h): 18 messages
- Max complaints (city): ~45 average
- Negative sentiment: 89% of complaints
- 7-day average: 12.5 complaints/day
- Today: 18 complaints = 144% of average
Calculation:
Complaint Volume: (18 / 45) × 100 = 40.0
0.40 × 40 = 16.0 points
Sentiment: 89% negative = 0.89
0.35 × 89 = 31.15 points
Anomaly: 144% of 7-day avg = 100 (maximum)
0.25 × 100 = 25.0 points
─────────────────────────────
CSI = 16.0 + 31.15 + 25.0 = 72.15 → rounds to 75/100
Interpretation: 🟠 CRITICAL - Intervention needed immediately
| CSI Range | Level | Status Badge | Required Action |
|---|---|---|---|
| 0-25 | 🟢 STABLE | Green zone | Routine monitoring |
| 26-50 | 🟡 ELEVATED | Yellow zone | Escalate planning |
| 51-75 | 🟠 CRITICAL | Orange zone | Deploy resources now |
| 76-100 | 🔴 EMERGENCY | Red zone | Immediate emergency response |
- Framework: FastAPI (modern async Python framework)
- Async Runtime: Python asyncio with SSE-Starlette for real-time streaming
- Data Validation: Pydantic v2 for schema validation
- ML Libraries: Scikit-learn (Isolation Forest for anomalies)
- Language Processing: Custom NLP engines (Hindi/English/Hinglish)
- Data Storage: Persistent JSON + in-memory caching
- Server: Uvicorn ASGI server with hot-reload
- Framework: React 18 + Vite (ultra-fast development)
- Maps: React-Leaflet + Leaflet.js for interactive GeoJSON
- Data Visualization: Recharts (D3.js-powered charts)
- Animations: Framer Motion for smooth transitions
- Icons: Lucide React (600+ professional SVG icons)
- State Management: React Hooks (useContext, useEffect, useState)
- HTTP Client: Axios for API communication
- Styling: CSS-in-JS with CSS custom properties (variables)
- Anomaly Detection: Isolation Forest (scikit-learn)
- Sentiment Analysis: Custom lexicon-based engine (300+ terms)
- Topic Modeling: TF-IDF vectorization + cosine similarity
- Time Series: Rolling averages for trend analysis
- Containerization: Docker + Docker Compose
- Package Managers: pip (Python), npm (Node.js)
- Build Tools: Vite (frontend), Uvicorn (backend)
- Development: Hot module reloading for rapid iteration
- Dark, cinematic dashboard loads with fade-in animation
- Delhi map renders with color-coded wards (green to red)
- CSI gauge initializes and animates to 40/100 (STABLE)
- Top Stressed Wards populate with real CSI data
- Active Alerts panel shows 3 critical/emergency alerts (with officers assigned)
- Live Complaint Feed starts SSE streaming real complaints
- Click red-colored ward (Rohini Sector 3, CSI 87/100)
- Tooltip shows: Ward name, CSI score, dominant issue
- See 24-hour trend chart with spike visualization
- Anomaly badge shows: "
⚠️ SPIKE - Water complaints 144% above 7-day average"
- Open AI Assistant panel (bottom right)
- Click "Which wards have the highest stress?"
- Get instant response with top 5 wards, CSI scores, recommended actions
- All powered by real backend data fetching
- Navigate to "Transfer Tracker" page
- See Department Performance Board
- MCD highlighted in red: "WORST OFFENDER - 12 bounces, 15.4% bounce ratio"
- Understand complaint bouncing between departments
- View detailed alert for Rohini water crisis
- Click "NOTIFY OFFICER"
- WhatsApp preview shows pre-formatted message:
🚨 EMERGENCY — RajyaNET Alert Ward: Rohini Sector 3 Issue: Water Crisis Civic Stress Index: 87/100 18 complaints received in last 6h Recommended Action: Deploy emergency water tankers (2-3 units)
-
Real-Time Dashboard ✓
- Live monitoring of all 40 Delhi wards
- SSE streaming for instant updates
- Professional government interface
-
AI/ML Intelligence ✓
- Civic Stress Index composite metric with weighted formula
- Isolation Forest anomaly detection for emerging crises
- NLP sentiment analysis (Hindi/English/Hinglish, 300+ terms)
- Intelligent chatbot with real-time data retrieval
-
Citizen Engagement ✓
- Natural language queries ("Pani ki problem kahan hain?")
- Complaint sentiment tracking
- Real-time feedback integration via SSE
-
Government Accountability ✓
- Department Performance Board (Ping-Pong tracking)
- Inter-departmental transfer tracking
- Automated escalation for chronic bouncing (3-bounce rule)
-
Predictive Capability ✓
- Anomaly detection before crisis peaks
- Trend analysis for early warning
- Recommended actions per issue type
-
Scalability ✓
- Handles 500+ historical complaints
- Processes 40 wards with real-time CSI calculations
- Concurrent SSE support for multiple users
-
Data Privacy ✓
- No personal citizen data stored
- Sentiment scores only (not complaint text)
- Government-only dashboard access
-
Advanced Features (Beyond Scope) ✓
- Real-time AI assistant with live data
- Department accountability shameboard
- WhatsApp alert integration
- Anomaly spike detection
- Multi-language support
- Frontend Dashboard: http://localhost:3000
- Backend API Docs: http://localhost:8000/docs (Interactive Swagger)
- Setup Guide: See
setup.sh
Port Already in Use:
# Windows
netstat -ano | findstr :8000
taskkill /PID <PID> /F
# macOS/Linux
lsof -i :8000 | grep LISTEN | awk '{print $2}' | xargs kill -9Missing Dependencies:
pip install -r requirements.txt --upgrade
npm install --legacy-peer-depsClear Demo Data & Reset:
rm backend/app/data/seed_complaints.json
# Restart backend to regenerate404. Not Found
Built with dedication for India Innovates 2026 Hackathon
✅ Real-time Civic Stress Index engine with weighted formula ✅ Isolation Forest anomaly detection (ML-based) ✅ Hindi/English/Hinglish sentiment analyzer ✅ Advanced AI chat assistant (real-time data integration) ✅ Interactive government dashboard (360° gauge, leaderboards, trends) ✅ Department accountability "Shame Board" (Ping-Pong tracking) ✅ WhatsApp alert integration with officer routing ✅ Professional GeoJSON map with color-coded wards ✅ Live SSE complaint streaming ✅ Comprehensive API with interactive docs
MIT License - Built for hackathon demonstration and government adoption
This project is intended to be the foundation for actual municipal governance systems across Indian cities. Released under MIT for transparency and government adoption.
For hackathon demo or implementation inquiries:
- 📧 Email: contact@rajya-net.in
- 🌐 Website: rajya-net.in
- 📱 Support: India Innovates 2026 Technical Support
Last Updated: March 27, 2026
Version: 1.0.0 (Hackathon Release)
Status: Production Ready for Government Evaluation
Team: 404. Not Found