A next-gen smart traffic control dashboard. Optimizes complex 4-lane intersections in real-time with AI and computer vision.
- React
- Express
- Vite
- YOLO
- OpenCV
- PostgreSQL
- WebSockets
Problem
Modern cities are choking on static traffic lights. Urban planners need dynamic systems that can "see" congestion and adapt on the fly, but combining live simulation with raw computer vision is notoriously difficult to scale.
Approach
I engineered a high-performance Express & React platform capable of digesting live WebSocket feeds. It intelligently swaps between a synthetic traffic engine and a Python-based YOLO/OpenCV microservice that tracks vehicles frame-by-frame.
Architecture
- Vite/React dashboard with 2s WebSocket pulse
- Python CV microservice running YOLO & OpenCV for raw video analysis
- DataSourceManager pattern for seamless simulation vs. live-video toggling
Results
- Achieved sub-2s latency for live intersection rendering
- Integrated an AI Copilot for natural-language traffic querying
Latency
<2s
AI
Copilot
// code
nexus.ts
// Hot-swapping data sources on the fly
const trafficEngine = new DataSourceManager(mode);
// Toggles seamlessly without dropping WebSocket connections
trafficEngine.on('switch', (newMode) => {
logger.info(`Traffic source switched to ${newMode}`);
broadcastToAll({ event: 'SOURCE_CHANGED', payload: newMode });
});lessons learned
- Decoupling the data source (Video vs Simulation) from the WebSocket broadcaster is critical for zero-downtime swaps.
- CV models (YOLO) can spike CPU; background worker queues are essential for stable performance.