An AI‑powered civic issue management platform that helps citizens report problems quickly and helps city officials act faster and more transparently.
FixMyCity combines computer vision, voice + WhatsApp automation, a smart department classifier, and a citizen chatbot to create a unified pipeline from issue detection → triage → resolution → citizen acknowledgement.
-
Problem: Civic issues like potholes, broken streetlights, water leakage, overflowing garbage, etc. are often:
- Reported late (or not at all),
- Sent to the wrong department,
- Poorly tracked, with no feedback to citizens.
-
Solution: FixMyCity provides:
- Multi‑channel reporting: automated AI detection, SOS hardware buttons, voice calls, chatbot, and certificates over WhatsApp.
- AI‑based triage: classifies issues into the right civic department using CNN models and LLMs.
- Central backend: unified APIs that aggregate all issues on a live map/dashboard.
- Citizen feedback: auto‑generated resolution certificates shared digitally.
The project is organized as several focused micro‑services:
-
backend_python/– Flask backend for:- Receiving SOS alerts from physical boxes / simulators.
- Receiving AI‑detected issues (e.g. pothole detection).
- Storing issues in memory and exposing them via APIs for the frontend/map.
- Managing vehicle live locations (for field teams / response vehicles).
-
agentic-chatbot-user/– FastAPI + Gemini based citizen service chatbot for Mumbai:- Answers questions about local civic services.
- Uses a structured
citizen_services_geo.jsonlookup. - Falls back to an LLM (Gemini) when data is not in the JSON.
-
ml-dept-classifier/– Civic department classifier:- CNN‑based PyTorch model (
models/best_model.pth) to classify issue images into:roads,sanitation,electricity,water,other.
- FastAPI service (
app.py) for programmatic classification. - Streamlit UI (
src/streamlit_app.py) to upload images and view predictions.
- CNN‑based PyTorch model (
-
user-certificate/– Issue resolution certificate generator:- Generates personalised certificates using
Pillowon a PNG template. - Prepares links for WhatsApp delivery via Twilio (utility code provided).
- Generates personalised certificates using
-
backend_python/calling_agent.py– Twilio Voice + Whisper + Gemini agent:- Citizens can call a number and verbally describe issues.
- Audio is recorded by Twilio, transcribed via Whisper, and summarized/replied via Gemini/OpenAI.
-
Root Node package (
package.json):- Provides supporting Node utilities (WebSocket, Twilio, Google GenAI integrations, i18n, etc.).
- Can be used by a frontend or gateway service if needed.
-
AI‑powered detection
- YOLOv8 based pothole detection training script (
backend_python/train_model.py). - Designed to be extended to other visual civic issues.
- YOLOv8 based pothole detection training script (
-
SOS hardware integration
/report_sos_issueendpoint ingests alerts from physical SOS buttons or simulators.- Issues are stored and served to a dashboard via
/get_sos_alertsand/get_issues.
-
Voice‑based citizen assistant
- Twilio Voice webhook (
/voice,/outbound_voice) handles Hindi speech. - Whisper converts speech → text; Gemini/OpenAI generates empathetic responses.
- Twilio Voice webhook (
-
Department classifier for routing
- Given an image URL, the classifier predicts the responsible department.
- Used to route issues to
roads,sanitation,electricity,water, orother.
-
Citizen services chatbot
- FastAPI + Gemini chatbot with CORS enabled for local and hosted frontends.
- Uses
citizen_services_geo.jsonfor department + location lookups.
-
Digital resolution certificates
- High‑quality PNG certificates generated from templates + TrueType fonts.
- Designed to be sent over WhatsApp via Twilio using public URLs (e.g. ngrok).
- Languages: Python, JavaScript/TypeScript
- Frameworks & Libraries:
- Backend: FastAPI, Flask, Flask‑CORS
- ML / CV: PyTorch, torchvision, ultralytics YOLOv8, scikit‑learn
- UI: Streamlit, (Node package prepared for frontend integrations)
- AI: LangChain, Gemini (
langchain-google-genai), Whisper, OpenAI - Messaging/Telephony: Twilio (Voice + WhatsApp)
- Others:
requests,pandas,Pillow,python-dotenv,ws
From FixMyCity-SIH-2025/SIH-2025f:
-
agentic-chatbot-user/main.py– FastAPI chatbot service.citizen_services_geo.json– department/location data.requirements.txt– dependencies for this service.
-
backend_python/app.py– core SOS + AI issue + vehicle location Flask API.calling_agent.py– Twilio voice bot + Whisper + Gemini/OpenAI.train_model.py– YOLOv8 training script for pothole detection.yolov8n.pt– base YOLOv8 model (lightweight).requirements.txt– dependencies for backend services.
-
ml-dept-classifier/app.py– FastAPI model inference service.models/best_model.pth– trained CNN weights.src/model.py,src/inference.py,src/train.py– model definition and training pipeline.src/streamlit_app.py– Streamlit frontend.
-
user-certificate/templates/certificate_template.png– base certificate design.fonts/– custom fonts (Alice-Regular.ttf,ARIAL.TTF,Skrine.otf).utils/certificate_generator.py– certificate rendering logic.utils/whatsapp_sender.py– Twilio WhatsApp sender (currently commented/sample code).main.py– orchestrates certificate generation and WhatsApp sending.
-
Root files
requirements.txt– consolidated Python dependencies (ML + Streamlit + Twilio + Flask, etc.).package.json– Node dependencies (Google GenAI, Twilio, WebSocket, i18n, etc.).
- Python: 3.9+ recommended.
- Node.js: 18+ (if you plan to use Node utilities / frontend).
- pip / venv: for managing Python dependencies.
- ffmpeg: required for Whisper (speech‑to‑text) used in
calling_agent.py. - Twilio account: for Voice and WhatsApp flows.
- Google Gemini / OpenAI API keys: for LLM‑based responses.
The services are intentionally decoupled. You can run only the parts you need (for example, just the chatbot + department classifier) or run everything for a full demo.
All commands assume you are in:
cd FixMyCity-SIH-2025/SIH-2025fIt is recommended to create separate virtual environments per service to keep dependencies clean.
Environment variables
Create a .env file in agentic-chatbot-user/ with:
GOOGLE_API_KEY=your_gemini_api_key_hereInstall & run
cd agentic-chatbot-user
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
# source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8001 --reloadThe service exposes:
POST /chat– body:{ "query": "your question" }→{ "reply": "answer" }
Environment variables
Some endpoints do not require special env variables, but Twilio‑related features (in calling_agent.py) will.
Install & run
cd backend_python
python -m venv .venv
.venv\Scripts\activate # or source .venv/bin/activate
pip install -r requirements.txt
python app.pyThis starts the Flask app on http://0.0.0.0:5003 (see app.py).
Key endpoints (app.py)
POST /report_sos_issue– receive SOS alerts from hardware/simulators.GET /get_sos_alerts– list active SOS alerts.POST /report_issue– ingest AI‑detected issues (e.g. from CV models).GET /get_issues– list all issues.POST /resolve_issue– mark an issue as resolved and remove it.POST /update_location– update a vehicle’s lat/lon.GET /get_locations– fetch current vehicle locations.
Environment variables (.env or system)
Set at least:
PUBLIC_BASE_URL=https://your-ngrok-or-public-domain
TWILIO_ACCOUNT_SID=...
TWILIO_AUTH_TOKEN=...
TWILIO_FROM_NUMBER=+1XXXXXXXXXX # Twilio phone number in E.164 format
GEMINI_API_KEY=... # recommended
OPENAI_API_KEY=... # optional fallbackInstall & run
Use the same virtual environment created in backend_python or a fresh one:
cd backend_python
python calling_agent.pyThis starts a Flask app on http://0.0.0.0:5004.
Configure your Twilio Voice webhook to:
- Incoming calls →
POST {PUBLIC_BASE_URL}/voice
Install & run FastAPI service
cd ml-dept-classifier
python -m venv .venv
.venv\Scripts\activate # or source .venv/bin/activate
pip install -r ../requirements.txt # uses shared requirements
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadRun Streamlit UI
In another terminal (with the same venv activated):
cd ml-dept-classifier
streamlit run src/streamlit_app.pyThe FastAPI app (app.py) exposes:
GET /– health/info message.POST /predict_url–{ "image_url": "https://..." }→ prediction JSON.
The Streamlit app (src/streamlit_app.py) lets you upload an image and view the predicted department + confidence.
Environment variables
For full WhatsApp integration (when you enable the Twilio sender utility), you need:
TWILIO_ACCOUNT_SID=...
TWILIO_AUTH_TOKEN=...
TWILIO_WHATSAPP_NUMBER=whatsapp:+1XXXXXXXXXXThe current utils/whatsapp_sender.py is provided as a template and is commented out. You can adapt and enable it as needed.
Install & run
cd user-certificate
python -m venv .venv
.venv\Scripts\activate # or source .venv/bin/activate
pip install -r ../requirements.txt
python main.pymain.py demonstrates trigger_certificate_process(...), which:
- Generates a PNG certificate using
certificate_generator.py. - Builds a public URL using a hard‑coded ngrok URL in the script.
- Sends the link via WhatsApp (when Twilio integration is enabled).
You can import trigger_certificate_process into other services (e.g. after an issue is marked resolved in backend_python/app.py) to automatically send certificates.
The script backend_python/train_model.py shows how to fine‑tune YOLOv8:
- Update
dataset_yaml_pathin the script to point to your custom dataset’sdata.yaml. - Run:
cd backend_python
python train_model.pyAfter training, copy the generated best.pt from:
training_results/pothole_detector/weights/best.pt
into the appropriate backend folder and update any inference scripts you add.
The CNN‑based classifier is defined and trained using:
ml-dept-classifier/src/model.py– model architecture.ml-dept-classifier/src/train.py– training loop.ml-dept-classifier/src/dataloader.py– dataset loading helpers.
You can:
- Prepare a labeled dataset of issue images.
- Adjust classes and transforms in these files.
- Retrain and save a new
best_model.pthinmodels/.
Depending on which modules you run, you may need some or all of these:
-
LLM / AI
GOOGLE_API_KEY– for chatbot (Gemini via LangChain).GEMINI_API_KEY– for voice agent’s Gemini calls.OPENAI_API_KEY– optional fallback for voice agent.
-
Twilio (Voice & WhatsApp)
TWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENTWILIO_FROM_NUMBER– for voice calls.TWILIO_WHATSAPP_NUMBER– for WhatsApp messages (when enabled).
-
Public URL
PUBLIC_BASE_URL– e.g. ngrok HTTPS URL that Twilio can reach.
Keep secrets in .env files and never commit them to git.
A suggested end‑to‑end demo:
- Start SOS + AI backend (
backend_python/app.py). - Start department classifier (
ml-dept-classifier/app.py) and Streamlit UI. - Start the citizen chatbot (
agentic-chatbot-user/main.py) and connect a simple web UI or test via tools like Postman. - (Optional) Start the voice agent (
calling_agent.py) and configure Twilio. - (Optional) Start the certificate generator and wire it into the issue resolution flow.
This shows:
- Issues coming from multiple channels (SOS button, AI CV module, chatbot, voice).
- Smart routing to departments using ML.
- Visibility into issues via APIs / dashboards.
- Citizens receiving digital proof of resolution.
- Parts of the system (especially Node utilities and frontend) are intentionally minimal or stubbed and can be further expanded.
- Feel free to adapt port numbers, endpoints, and deployment strategies to your infrastructure.
- Consider containerizing each service (Docker) for easier deployment in production or on cloud platforms.