JanSamadhan
AI Powered Civic System
// Overview
JanSamadhan is an automated civic grievance routing system deployed as an experimental ward pilot in Delhi, India. It ingests infrastructure failure reports from local citizens (such as broken street lights, open manholes, or waste piles), resolves their geo-coordinates, and dynamically categorizes and routes them to 10+ distinct municipal departments. By implementing smart deduplication check pipelines, the application limits ticket flood while notifying citizens transparently via automated message webhooks.
// The Problem
Municipal governance in high-density urban areas like Delhi is notoriously fragmented. Citizens reporting a local hazard must navigate a web of overlapping public authorities—the Municipal Corporation of Delhi (MCD), Delhi Development Authority (DDA), Public Works Department (PWD), and regional electricity boards. This leads to high bounce rates, dropped complaints, and general citizen distrust.
Furthermore, when a major public hazard occurs (e.g., a collapsed main sewer line on a busy market road), dozens of citizens submit the same report within hours. In legacy systems, this floods departmental queues with redundant entries, forcing manual verification and wasting administrative hours.
// Key Architectures & Solutions
1. WhatsApp Webhook Ingestion: An async FastAPI pipeline to swallow rapid callback updates under high loads. Uses connection pooling and background workers to avoid serverless cold start timeout issues.
2. Duplicate Suppression: Uses custom PostGIS spatial queries (`ST_DWithin`) to automatically match and link complaints submitted within a proximity radius of the same category, preventing ticket spam.
3. Department RLS & RBAC: Features a 20-table Postgres schema protected by 28 Row Level Security (RLS) policies ensuring government operators only see and modify tickets scoped within their administrative ward.
4. FastAPI & Redis Optimization: Aggressive caching and database index optimization to handle peak throughput smoothly.
WhatsApp Webhook Cold Start
Handling latency spikes on serverless cold starts for WhatsApp Cloud API callbacks; resolved by implementing background warm-up pings, aggressive connection pooling, and an async task queue.
PostGIS Duplicate Detection
Detecting duplicate grievances submitted within a radius of X meters across 42 categories; implemented customized spatial indexing using PostGIS and ST_DWithin querying to throttle repetitive complaints.
Multi-Authority RBAC Scoping
Designing role-based access controls for 10+ government departments with rigid per-ward administrative scoping. Architected a 20-table schema with 28 strict PostgreSQL Row Level Security (RLS) policies.
FastAPI Tuning at Scale
Optimizing async request endpoints to process 4K to 8K requests per day. Established low-latency Redis caching layers, query optimization, and structured error handling for 99.9% live availability.