Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

106 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Marga Rakshak

An AI-powered mobility enforcement platform with computer vision, automated evidence processing, e-challan management, analytics, and role-based administration.


React Vite Node.js Express MySQL Gemini AI OpenAI Mistral AI JWT Tailwind CSS Vercel Render Stars Forks MIT License Last Commit



Key Functionalities

Marga Rakshak โ€” overview
See all features

๐Ÿ“ธ Citizen reporting

  • One-tap evidence upload โ€” capture and submit violation photos/videos from the citizen portal
  • Automatic plate recognition โ€” OCR-based number plate extraction, no manual entry
  • Violation detection โ€” Vision Agent classifies the offense straight from the image
  • Challan payment โ€” pay issued challans directly through the portal
  • Appeals โ€” contest a challan and track resolution status
  • Reward points โ€” citizens earn points for verified, accurate submissions

๐Ÿ‘ฎ Police dashboard

  • Review queue โ€” every AI-processed report lands here before any challan is issued
  • One-click approve/reject โ€” human-in-the-loop verification, no automated punishment
  • Vehicle registration lookup โ€” cross-check vehicle details on demand
  • Violation history โ€” per-vehicle record across all past reports
  • Hotspot map โ€” high-risk locations surfaced from historical report density
  • Role-based access โ€” JWT-secured, officer-only actions

๐Ÿง  Multi-agent AI engine

  • Vision Agent โ€” OCR plate extraction + violation identification
  • Rule Validation Agent โ€” maps detected violations to Motor Vehicles Act provisions and calculates fines
  • Vehicle Verification Agent โ€” cross-checks extracted vehicle data before report generation
  • Hotspot Prediction Agent โ€” analyses historical reports to flag high-risk zones
  • AskRakshak Assistant โ€” chatbot for traffic-rule and challan queries

โš™๏ธ Platform

  • REST API backend โ€” Express.js, modular route structure
  • JWT authentication โ€” secure sessions for citizens and officers
  • MySQL 8.0 โ€” relational schema for reports, vehicles, users, challans
  • Independent AI service โ€” FastAPI microservice, decoupled from the main API
  • Cloud-native deploy โ€” Vercel (frontend) + Render (backend)

Get started

git clone https://github.com/yuvanvishnupandi/margarakshak.git
cd margarakshak

Create a MySQL database named traffic_violation_db, import the schema from backend/database_schema.sql, then start the backend, AI service, and frontend (see Local Setup below) โ€” or run start.bat on Windows to launch all three at once.


๐Ÿ› ๏ธ Tech Stack



React


Vite


Node.js


Express


FastAPI


MySQL


JavaScript


Gemini


Mistral AI


Tailwind CSS


JWT


Vercel


Render


Git


GitHub


Postman

๐Ÿ›๏ธ Overall system architecture

The application follows a modular three-tier architecture consisting of the presentation layer, backend API, AI service, and database. Each component operates independently and communicates through REST APIs.

graph TD

subgraph Client["Client Layer"]
Citizen[Citizen Portal]
Police[Police Dashboard]
end

subgraph Server["Application Layer"]
API[Express API Server]
AUTH[JWT Authentication]
end

subgraph AI["AI Service"]
ORCH[AI Orchestrator]
VISION[Vision Agent]
RULE[Rule Validation]
CHATBOT[AskRakshak Assistant]
HOTSPOT[Hotspot Prediction]
end

subgraph Database["Database Layer"]
MYSQL[(MySQL Database)]
end

Citizen --> API
Police --> API

API --> AUTH
API --> MYSQL
API --> ORCH

ORCH --> VISION
ORCH --> RULE
ORCH --> CHATBOT
ORCH --> HOTSPOT

VISION --> GeminiAPI[Gemini API]
CHATBOT --> OpenAIAPI[OpenAI API]
Loading

Traffic violation processing workflow

The following sequence diagram illustrates how a citizen report is processed from submission to challan generation.

sequenceDiagram

actor Citizen
participant Frontend
participant Backend
participant AI
participant Database
actor Police

Citizen->>Frontend: Submit violation evidence
Frontend->>Backend: Upload image/video
Backend->>AI: Request AI analysis
AI->>AI: Detect number plate
AI->>AI: Identify violation
AI->>AI: Validate traffic rules
AI-->>Backend: Return analysis result
Backend->>Database: Save pending report
Police->>Backend: Review report
Backend->>Database: Update report status
Backend-->>Citizen: Notify report status
Loading

Core data flow

  1. Citizen uploads traffic violation evidence through the portal.
  2. The backend stores the uploaded media and forwards it to the AI service.
  3. The Vision Agent extracts the vehicle registration number and identifies the violation.
  4. The Rule Validation Agent determines the applicable traffic rule and fine.
  5. The processed report is stored in the database with a Pending Review status.
  6. A police officer verifies the report through the dashboard.
  7. Once approved, the system generates the challan and updates the violation history.
  8. The citizen receives the report status and reward points for verified submissions.

๐Ÿง  Multi-agent AI engine

The AI service is designed as a collection of specialized agents. Each agent performs a dedicated task, allowing the system to process reports in a structured manner.

See all agents
  • Vision Agent

    • Extracts vehicle registration numbers using OCR.
    • Identifies traffic violations from uploaded images.
  • Rule Validation Agent

    • Maps detected violations to applicable Motor Vehicles Act provisions.
    • Calculates the corresponding fine.
  • Vehicle Verification Agent

    • Validates extracted vehicle information before report generation.
  • Hotspot Prediction Agent

    • Analyses historical reports to identify high-risk traffic locations.
  • AskRakshak Assistant

    • Answers user queries related to traffic rules, challans, and reporting procedures.

๐Ÿš€ Local setup

Prerequisites

  • Node.js 18 or later
  • Python 3.9 or later
  • MySQL 8.0

Clone repository

git clone https://github.com/yuvanvishnupandi/margarakshak.git
cd margarakshak

Database

Create a MySQL database named traffic_violation_db and import the provided SQL schema from backend/database_schema.sql.

Backend setup
cd backend
npm install
npm start
AI service setup
cd ai_service
pip install -r requirements.txt
uvicorn main:app --reload --port 8000
Frontend setup
cd frontend
npm install
npm run dev

Quick start (Windows)

start.bat

Environment variables

Full reference

Template based on the services in use โ€” confirm exact variable names against your .env.example files before deploying.

Variable Description Where
PORT Backend API port backend/.env
DB_HOST / DB_USER / DB_PASSWORD / DB_NAME MySQL connection details for traffic_violation_db backend/.env
JWT_SECRET Signing secret for citizen/officer session tokens backend/.env
GEMINI_API_KEY Google Gemini key for the Vision Agent and violation detection ai_service/.env
MISTRAL_API_KEY Mistral AI key, used alongside Gemini in the AI pipeline ai_service/.env
OPENAI_API_KEY OpenAI API key powering the AskRakshak chat assistant ai_service/.env
AI_SERVICE_URL URL the backend uses to reach the AI microservice (e.g. http://localhost:8000) backend/.env
VITE_API_URL Base URL the frontend uses to call the backend API frontend/.env

Data & storage

  • Database โ€” MySQL 8.0, schema in backend/database_schema.sql
  • Uploads โ€” violation evidence (photos/videos) handled by the backend at upload time
  • AI service โ€” stateless FastAPI microservice; no persistent storage of its own
  • Hosting โ€” frontend on Vercel, backend on Render

License

Marga Rakshak is MIT licensed.


About

An intelligent transit enforcement platform powered by a multi-agent AI architecture. Margarakshak utilizes specialized distributed agents for computer vision, OCR telemetry, and spatial hotspot prediction to autonomously process crowdsourced incident reports, validate regulatory infractions, and streamline authoritative adjudication.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages