ποΈ NagarSeva β AI-Powered Civic Issue Monitoring System
NagarSeva is an end-to-end platform for municipal corporations to detect, track, assign, and resolve civic infrastructure issues like potholes and garbage across city wards. It uses AI/ML-based computer vision for automated detection and provides role-based workflows for Admins, Surveyors, and Engineers.
π Architecture Overview
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NagarSeva Platform β
ββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββββββ€
β Frontend β Surveyor App β Engineer App β Microservices (AI) β
β (Admin Web β (React β (React β (FastAPI + YOLOv8 β
β Dashboard) β Native) β Native) β Pothole Detection) β
ββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββββββββββ€
β Backend (Express.js REST API) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PostgreSQL (via Prisma ORM) + Cloudinary β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SQL Agent (LangChain + Groq LLM) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ποΈ Project Structure
nagarseva/
βββ backend/ # Express.js REST API with Prisma ORM
βββ frontend/ # React (Vite) Admin Dashboard β web app
βββ surveyorApp/ # React Native mobile app for Surveyors
βββ engineerApp/ # React Native mobile app for Engineers
βββ microservices/ # FastAPI AI microservice (YOLOv8 pothole detection)
βββ models/ # Pre-trained YOLO model weights (.pt files)
βββ sql-agent/ # LangChain SQL Agent for natural-language DB queries
βββ README.md # β You are here
Folder
Tech Stack
Purpose
backend/
Node.js, Express, Prisma, PostgreSQL, Cloudinary
Core REST API β auth, CRUD, file uploads, issue lifecycle
frontend/
React 18, Vite, TypeScript, TailwindCSS, shadcn/ui, Recharts, Leaflet
Admin dashboard β analytics, employee mgmt, map view, issue verification
surveyorApp/
React Native 0.83, TypeScript, Vision Camera
Mobile app β surveyors capture road footage, auto-upload frames
engineerApp/
React Native 0.83, TypeScript
Mobile app β engineers view assigned issues, mark as fixed with proof
microservices/
Python, FastAPI, PyTorch, YOLOv8 (Ultralytics)
AI β pothole detection on images & videos, returns annotated results
models/
β
Pre-trained YOLOv8 model weights for pothole and garbage detection
sql-agent/
Python, LangChain, Groq, SQLAlchemy, Flask
NL-to-SQL chatbot β query municipal data using natural language
π₯ User Roles & Workflows
View analytics dashboard (issue counts, resolution rates, ward-wise breakdowns)
Manage employees (create Surveyors & Engineers)
Assign routes to Surveyors for patrol
Assign detected issues to Engineers for resolution
Verify engineer-submitted fixes (approve / reject with feedback)
View all issues on an interactive map (Leaflet)
Chat with the AI SQL Agent for data insights
Login and view assigned route patrols
Accept route assignments
Start survey sessions β camera captures frames every second
Frames are auto-uploaded, processed through AI detection, and issues are logged
End survey sessions
Login and view assigned issues (potholes/garbage)
Accept issue assignments
Navigate to the issue location
Upload after-fix photo as proof of resolution
Mark issue as fixed β goes to admin for final verification
DETECTED β ASSIGNED β IN_PROGRESS β FIXED β RESOLVED
β REJECTED (back to engineer)
DETECTED β AI detects a pothole/garbage from surveyor camera feed
ASSIGNED β Admin (or auto-assignment) assigns the issue to an engineer
IN_PROGRESS β Engineer accepts the assignment
FIXED β Engineer uploads after-fix proof photo
RESOLVED β Admin verifies and approves the fix
REJECTED β Admin rejects the fix with feedback
Make sure you have the following installed:
Tool
Version
Purpose
Node.js
β₯ 20.x
Backend & frontend runtime
npm
β₯ 10.x
Package manager
PostgreSQL
β₯ 15.x
Primary database
Python
β₯ 3.10
AI microservices & SQL agent
Android Studio
Latest
React Native Android builds
JDK
17
React Native Android builds
π Quick Start (Local Development)
git clone https://github.com/vivek1504/NagarSeva.git
cd NagarSeva
cd backend
npm install
cp .env.example .env # Configure your DB URL, Cloudinary keys, JWT secret
npx prisma generate # Generate Prisma client
npx prisma migrate deploy # Run migrations
npx tsx src/seed.ts # (Optional) Seed demo data
npm run dev # Starts on http://localhost:3000
3. Start the Frontend (Admin Dashboard)
cd frontend
npm install
npm run dev # Starts on http://localhost:8080
4. Start the AI Microservice
cd microservices
pip install -r requirements.txt
python app.py # Starts on http://localhost:7860
cd sql-agent
pip install langchain langchain-groq langchain-community sqlalchemy flask python-dotenv
python interface.py # Starts on http://localhost:3000
6. Start Mobile Apps (Surveyor / Engineer)
# Surveyor App
cd surveyorApp
npm install
npx react-native run-android
# Engineer App
cd engineerApp
npm install
npx react-native run-android
π Environment Variables
Variable
Description
Example
DATABASE_URL
PostgreSQL connection string
postgresql://user:pass@localhost:5432/nagarseva
JWT_SECRET
Secret key for JWT token signing
your-jwt-secret
cloudinary_cloud_name
Cloudinary cloud name
dsvgi3ehk
cloudinary_api_key
Cloudinary API key
363457628376739
cloudinary_api_secret
Cloudinary API secret
your-secret
hf_token
HuggingFace API token (for AI model)
Bearer hf_xxx
SQL Agent (environment or .env)
Variable
Description
DATABASE_URL
PostgreSQL connection string (same DB)
GROQ_API_KEY
Groq API key for LLM inference
π§ͺ Default Credentials (Seed Data)
Role
Email
Password
Admin
admin@vmc.gov.in
admin123
Surveyor
amit.patel@vmc.gov.in
password
Engineer
suresh.pandya@vmc.gov.in
password
π Per-Component Documentation
Each folder has its own detailed README:
Layer
Technologies
Frontend
React 18, TypeScript, Vite, TailwindCSS, shadcn/ui, Recharts, Leaflet, i18next, Jotai, Zustand
Mobile
React Native 0.83, TypeScript, React Navigation, Vision Camera
Backend
Node.js, Express 5, TypeScript, Prisma 7, PostgreSQL, Cloudinary, JWT, bcrypt
AI/ML
Python, FastAPI, PyTorch, YOLOv8 (Ultralytics), OpenCV
Data Agent
Python, LangChain, Groq (LLM), SQLAlchemy, Flask
This project is for educational and municipal governance purposes.
Fork the repository
Create your feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'Add amazing feature')
Push to the branch (git push origin feature/amazing-feature)
Open a Pull Request