Skip to content

sshekhar563/JanVaani

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ JanVaani β€” ΰ€œΰ€¨ΰ€΅ΰ€Ύΰ€£ΰ₯€ | Smart Civic Governance Platform

ΰ€œΰ€¨ΰ€€ΰ€Ύ ΰ€•ΰ₯€ ΰ€†ΰ€΅ΰ€Ύΰ€œΰ€Ό, ΰ€¨ΰ₯‡ΰ€€ΰ€Ύ ΰ€•ΰ₯€ ΰ€¦ΰ€Ώΰ€Άΰ€Ύ β€” Voice of the People, Direction for Leaders

An AI-powered Smart Civic Governance Platform built with React + Vite (frontend) and FastAPI + MongoDB (backend). Citizens can report civic issues like potholes, officers resolve them, and AI verifies repairs β€” all tracked with real-time trust scores.


🎯 Features

πŸ§‘β€πŸ€β€πŸ§‘ Citizen Portal

  • Submit complaints with image upload + text description
  • AI-powered pothole detection from road images
  • NLP sentiment & urgency analysis of complaint text
  • Real-time complaint tracking with timeline
  • Community validation of completed repairs

πŸ‘· Officer Dashboard

  • View assigned complaints
  • Upload after-repair proof images
  • AI-powered repair verification (before/after comparison)
  • Performance stats & resolution tracking

🏒 Admin Dashboard (Leadership War Room)

  • Real-time stats: Total Issues, Resolved, Pending, Pothole Alerts
  • Public Trust Index with 4 key metrics (Resolution Speed, Citizen Sentiment, Verified Proof, Communication)
  • AI Priority Inbox β€” issues ranked by urgency Γ— public impact
  • Proof of Work gallery β€” verified completions
  • Quick Insights β€” Critical Alerts, Misinformation, Trending issues

πŸ€– Governance AI Suite (Admin Only)

  • Heatmaps β€” Geographic complaint clustering with KMeans
  • Fraud Detection β€” Duplicate images, suspicious timing, unresolved damage checks
  • Officer Performance β€” Rankings, resolution time, citizen ratings
  • Trust Score Analytics β€” Area-wise and city-wide trust computation
  • Digital Twin β€” City simulation with what-if scenario modeling
  • Predictions β€” Complaint volume forecasting with linear regression

πŸ” Security

  • JWT-based authentication with bcrypt password hashing
  • Role-Based Access Control (RBAC):
    • Admin β†’ Full access to all governance endpoints
    • Department/Officer β†’ Proof upload, assignment views
    • Public/Citizen β†’ Complaint submission, feedback
  • Frontend route protection with role checks

πŸ“ Project Structure

JanVaani/
β”œβ”€β”€ backend/                    # FastAPI Backend
β”‚   β”œβ”€β”€ main.py                 # App entry point + all API routes
β”‚   β”œβ”€β”€ db.py                   # Shared MongoDB handle
β”‚   β”œβ”€β”€ register_routers.py     # Governance router registration
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ rbac.py             # RBAC dependency helpers
β”‚   β”‚   β”œβ”€β”€ workflow.py         # Complaint lifecycle endpoints
β”‚   β”‚   β”œβ”€β”€ fraud.py            # Fraud detection APIs
β”‚   β”‚   β”œβ”€β”€ trust.py            # Trust score APIs
β”‚   β”‚   β”œβ”€β”€ officer_analytics.py # Officer performance APIs
β”‚   β”‚   β”œβ”€β”€ geo.py              # Heatmap & clustering APIs
β”‚   β”‚   β”œβ”€β”€ digital_twin.py     # City simulation APIs
β”‚   β”‚   β”œβ”€β”€ prediction.py       # Forecasting APIs
β”‚   β”‚   └── verification.py     # Work verification APIs
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ trust_service.py    # Trust computation logic
β”‚   β”‚   β”œβ”€β”€ officer_service.py  # Officer metrics from complaints
β”‚   β”‚   β”œβ”€β”€ fraud_service.py    # Fraud checks
β”‚   β”‚   β”œβ”€β”€ prediction_service.py # Linear regression forecasting
β”‚   β”‚   β”œβ”€β”€ digital_twin_service.py # Simulation engine
β”‚   β”‚   └── geo_service.py      # Geographic analytics
β”‚   └── requirements.txt
β”œβ”€β”€ src/                        # React Frontend
β”‚   β”œβ”€β”€ App.jsx                 # Routes + RBAC protection
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ CitizenPortal.jsx   # Complaint submission
β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx       # Admin dashboard
β”‚   β”‚   └── GovernanceDashboard.jsx # AI governance suite
β”‚   └── components/dashboard/
β”‚       β”œβ”€β”€ StatsCards.jsx       # Real-time stats
β”‚       β”œβ”€β”€ TrustIndex.jsx       # Trust score visualization
β”‚       β”œβ”€β”€ PriorityInbox.jsx    # AI-ranked issue queue
β”‚       └── ProofOfWork.jsx      # Verified completions
β”œβ”€β”€ datasets/                   # Analytics datasets
β”‚   └── 311_small.csv           # NYC 311 complaint data
β”œβ”€β”€ data/India/                 # Road damage detection images
β”œβ”€β”€ package.json
└── vite.config.js

πŸš€ Quick Start

Prerequisites

  • Python 3.10+ with pip
  • Node.js 18+ with npm
  • MongoDB β€” running locally or on Atlas (default: mongodb://localhost:27017)

1. Clone the Repository

git clone https://github.com/sshekhar563/JanVaani.git
cd JanVaani

2. Setup Backend (Python Virtual Environment)

# Create and activate virtual environment
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate

# Install dependencies
pip install -r backend/requirements.txt

3. Setup Frontend

npm install

4. Configure Environment

Create a .env file inside backend/ (optional β€” defaults are provided):

MONGODB_URL=mongodb://localhost:27017
SECRET_KEY=janvaani_production_super_secret_key_999
FRONTEND_URLS=http://localhost:5173,http://localhost:3000

5. Start the Application

npm run dev

This starts both servers concurrently:

  • Frontend β†’ http://localhost:5173
  • Backend API β†’ http://localhost:8000

6. Create Admin Account

  1. Go to http://localhost:5173/admin/signup
  2. Enter your details
  3. Use access key: JANVAANI_ADMIN_2024
  4. Login at http://localhost:5173/admin/login

7. Create Citizen Account

  1. Go to http://localhost:5173/signup
  2. Register with email and password
  3. Login at http://localhost:5173/login

8. Run Production Server via Docker (Optional)

We provide a multi-stage Dockerfile that builds the Vite frontend and the Python backend in one container.

docker build -t janvaani:latest .
docker run -p 8000:8000 --env-file backend/.env janvaani:latest

The application will be served at http://localhost:8000.

9. Run End-To-End Integration Tests

python backend/test_e2e.py

πŸ”„ Complete Workflow

Citizen uploads pothole image
  β†’ AI detects pothole (YOLOv8-based detection)
  β†’ NLP analyzes complaint text (sentiment + urgency)
  β†’ Complaint created in MongoDB
  β†’ Appears in Admin Priority Inbox
  β†’ Admin assigns officer
  β†’ Officer fixes issue & uploads proof image
  β†’ AI verifies repair (before/after comparison)
  β†’ Citizen gives feedback (1-5 rating)
  β†’ Trust score auto-recalculated
  β†’ Officer performance auto-updated

πŸ“‘ API Endpoints

Public (No Auth Required)

Method Endpoint Description
POST /api/auth/signup Register new user
POST /api/auth/login Login (returns JWT)
GET /api/workflow/stats Dashboard statistics
GET /api/workflow/completed-works Verified completions
GET /api/trust/city City-wide trust score

Authenticated (JWT Required)

Method Endpoint Role Description
POST /api/complaints Any Create complaint
GET /api/complaints Any List complaints
POST /api/detect-pothole Any AI pothole detection
POST /api/analyze Any NLP text analysis
POST /api/workflow/feedback/{id} Any Submit citizen feedback

Admin Only

Method Endpoint Description
POST /api/workflow/assign Assign complaint to officer
GET /api/workflow/officers List all officers
GET /api/fraud/reports View fraud reports
GET /api/predict/complaints Complaint forecasts
GET /api/geo/heatmap Geographic heatmap data
GET /api/officer/ranking Officer performance ranking
GET /api/digital-twin/state Digital twin city state

Officer / Department

Method Endpoint Description
GET /api/workflow/my-assignments View assigned cases
POST /api/workflow/upload-proof/{id} Upload repair proof
POST /api/workflow/verify-repair/{id} AI verification

πŸ—ƒοΈ Datasets Used

Dataset Size Purpose
datasets/311_small.csv ~16 MB Complaint volume prediction & digital twin
News_Dataset/Fake.csv + True.csv ~50 MB Misinformation/fraud detection
twcs/twcs.csv ~45 MB Customer service sentiment training
data/India/ images ~200 MB Road damage detection (7706 annotations)

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 19, Vite 7, Framer Motion, Lucide Icons, Chart.js
Backend FastAPI, Uvicorn, Motor (async MongoDB)
Database MongoDB
AI/ML OpenCV (pothole detection), HuggingFace Transformers (NLP), Whisper (voice)
Auth JWT + bcrypt + RBAC
Styling Tailwind CSS + custom glassmorphism theme

πŸ“„ License

This project is built for academic and civic governance research purposes.


Built with ❀️ for Smart Governance

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors