An AI-powered mobility enforcement platform with computer vision, automated evidence processing, e-challan management, analytics, and role-based administration.
See all features
|
|
|
|
git clone https://github.com/yuvanvishnupandi/margarakshak.git
cd margarakshakCreate 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.
|
React |
Vite |
Node.js |
Express |
|
FastAPI |
MySQL |
JavaScript |
Gemini |
|
Mistral AI |
Tailwind CSS |
JWT |
Vercel |
|
Render |
Git |
GitHub |
Postman |
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]
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
- Citizen uploads traffic violation evidence through the portal.
- The backend stores the uploaded media and forwards it to the AI service.
- The Vision Agent extracts the vehicle registration number and identifies the violation.
- The Rule Validation Agent determines the applicable traffic rule and fine.
- The processed report is stored in the database with a Pending Review status.
- A police officer verifies the report through the dashboard.
- Once approved, the system generates the challan and updates the violation history.
- The citizen receives the report status and reward points for verified submissions.
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.
- Node.js 18 or later
- Python 3.9 or later
- MySQL 8.0
git clone https://github.com/yuvanvishnupandi/margarakshak.git
cd margarakshakCreate 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 startAI service setup
cd ai_service
pip install -r requirements.txt
uvicorn main:app --reload --port 8000Frontend setup
cd frontend
npm install
npm run devstart.batFull reference
Template based on the services in use โ confirm exact variable names against your
.env.examplefiles 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 |
- 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
Marga Rakshak is MIT licensed.







