Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NagarSeva Logo

NagarSeva AI ๐Ÿ›๏ธ

AI-Powered Civic Grievance & Community Safety Platform

Live Demo ยท GitHub ยท Features ยท Tech Stack


NagarSeva empowers citizens to report public infrastructure issues and unsafe areas using AI-powered analysis, real-time GPS tracking, and automatic routing to the correct government authority. The application works out of the box in demo mode without any external API keys or paid services.

๐Ÿ”— Live Demo: https://nagar-seva-ai-xx-devv.vercel.app

GitHub Stars Last Updated Repo Size License Deployment Status


๐Ÿ“‹ Table of Contents


โœจ Features

Feature Description
๐Ÿค– AI-Powered Complaint Filing Describe or upload images; AI classifies, categorizes, and routes issues to the correct department automatically
๐Ÿ—บ๏ธ Interactive Safety Map Full-screen Leaflet map with severity-coded markers, unsafe zone indicators, and category/severity/time-of-day filters
๐Ÿข Smart Department Routing AI determines the correct government department for each complaint based on keywords and context
๐Ÿ“Š Real-time Tracking Track complaints from submission โ†’ assigned โ†’ in progress โ†’ resolved with a detailed status timeline
๐Ÿ“ˆ Public Dashboard Live stats cards, category breakdown bar chart, monthly trend line chart, complaint distribution pie chart, and recent complaints table
๐Ÿ‘ฎ Authority Dashboard Full complaint management panel with search, department/severity/status filters, status update buttons, escalation indicators for overdue complaints
๐Ÿ“ GPS Auto-detection Browser Geolocation API with OpenStreetMap reverse geocoding for precise location
๐Ÿ™ˆ Anonymous Reporting Report issues without revealing your identity โ€” toggle on/off during submission
๐Ÿ” Demo Authentication Instant one-click login as Citizen or Authority โ€” no registration required
๐Ÿ’พ Persistent Storage SQLite backend stores all complaints persistently across server restarts
๐Ÿ“ฑ Fully Responsive Adaptive layout works seamlessly on mobile, tablet, and desktop

๐ŸŒ Pages & Routes

Route Page Description
/ Landing Hero section with stats, feature cards, how-it-works walkthrough, and CTA
/report Report Issue 3-step wizard: describe issue (with AI analysis), add location & photo, review & submit
/safety-map Safety Map Full-screen Leaflet map with severity-coded markers, unsafe zone circles, and multi-dimensional filters
/dashboard Public Dashboard Stat cards, category breakdown bar chart, monthly trend line chart, department workload bars, pie chart, recent complaints table
/track Track Complaint Search by tracking ID with animated status timeline and full complaint details
/authority Authority Dashboard Complaint management with search, department/severity/status filters, expandable details, status update actions, escalation warnings
/auth/login Login Email/password form plus one-click demo login buttons for Citizen and Authority roles
/auth/register Register Create a new account (demo mode โ€” works without email verification)
/about About Mission statement, core values, tech stack overview, team section, contact information

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Purpose
React 18 + TypeScript Component-based UI with full type safety
Vite Fast development server and optimized production builds
TailwindCSS Utility-first responsive styling with custom design system
Framer Motion Smooth page transitions and micro-interactions
React Router v6 Client-side routing with lazy loading support
React Query v5 Server state management, caching, and background refetching
Leaflet + React Leaflet Interactive maps with custom markers and overlays
Lucide React Consistent, lightweight icon system
Recharts Responsive bar, line, and pie charts for the dashboard

Backend

Technology Purpose
FastAPI (Python) High-performance async REST API with automatic OpenAPI docs
Pydantic v2 Request/response validation with strict typing
Uvicorn ASGI server for production-ready Python apps
SQLite (built-in) Zero-configuration persistent storage โ€” no database server needed

๐Ÿ Quick Start (Local Development)

Prerequisites

1. Clone & Install Frontend

git clone https://github.com/xx-devvv/NagarSevaAI.git
cd NagarSevaAI/client
npm install
npm run dev

The frontend development server starts on port 5173.

2. Install & Start Backend

Open a second terminal:

cd NagarSevaAI/server
pip install fastapi uvicorn pydantic pydantic-settings python-dotenv python-multipart
python -m uvicorn app.main:app --reload --port 8000

The API server starts on port 8000. Interactive API documentation is available at /docs.

3. Explore the App

Open https://nagar-seva-ai-xx-devv.vercel.app or run locally. Everything works immediately with:

  • 10 pre-seeded demo complaints stored in SQLite
  • Mock AI analysis โ€” no API key required
  • One-click demo login for Citizen and Authority roles

๐Ÿ Running the Backend

The backend provides a RESTful API at port 8000. In demo mode, it works entirely offline:

cd server
pip install -r requirements.txt
python -m uvicorn app.main:app --reload --port 8000

Demo behavior:

  • Storage uses SQLite (nagarseva.db) โ€” created automatically on first run
  • 10 sample complaints are seeded when the database is empty
  • All endpoints respond with realistic mock data
  • AI analysis uses keyword matching instead of external APIs
  • No environment variables or configuration files are required

Optional configuration: Copy server/.env.example to server/.env to customize settings.


๐Ÿ”ง External Services (all optional)

Service Purpose Demo Fallback
Google Gemini AI Enhanced AI complaint analysis Keyword-based mock analysis
Firebase Auth Authentication provider Local state with localStorage
Google Maps / Mapbox Map tiles Leaflet + OpenStreetMap (free)
Cloudinary Image storage Upload works without cloud storage
PostgreSQL Production database SQLite (zero-config, built-in)
Redis + Celery Background task processing Not required for demo

โš ๏ธ Note: The live demo deploys the frontend only. It gracefully falls back to built-in demo data when the backend is unreachable โ€” all features work visually. For the full experience with the persistent SQLite backend, run locally.

No paid API keys are needed. The app runs fully in demo mode out of the box.


๐Ÿ“ก API Endpoints

Method Endpoint Description
GET /api/health Health check โ€” returns status and timestamp
POST /api/complaints Create a new complaint (multipart form data)
GET /api/complaints List complaints (supports status, category, severity, department, page, limit filters)
GET /api/complaints/{id} Get a single complaint by internal ID
PATCH /api/complaints/{id}/status Update complaint status with optional notes
GET /api/complaints/track/{tracking_id} Get tracking info by tracking ID (e.g., NS-A7F3)
GET /api/dashboard/stats Dashboard statistics with category breakdown, department workload, and monthly trends
POST /api/ai/analyze AI analysis of complaint text
POST /api/ai/analyze-image AI analysis of uploaded image

Interactive API docs are available at /docs when running the backend locally.


๐Ÿ“ Project Structure

NagarSevaAI/
โ”œโ”€โ”€ client/                     # React + TypeScript Frontend
โ”‚   โ”œโ”€โ”€ public/                # Static assets (favicon, etc.)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ layout/        # Navbar, Footer
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ui/            # Button, shared UI primitives
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/             # useAuth, useGeolocation
โ”‚   โ”‚   โ”œโ”€โ”€ pages/             # Landing, Report, SafetyMap, Dashboard,
โ”‚   โ”‚   โ”‚                      #   Track, Authority, Auth, About
โ”‚   โ”‚   โ”œโ”€โ”€ services/          # API client with snake_caseโ†”camelCase conversion
โ”‚   โ”‚   โ”œโ”€โ”€ types/             # TypeScript interfaces and enums
โ”‚   โ”‚   โ”œโ”€โ”€ utils/             # cn() class merge utility
โ”‚   โ”‚   โ”œโ”€โ”€ config/            # Environment configuration
โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx            # Router configuration
โ”‚   โ”‚   โ”œโ”€โ”€ main.tsx           # Application entry point
โ”‚   โ”‚   โ””โ”€โ”€ index.css          # Tailwind directives and custom component classes
โ”‚   โ”œโ”€โ”€ tailwind.config.js     # Custom design system theme
โ”‚   โ”œโ”€โ”€ vite.config.ts         # Vite configuration with API proxy
โ”‚   โ””โ”€โ”€ package.json           # Dependencies
โ”œโ”€โ”€ server/                    # FastAPI Backend
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/v1/            # REST API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ models/            # Pydantic schemas (Complaint, User, DashboardStats, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ services/          # Storage (SQLite), AI analysis service
โ”‚   โ”‚   โ”œโ”€โ”€ config.py          # Application settings
โ”‚   โ”‚   โ””โ”€โ”€ main.py            # FastAPI app creation and middleware
โ”‚   โ”œโ”€โ”€ .env.example           # Optional environment variables
โ”‚   โ””โ”€โ”€ requirements.txt       # Python dependencies
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

๐Ÿงช Demo Credentials

No registration is required. On the login page, click one of these buttons:

Role Button What You Can Do
๐Ÿ‘ค Citizen Continue as Citizen (Demo) Report issues, view safety map, explore dashboard, track complaints
๐Ÿ›๏ธ Authority Continue as Authority (Demo) All citizen features plus the Authority Dashboard at /authority with complaint management, status updates, and escalation alerts

๐Ÿ“ธ Screenshots

Page Preview
Landing Hero with stats, feature grid, how-it-works, and CTA
Report Issue 3-step wizard with AI analysis, image upload, geolocation
Safety Map Full-screen Leaflet map with severity markers and filters
Dashboard Stats cards, bar/line/pie charts, department workload, recent complaints table
Track Tracking ID search with animated status timeline
Authority Complaint list with filters, expandable details, status actions, escalation badges

Visit the live demo to see all pages in action.


๐Ÿค Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is developed as part of a civic technology initiative. All rights reserved.


Made with โค๏ธ for safer communities.

Live Demo ยท GitHub Repository

About

AI-powered civic grievance & community safety platform for reporting, tracking, and managing public infrastructure issues with intelligent routing and real-time dashboards.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages