Jana Sunuwaai ("public hearing") is a full-stack web application that modernizes how citizens report public infrastructure and municipal problems — and how government departments receive and prioritize them.
Citizens report a wide range of civic issues (road damage, garbage dumping, broken streetlights, drainage failures, and public infrastructure defects) through a five-step web wizard. Every report carries a photo, a GPS fix, a severity rating and a timestamp, and is automatically routed to the department that actually owns the problem.
For road damage, the platform goes further: a fine-tuned YOLOv8 model detects potholes in the uploaded photo, and OpenCV heuristics translate the bounding box into real-world dimensions, surface conditions, and a priority score that departments can sort a work queue by.
All five categories are live and route to their real owning department:
| Category | Routed to | Severity source |
|---|---|---|
| Road Damage | Department of Roads | AI-detected (YOLOv8 + OpenCV) |
| Electrical / Street Lights | Nepal Electricity Authority (NEA) | Citizen-rated |
| Water & Sanitation | Department of Urban Development | Citizen-rated |
| Waste Management | KMC Waste Management Division | Citizen-rated |
| Public Spaces | Kathmandu Metropolitan City | Citizen-rated |
On AI coverage: only road damage has a trained detection model today, because that is the only category we have labelled training data for. The other four categories deliberately skip AI inference entirely and instead collect a citizen-supplied severity (Low / Medium / High) for human triage — the system never fabricates a detection result it cannot actually produce. Extending detection to the remaining categories is on the roadmap.
- Five-step reporting wizard — category → location → photo → details → review. Interactive Leaflet maps with a draggable pin, and on-device image compression so submission works on a slow connection.
- AI pothole detection — YOLOv8 object detection fine-tuned on Nepali road imagery, returning bounding boxes and confidence scores.
- Physical measurement estimation — OpenCV heuristics convert 2D boxes into estimated width, depth and surface area, and classify road material (asphalt, concrete, gravel) and weather conditions.
- Automatic department routing — every report is matched to its owning department, with a priority score derived from either AI confidence × severity or the citizen's own severity rating.
- Duplicate and cluster detection — nearby reports are grouped so one bad junction raises a single reconstruction alert rather than fifty separate tickets.
- Community verification — public feed with up/down voting and comments, so citizens corroborate each other's reports without staff effort.
- Decoupled inference — expensive ML work runs behind Celery and Redis in production, so a slow model never blocks a citizen's upload.
- Secure access control — email/password auth with JWT tokens and bcrypt-hashed credentials.
Detection metrics from the final YOLOv8 training run, measured on a held-out validation set:
| Metric | Score |
|---|---|
| mAP@50 | 99.2% |
| Precision | 98.0% |
| Recall | 97.7% |
| mAP@50-95 | 75.5% |
Trained for 30 epochs on 329 hand-labelled images plus an equal set of augmented composites. Inference runs on CPU in roughly three seconds — no GPU required to deploy.
Check out the latest system walkthrough and AI pothole detection demo (Local File):
- Video: 4o2.mp4
Detailed analysis and technical documentation of the system's performance:
- PDF: Reports.pdf
- Core: React 18, Vite
- Styling & UI: Tailwind CSS, Framer Motion, Lucide-React
- State Management: Zustand
- Maps: Leaflet, React-Leaflet
- Image Optimization: Browser-Image-Compression
- Framework: FastAPI, Uvicorn
- Database: SQLite for local development (tables auto-created on startup), PostgreSQL-ready via SQLAlchemy 2.0 ORM + Alembic migrations for production
- Background Tasks: Celery, Redis (bypassed locally via
CELERY_TASK_ALWAYS_EAGER=true) - Machine Learning: PyTorch, Ultralytics (YOLOv8)
- Computer Vision: OpenCV, Pillow, Albumentations
- Data & Auth: Pydantic validation, Python-JOSE (JWT), Passlib (Bcrypt)
4o2/
├── backend/ # Python/FastAPI Backend Services
│ ├── ai/ # YOLOv8 inference pipeline and OpenCV scripts
│ ├── app/ # FastAPI routes, Pydantic schemas, Auth logic
│ ├── alembic/ # PostgreSQL schema migration history
│ └── requirements.txt # Python dependencies (Celery, FastAPI, Torch)
├── frontend/ # Node/React Frontend Application
│ ├── src/ # UI Components, Pages, State Store, API clients
│ └── package.json # React dependencies and scripts
└── package.json # Root workspace configuration
Ensure your development environment meets the following requirements:
- Node.js (v18+ recommended)
- Python 3.12 — the pinned ML dependencies (torch, opencv-python, ultralytics) are built against this version; other 3.x versions may fail to install or import.
- PostgreSQL and Redis are only needed for a production-like setup — see Production configuration below. For day-to-day local development, SQLite and Celery's eager mode cover everything, including AI inference.
Clone the project locally and install all workspace dependencies (this cascades into both frontend/ and backend/ folders):
git clone <project-url>
cd 4o2
# Install frontend and backend dependencies using the root script
npm run install:allWindows users: see COMMANDS.md for a quick-reference cheat sheet (venv activation, individual service commands, etc).
Create a .env file inside the backend/ directory. This is enough to run the full app, including AI inference, with no external services:
# backend/.env
APP_NAME=AI-Pothole-Detection
APP_VERSION=1.0.0
DEBUG=true
SECRET_KEY=change-me-in-production-use-a-long-random-string
JWT_SECRET_KEY=change-this-in-prod-min32chars
JWT_ALGORITHM=HS256
JWT_EXPIRE_MINUTES=10080
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
# SQLite for local dev — tables are created automatically on startup, no migrations needed
DATABASE_URL=sqlite:///./ai_pothole_db.sqlite3
# Redis isn't required locally — eager mode runs Celery tasks in-process
REDIS_URL=redis://localhost:6379/0
CELERY_TASK_ALWAYS_EAGER=true
DATASET_DIR=./Data
MODEL_DIR=./models_store
LOG_LEVEL=DEBUG
LOG_FILE=./logs/app.logThe trained model weights the AI pipeline loads (backend/ai/weights/pothole_best.pt) are not tracked in git — get a copy from a teammate or re-train via backend/scripts if you don't already have one.
You can spin up both the Vite frontend server and the FastAPI backend concurrently from the root directory:
npm run devIf you prefer to run the services individually:
- Frontend only:
npm run dev:frontend - Backend only:
npm run dev:backend
With CELERY_TASK_ALWAYS_EAGER=true set, AI inference runs synchronously in the request itself — no Celery worker or Redis server needed for local development.
For a deployment that matches production (persistent Postgres storage, real async task queue), swap the .env values above for:
DATABASE_URL=postgresql://user:password@localhost:5432/jana_sunuwaai
REDIS_URL=redis://localhost:6379/0
CELERY_TASK_ALWAYS_EAGER=falseThen apply migrations and run a Celery worker alongside the API:
cd backend
alembic upgrade head
celery -A app.core.celery_worker.celery_app worker --loglevel=infoWith the backend running locally, the auto-generated interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /api/v1/reports/ accepts multipart/form-data and requires a bearer token:
| Field | Required | Notes |
|---|---|---|
image |
yes | JPEG, PNG or WebP, max 10 MB |
latitude, longitude |
yes | Decimal degrees |
category_id |
yes | One of the five category_id values from GET /api/v1/departments |
description |
no | Free text, up to 300 characters |
severity |
conditional | LOW, MEDIUM or HIGH. Required for every category except road_damage, where it is derived from AI detection instead. |
The response reports which path was taken: ai_detected: true means the YOLOv8 pipeline ran and the measurement fields (width_cm, depth_cm, area_sqm, road_type, weather) are populated. ai_detected: false means the report took the manual path — those fields are null and ai_severity carries the citizen's own rating.
See CONTRIBUTING.md for the development workflow and commit guidelines.
This project is proprietary and confidential. For licensing inquiries, please contact the maintainers.