All Projects
LiveSolo Engineer & ArchitectFlagship · Advanced

Traffix AI

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.

Live Demo GitHub
Traffix AI

The Story

Why this exists.

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

What it does.

Real-Time Traffic Map

Live road network visualisation showing traffic flow, congestion levels, and incident markers pulled from TomTom Traffic API — updated every 30 seconds.

Real-Time Traffic Map

AI Congestion Prediction

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.

Signal Optimisation Engine

AI-generated signal timing recommendations for key intersections based on current and predicted traffic density — reducing average intersection wait time.

Signal Optimisation Engine

Incident Detection & Routing

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.

Analytics Dashboard

Historical congestion trends, signal performance metrics, peak hour analysis, and incident frequency heatmaps — all in an operator-facing analytics dashboard.

System Architecture

How every layer connects.

FrontendReact.jsReal-time traffic map, operator dashboard, alerts feed
BackendJava Spring BootREST API, WebSocket server, TomTom data ingestion pipeline
Traffic DataTomTom Traffic APIReal-time flow, incident, and density data
AI EngineGemini AICongestion prediction, signal optimisation, incident analysis
Data StorePostgreSQLHistorical traffic data, prediction records, incidents
DeploymentRenderSpring Boot service, always-on dyno for streaming

Technical Deep Dive

Under the hood.

Congestion Prediction Pipeline

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));
    });
}

WebSocket Real-Time Feed

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

Challenge → Decision → Result.

Spring Boot vs. Node.js for the backend

Decision

Java Spring Boot

Why

The data ingestion pipeline runs parallel TomTom API calls across 50 segments every 30 seconds. Java's thread pool model handles this more predictably than Node.js's single-threaded event loop under sustained parallelism.

Result

50 parallel API calls complete in under 800ms per cycle with Spring's virtual threads.

Polling vs. WebSocket for dashboard updates

Decision

WebSocket with STOMP

Why

Traffic data changes every 30 seconds. Polling at that frequency from many operator clients would generate unnecessary load. WebSocket push is more efficient and gives lower perceived latency.

Result

Dashboard update latency under 200ms from data ingestion to UI render.

Performance & Scale

By the numbers.

30sData Ingestion Cycle50 segments per cycle
78%Prediction Accuracy15-min congestion prediction
< 200msDashboard Latencydata to UI via WebSocket
50Parallel API Callscompleted in < 800ms

Deployment & Infrastructure

Production setup.

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 broke — and how I fixed it.

Challenge

TomTom API rate limits causing gaps in data during peak ingestion.

Fix

Implemented a token bucket rate limiter and a backoff queue — segments are prioritised by incident frequency, ensuring high-priority corridors always get fresh data.

Challenge

Gemini prediction quality degrading for road segments with sparse historical data.

Fix

Added a minimum history threshold — segments with fewer than 48 data points fall back to a rule-based prediction model instead of Gemini.

What I Learned

Key takeaways.

Future Roadmap

Where this is going.

v2.0 — 2026

  • Integration with city CCTV feeds for computer vision-based congestion detection
  • Emergency vehicle routing — green corridor auto-generation for ambulances
  • Public-facing commuter app with personalised route recommendations

Screenshots

The product.

Traffix AI traffic map

Real-time traffic map with congestion prediction overlay

Signal optimisation dashboard

AI signal timing recommendations dashboard

Technology Stack

Built with.

Backend

Java Spring Boot

Frontend

React.js

Data

TomTom API

AI

Gemini AI

Database

PostgreSQL

Real-Time

WebSocket/STOMP

Deployment

Render

Ready to dive in?

This isn't just a project.
It's a system I designed,
engineered, and shipped.

Live Demo Explore the code← All Projects