AI-driven traffic intelligence for smarter cities.
Traffix AI transforms raw traffic data from the TomTom API into actionable intelligence — predicting congestion before it forms, optimising signal timing dynamically, and giving city operators a real-time command view of their road network.
The Story
The Problem
India loses $22 billion annually to traffic congestion — wasted fuel, lost productivity, emergency vehicles stuck in gridlock, and air pollution from idling engines. Most traffic management systems react to congestion after it forms. By the time a signal changes or a diversion is announced, the jam is already kilometres long.
Why It Matters
Moving from reactive to predictive traffic management is the difference between a city that works and one that doesn't. Every 10% reduction in average commute time in a city of 10 million people saves 200 million person-hours per year. Traffic AI is not a smart city vanity project — it is foundational urban infrastructure.
The Solution
A Java Spring Boot backend that ingests real-time traffic flow, incident, and density data from the TomTom API, runs predictive congestion analysis with Gemini AI, and exposes a REST + WebSocket API for a React dashboard that gives operators live situational awareness and AI-generated signal optimisation recommendations.
Product Features
Live road network visualisation showing traffic flow, congestion levels, and incident markers pulled from TomTom Traffic API — updated every 30 seconds.
Gemini AI analyses historical traffic patterns, current flow data, time-of-day, day-of-week, and weather to predict congestion hotspots 15–30 minutes before they form.
AI-generated signal timing recommendations for key intersections based on current and predicted traffic density — reducing average intersection wait time.
TomTom incident data is cross-referenced with traffic flow anomalies to detect likely accidents or road blocks. Alternative routes are auto-suggested for affected corridors.
Historical congestion trends, signal performance metrics, peak hour analysis, and incident frequency heatmaps — all in an operator-facing analytics dashboard.
System Architecture
Technical Deep Dive
Every 30 seconds, a Spring Boot scheduled job fetches traffic flow data for 50 key road segments from TomTom. The data (current speed, free-flow speed, travel time ratio) is structured and sent to Gemini with a prediction prompt that includes: current conditions, last 2 hours of historical data for that segment, time-of-day, and day-of-week. Gemini returns a congestion probability and predicted severity for the next 15 and 30 minutes. Predictions above 70% probability trigger an operator alert.
@Scheduled(fixedRate = 30000)
public void ingestAndPredict() {
List<Segment> segments = tomTomClient.fetchFlowData(MONITORED_SEGMENTS);
segments.parallelStream().forEach(segment -> {
List<HistoricalRecord> history = trafficRepo.getLastTwoHours(segment.id());
PredictionResult prediction = geminiService.predictCongestion(segment, history);
if (prediction.probability() > 0.70) {
alertService.dispatch(new CongestionAlert(segment, prediction));
}
trafficRepo.save(new TrafficRecord(segment, prediction));
});
}The React dashboard subscribes to a Spring Boot WebSocket endpoint. Every 30 seconds, updated traffic data and new predictions are pushed to all connected operator clients — no polling, no stale maps. STOMP over WebSocket is used for structured message routing, with separate channels for traffic updates, incident alerts, and signal recommendations.
Engineering Decisions
Performance & Scale
Deployment & Infrastructure
Deployment
Java Spring Boot on Render with an always-on dyno. PostgreSQL on Render. React frontend on Vercel. TomTom and Gemini API keys in Render environment.
CI/CD
GitHub Actions — Maven build + JUnit tests on PR. Auto-deploy Spring Boot to Render and frontend to Vercel on merge.
Monitoring
Render metrics for Spring Boot CPU/memory. Custom alert logging for TomTom API failures. Gemini API latency tracked per prediction cycle.
Challenges & Failures
What I Learned
Java Spring Boot's parallel stream handling is genuinely superior to Node.js for sustained high-throughput API fan-out.
Predictive models degrade gracefully when you have fallback rules — never let an AI failure break the core feature.
WebSocket is the right architecture for real-time dashboards — polling is technically simpler but operationally expensive at scale.
Future Roadmap
v2.0 — 2026
Screenshots
Real-time traffic map with congestion prediction overlay
AI signal timing recommendations dashboard
Technology Stack
Backend
Frontend
Data
AI
Database
Real-Time
Deployment
Ready to dive in?