AI-powered Smart City Traffic Platform for Solapur Municipal Corporation
SMC-Niyantran (Smart Traffic) is a decentralized, AI-driven traffic intelligence platform designed for the Solapur Municipal Corporation (SMC). The system utilizes existing CCTV infrastructure and edge computing (Raspberry Pi 4) to eliminate the inefficiencies of fixed 60-second traffic signals, saving commute time, fuel, and reducing carbon emissions. It features automatic encroachment detection, dynamic RL-based signal optimization, auto E-Challan generation, and a specialized one-click "Yatra Mode" for managing massive pilgrim crowds during the Siddheshwar Yatra.
- Dynamic RL Optimizer: Replaces fixed timers with adaptive signal control based on real-time vehicle density (reducing wait times by ~68.7%).
- Virtual Geofencing & Encroachment Detection: Automatically detects vehicles parked in unauthorized zones using YOLOv8 bounding boxes.
- Auto E-Challan Generation: Generates real-time infraction logs with unique challan IDs in under 40ms with zero manual enforcement.
- Yatra Mode (Emergency Override): One-click fail-safe to prioritize pilgrim and emergency vehicle flow during major festivals.
- Eco-Niyantran (Carbon Calculator): Tracks cumulative CO2 emissions saved by reducing vehicle idle times (up to 4.2 tonnes CO2/day citywide).
- AI Live Assistant: Integrated Gemini 1.5 Flash for context-grounded queries and parking/vehicle analysis.
- AI / Computer Vision: YOLOv8n, OpenCV 4.9, NumPy, PyTorch 2.0 (CPU only)
- Backend: Python, FastAPI, Uvicorn
- Frontend: React 18, Vite, TypeScript, Tailwind CSS, shadcn/ui, Recharts
- LLM / Generative AI: Google Gemini 1.5 Flash (Context-grounded)
- Hardware Profile: Raspberry Pi 4 (Edge device), existing RTSP/CCTV IP cameras
- Python 3.9+
- Node.js 18+ & npm
- Basic C/C++ build tools (for OpenCV dependencies)
# 1. Navigate to the backend directory
cd backend
# 2. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Provide a video feed
# Place your CCTV feed as 'traffic_feed.mp4' in the backend/ directory
# (If missing, the system will automatically run a synthetic demo feed)# 1. Navigate to the frontend directory
cd frontend2
# 2. Install dependencies
npm installcd backend
source venv/bin/activate
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadThe API will be live at http://localhost:8000. Auto-generated Swagger docs available at http://localhost:8000/docs.
cd frontend2
npm run devThe React Dashboard will be accessible at http://localhost:8080 (or the port specified by Vite, typically 5173).
Smart Traffic/
βββ backend/ # FastAPI Backend & AI Engine
β βββ main.py # Core application and video processing threads
β βββ requirements.txt # Python dependencies
β βββ traffic_feed.mp4 # Live CCTV or demo footage
β βββ yolov8n.pt # Pre-trained YOLOv8 Nano weights
β
βββ frontend2/ # React Vite Application
β βββ src/ # React components, pages, and hooks
β βββ public/ # Static assets
β βββ package.json # Node dependencies
β βββ tailwind.config.ts # Tailwind UI configurations
β βββ components.json # shadcn/ui component definitions
β
βββ README.md # Project Documentation
The FastAPI backend serves several key endpoints for the React dashboard:
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/video-feed |
Streams live processed MJPEG video frames with YOLO bounding boxes. |
GET |
/api/traffic-data |
Polled for real-time metrics (vehicle counts, active alerts, green times). |
GET |
/api/alert-log |
Retrieves history of encroachment violations and auto-generated E-Challans. |
GET |
/api/carbon-log |
Fetches a 30-day rolling array of CO2 metrics and RL learning efficiency. |
GET |
/api/system-stats |
Provides system FPS, frame counts, and hardware uptime metrics. |
POST |
/api/settings |
Hot-reloads configuration (e.g., Yatra Mode, zone coordinates, confidence). |
Sample response for /api/traffic-data:
{
"vehicle_count": 12,
"encroachment_alert": true,
"dynamic_green_time": 36,
"carbon_saved_kg": 4.2,
"yatra_mode": false,
"fps": 24.5,
"backend_status": "live"
}
Figure 1: Main React Dashboard showing live CCTV feed, YOLOv8 detections, and dynamic RL timers.
Figure 2: Real-time Encroachment Detection and Auto E-Challan Drafting.
Figure 3: Eco-Niyantran 30-Day Carbon Emission Reduction Analytics.
Figure 4: Hot-reloadable Settings Panel and Yatra Mode activation.
(Note: Create a screenshots folder in the repository root and place your actual screenshots using these filenames.)
- Backend Configuration: The application hot-reloads settings directly via the
/api/settingsendpoint. Initial default parameters likeBASELINE_GREEN,CARBON_PER_VEH_SEC, andZONEcoordinates are hardcoded at the top ofbackend/main.pybut can be dynamically overridden by the frontend. - Frontend Configuration: The frontend communicates directly with
http://localhost:8000. Ensure proxy settings in Vite or.envfiles are updated if you deploy the backend on a remote server.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project is open-source and distributed under the MIT License.
Team Name: VYOMAN