Real-Time Traffic Analytics & Intelligent Route Optimization Platform
A production-grade full-stack platform for live congestion monitoring, incident intelligence, AI-powered route planning, and per-user session management. Built to demonstrate engineering depth across the full stack — from real-time data pipelines and WebSocket broadcast to secure multi-user auth and persistent cloud storage.
- Real-time traffic dashboard — live charts, congestion zones, peak hour analysis, priority alerts
- AI-powered route analysis with delay estimates and Gemini AI synopsis
- TomTom incident feed with severity classification and live map overlay
- Google Sign-In with per-user data isolation in MongoDB
- Default city preference saved per account, loaded on every session
- Recent city search history per user, surfaced as autocomplete suggestions
- AOP-based per-IP rate limiting — 60 req/min global, 20 req/min on auth
- MongoDB TTL index — traffic data auto-expires after 24 hours
- WebSocket real-time push via STOMP over SockJS
- Skeleton loading screens for every page
- Fully responsive UI — mobile, tablet, and desktop
TraffixAI/
|
|- frontend/
| |- public/
| | |- logo1.png
| | `- favicon.svg
| |- src/
| | |- App.jsx
| | |- main.jsx
| | |- index.css
| | |- api.js
| | |
| | |- components/
| | | |- common/
| | | | |- Loader.jsx
| | | | `- Skeleton.jsx
| | | |- layout/
| | | | |- Header.jsx
| | | | |- Sidebar.jsx
| | | | `- UserMenu.jsx
| | | |- map/
| | | | |- TomTomMap.jsx
| | | | `- RouteMap.jsx
| | | |- modals/
| | | | |- LoginModal.jsx
| | | | `- DefaultLocationModal.jsx
| | | `- route/
| | | |- RouteSearch.jsx
| | | `- RouteDetails.jsx
| | |
| | |- context/
| | | |- AuthContext.jsx
| | | `- CityContext.jsx
| | |
| | `- pages/
| | |- Dashboard/
| | | |- index.jsx
| | | `- DashboardSkeleton.jsx
| | |- IncidentCenter/
| | | |- index.jsx
| | | `- IncidentCenterSkeleton.jsx
| | |- RouteAnalyzer/
| | | |- index.jsx
| | | `- RouteAnalyzerSkeleton.jsx
| | |- Settings/
| | | |- index.jsx
| | | `- SettingsSkeleton.jsx
| | `- Help/
| | `- index.jsx
| |
| |- index.html
| |- package.json
| |- vite.config.js
| `- .env (git-ignored, see .env.example)
|
|- src/
| `- main/
| |- java/com/traffic/analytics/
| | |- TrafficAnalyticsApplication.java
| | |
| | |- config/
| | | |- CorsConfig.java
| | | |- RestTemplateConfig.java
| | | |- SecurityConfig.java
| | | `- WebSocketConfig.java
| | |
| | |- controller/
| | | |- AuthController.java
| | | |- LiveTrafficController.java
| | | |- RouteController.java
| | | |- TrafficDataController.java
| | | `- UserController.java
| | |
| | |- dto/
| | | |- RoadTrafficSummaryDto.java
| | | |- RouteAnalysisDto.java
| | | |- RouteRequestDto.java
| | | |- RouteResponseDto.java
| | | |- TrafficAlertDto.java
| | | `- TrafficDataDto.java
| | |
| | |- mapper/
| | | `- TrafficMapper.java
| | |
| | |- model/
| | | |- TrafficData.java
| | | `- User.java
| | |
| | |- ratelimit/
| | | |- RateLimit.java
| | | `- RateLimitAspect.java
| | |
| | |- repository/
| | | |- TrafficDataRepository.java
| | | `- UserRepository.java
| | |
| | |- security/
| | | |- GoogleTokenVerifier.java
| | | |- JwtAuthFilter.java
| | | `- JwtUtil.java
| | |
| | `- service/
| | |- GeminiAiService.java
| | |- RealTimeTrafficMonitorService.java
| | |- RouteService.java
| | |- TrafficAlertService.java
| | |- TrafficAnalysisService.java
| | |- TrafficClassificationService.java
| | |- TrafficDataService.java
| | |- TrafficSortingService.java
| | `- UserService.java
| |
| `- resources/
| |- application.properties
| `- application-local.properties (git-ignored)
|
|- pom.xml
|- Dockerfile
|- render.yaml
|- LICENSE
`- .gitignore
Browser
|
|-- React (Netlify)
| |-- Google OAuth popup --> Google
| |-- REST calls --> Spring Boot (Render)
| `-- WebSocket (STOMP) --> Spring Boot (Render)
|
Spring Boot (Render)
|-- Spring Security + JWT filter
|-- AOP Rate Limiter (per IP, sliding window)
|-- MongoDB Atlas
| |-- users (accounts, default city, search history)
| `-- traffic_data (TTL 24h, per-user tagged)
|-- TomTom API (traffic flow + incidents)
|-- Gemini AI (route synopsis)
`-- OpenStreetMap (road discovery via Overpass API)
| Variable | Description |
|---|---|
MONGODB_URI |
MongoDB Atlas connection string |
GOOGLE_CLIENT_ID |
Google OAuth2 client ID |
JWT_SECRET |
Long random string for signing JWTs |
TOMTOM_API_KEY |
TomTom developer API key |
GEMINI_API_KEY |
Google Gemini API key |
ALLOWED_ORIGINS |
Comma-separated allowed frontend origins |
PORT |
Server port (Render injects this automatically) |
| Variable | Description |
|---|---|
VITE_TOMTOM_API_KEY |
TomTom API key |
VITE_API_BASE_URL |
Backend base URL |
VITE_WS_BASE_URL |
Backend WebSocket base URL |
Create src/main/resources/application-local.properties (git-ignored):
tomtom.api.key=YOUR_TOMTOM_KEY
spring.data.mongodb.uri=mongodb+srv://user:pass@cluster.mongodb.net/traffixai?appName=TraffixAi
spring.data.mongodb.auto-index-creation=true
google.client.id=YOUR_GOOGLE_CLIENT_ID
jwt.secret=any-local-secret-string
rate.limit.requests-per-minute=60Create frontend/.env (git-ignored):
VITE_TOMTOM_API_KEY=YOUR_TOMTOM_KEY.\apache-maven-3.9.6\bin\mvn.cmd spring-boot:runRuns at http://localhost:8080. The Vite dev proxy forwards /api and /ws-traffic automatically.
cd frontend
npm install
npm run devOpens at http://localhost:5173.
Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty OwningProcess |
ForEach-Object { Stop-Process -Id $_ -Force }Go to APIs & Services > Credentials > OAuth 2.0 Client ID and configure:
Authorized JavaScript origins
http://localhost:5173
http://localhost:5174
https://traffix-aiv1.netlify.app
Authorized redirect URIs
http://localhost:5173
http://localhost:5174
https://traffix-aiv1.netlify.app
cd frontend
npm run build.\apache-maven-3.9.6\bin\mvn.cmd clean package| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/google | Public | Verify Google token, return JWT |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/user/profile | JWT | Get user profile |
| PUT | /api/user/default-location | JWT | Save or update default city |
| GET | /api/user/searches | JWT | Get recent city searches |
| POST | /api/user/searches | JWT | Save a city search |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/traffic/all | Optional | All traffic data (user-scoped) |
| GET | /api/traffic/top-roads | Optional | Top 5 busiest roads |
| GET | /api/traffic/least-roads | Optional | Top 5 free-flow roads |
| GET | /api/traffic/peak-hours | Optional | Peak congestion hour |
| GET | /api/traffic/alerts | Optional | High-load alerts |
| POST | /api/traffic/add | Optional | Add a traffic data point |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/live/start | Optional | Start TomTom data polling |
| POST | /api/live/stop | Optional | Stop polling |
| POST | /api/live/location | Optional | Change monitored city |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/route/analyze | Optional | AI route analysis |
TraffixAI is open for contributions. Whether you want to fix a bug, improve the UI, add a feature, or improve the engineering quality — all pull requests are welcome.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Commit your changes with clear messages
- Push to your fork and open a pull request against
main - Describe what you changed and why in the PR description
- Traffic heatmap overlay using TomTom flow tiles
- Predictive congestion alerts using trend detection
- Historical traffic comparison (today vs. yesterday)
- Export traffic report as CSV or PDF
- Shareable city dashboard via URL (
/dashboard/bangalore) - Push notifications for critical alerts
- Unit and integration test coverage
- Docker Compose setup for local full-stack development
- Performance improvements (code splitting, lazy loading)
- Backend: follow standard Spring Boot layered architecture — controllers call services, services call repositories. No business logic in controllers.
- Frontend: component per file, co-locate skeleton with its page, use context only for global shared state.
- Commits: use plain English imperative style — "Add skeleton for Dashboard", not "added skeletons"
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).See LICENSE for the full text.
You are welcome to use, study, modify, and contribute to this project under the terms of the GPL-3.0 license. Any distributed modified versions must also remain licensed under GPL-3.0 and retain the original copyright notices.
Naren SJ
- Email: narensonu1520@gmail.com
- Phone: 8296833381
- LinkedIn: linkedin.com/in/narensj20
Built as a showcase of full-stack engineering across real-time systems, cloud deployment, multi-user auth, and production-quality UI patterns. Contributions and feedback are genuinely welcome.