A full-stack Traffic Management System built with Flask, React, MySQL, Web3, and AI. The system manages vehicles, violations, and payments while incorporating an AI-powered helmet violation detector, interactive 3D IoT simulations, and an immutable blockchain audit trail to ensure data integrity.
- Login & registration
- Password hashing (bcrypt)
- JWT-based authorization
- Admin/user role support
- Add, view, search, and delete vehicles
- Auto-registration of unknown vehicles detected through AI or IoT
- Admin-only delete access
- Add violations manually
- View violations per vehicle
- Check violation details
- Update fine status after payment
- Live Geographic Map: Real-time plotting of incidents across Rajasthan using Leaflet and OpenStreetMap.
Uses YOLOv8 + EasyOCR to automatically detect:
- Detects With Helmet / Without Helmet
- Creates bounding boxes + labels on the image
- Detects license plate
- Extracts plate number using OCR
- Auto-registers vehicle if not found
- Auto-inserts violation into MySQL
- Saves annotated evidence image
API: POST /autodetect
Ensures database integrity by running alongside the traditional MySQL database:
- Generates a unique SHA-256 cryptographic hash of every violation payload.
- Automatically anchors the hash to a local Ethereum network via a Solidity smart contract (
ViolationAuditV2). - Verification Engine: Allows admins to cross-reference MySQL records against the immutable blockchain ledger to instantly detect database tampering.
An interactive WebGL digital twin for testing IoT ingestion:
- 3D Environment: Built with React Three Fiber, featuring a controllable vehicle and dynamic lighting.
- Automated Triggers: Automatically fires secure API requests when the simulated vehicle exceeds 90 km/h.
- Validates API key, auto-registers unknown vehicles, and logs the "Speeding" violation.
API: POST /iot/report-speeding
Provides summary stats:
- Total vehicles
- Total violations
- Total fines paid/unpaid
- Most common violation
- Username
- Role
- Violations reported
- Vehicles registered
- YOLOv8 helmet detection β
Weights/best.pt - YOLO license plate detection β
license_plate_detector.pt - OCR β EasyOCR
- OpenCV for image processing
MySQL Tables:
loginuserVehicleViolationsFines
Ethereum Smart Contracts:
ViolationAuditV2.sol(Maintains state lifecycle and evidence hashes on the blockchain)
- Backend: Python, Flask, MySQL, JWT, bcrypt
- AI & Computer Vision: PyTorch, YOLOv8, EasyOCR, OpenCV, NumPy
- Blockchain: Solidity, Ganache, Web3.py
- Frontend: React.js, Axios, React Router, React Three Fiber (3D WebGL), React-Leaflet (Maps)
- Install Python dependencies:
pip install -r requirements.txt
- Create MySQL database
TrafficDBand importTrafficDB.sql. - Start your local Ganache Ethereum workspace on port 8545.
- Run backend:
python app.py
- Run frontend:
cd traffic-violation-frontend
npm install
npm start
Traffic-Management-System-With-Ai/
βββ app.py
βββ iot_radar_gun.py
βββ TrafficDB.sql
βββ Weights/
βββ evidence_uploads/
βββ blockchain/
βββ audit/
βββ traffic-violation-frontend/
βββ screenshots/
Academic & educational use.
YOLOv8, EasyOCR, OpenCV, Flask, React, and Web3 communities.





