Skip to content

joeaoregan/TUS-26-ETP-AI-Traffic-Optimisation

Repository files navigation

AI-Driven Predictive Traffic Flow Optimisation System

Engineering Team Project | TUS Athlone

TUS Module Topic

Java 17 Python 3.9 Spring Boot FastAPI Docker Status

GitHub repo size GitHub last commit GitHub top language Stars

Project Goal: Target 15-20% reduction in urban traffic congestion for the Athlone "Orange Loop" using Reinforcement Learning, measured by:

  • Average Travel Time (ATT): -15%
  • Mean Queue Length (MQL): -20%
  • Data Integrity: TLS 1.3 secured telemetry pipeline

πŸ”— Quick Links

🌐 Live Services

πŸ“– API Documentation (Swagger)

🎬 Mappo Traffic Flow Simulation Demonstration

πŸ“š Documentation

πŸš€Running the System

You can start all three microservices (API Gateway, RL Inference, and LSTM Predictor) using the provided startup scripts:

Windows:

start.bat

Linux/macOS:

./start.sh
πŸ› οΈ API Setup β€” Docker, Environment Variables, Components, Examples, Monitoring
πŸ“– API Reference β€” Quick Reference & Detailed Specifications
πŸ’¬ Support β€” Contact, Contributing, Issues

πŸ—οΈ System Architecture

           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚          CLIENT LAYER           β”‚
           β”‚   Web β€’ Mobile β€’ External API   β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ HTTPS (TLS 1.3)
                            β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   JAVA API GATEWAY (Port 8080)      β”‚
         β”‚        Spring Boot 3.2.3            β”‚
         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
         β”‚  β€’ JWT Authentication (HS256)       β”‚
         β”‚  β€’ Request Validation               β”‚
         β”‚  β€’ Fallback Logic (RED signal)      β”‚
         β”‚  β€’ Circuit Breaker Pattern          β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                         β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  HEALTH CHECK      β”‚   β”‚  PREDICTION REQUESTS  β”‚
    β”‚  /health           β”‚   β”‚  /traffic/action      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚ INFERENCE SERVICE     β”‚
                  β”‚  (Port 8000)          β”‚
                  β”‚  Python/FastAPI       β”‚
                  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                  β”‚ β€’ MAPPO RL Model      β”‚
                  β”‚ β€’ 5-Junction Support  β”‚
                  β”‚ β€’ GRU State Mgmt      β”‚
                  β”‚ β€’ Action Masking      β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                         β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  LSTM PREDICTOR     β”‚   β”‚  ACTION SELECTION     β”‚
    β”‚  (Port 8001)        β”‚   β”‚  (MAPPO Output)       β”‚
    β”‚  Python/FastAPI     β”‚   β”‚                       β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”‚ Actions:              β”‚
    β”‚ β€’ Time-series LSTM  β”‚   β”‚ 0: RED                β”‚
    β”‚ β€’ 15-min Forecast   β”‚   β”‚ 1: YELLOW             β”‚
    β”‚ β€’ MAE < 10%         β”‚   β”‚ 2: GREEN              β”‚
    β”‚ β€’ Data Pipeline     β”‚   β”‚ 3: GREEN_EXTENDED     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                                          β”‚ Signal State
                                          β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚  RESPONSE TO CLIENT   β”‚
                              β”‚ {                     β”‚
                              β”‚   action: 0-3,        β”‚
                              β”‚   signalState: "RED", β”‚
                              β”‚   confidence: 0.87    β”‚
                              β”‚ }                     β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

This repository implements a Cloud-Native Microservices Pipeline designed for the Athlone "Orange Loop" case study.

  • Traffic Monitoring Gateway (Java/Spring Boot): Manages secure telemetry ingestion and orchestrates service communication.

  • RL Inference Service (Python/FastAPI): Hosts a trained MAPPO (Multi-Agent Proximal Policy Optimization) model to predict optimal signal timings based on real-time traffic observations from 5 junctions

  • LSTM Predictor Service (Python/FastAPI): Forecasts vehicle flow 15 minutes ahead using historical traffic patterns from SUMO simulations, targeting MAE < 10% accuracy

  • Simulation Layer (SUMO): Integrated high-fidelity traffic simulation environment for testing adaptive signal logic against baseline fixed-time controllers. YouTube Demo.

This system is specifically modeled to address the saturation flow rates and signal-timing patterns of the Athlone 'Orange Loop' corridor, providing a scalable template for Smart City traffic management in regional Irish hubs.

Two FastAPI microservices:

RL Inference Service (Port 8000)

  • MAPPO agent for signal prediction
  • Full docs

LSTM Predictor Service (Port 8001)

  • LSTM for traffic density forecasting
  • Full docs

πŸš€ Quick Start

Start both services in separate terminals:

cd rl-inference-service
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
cd lstm-predictor-service
python -m uvicorn app.main:app --host 0.0.0.0 --port 8001 --reload

Test integration:

python lstm-predictor-service/test_rl_integration.py

πŸ—‚οΈ Project Structure

TUS-26-ETP-AI-Traffic-Optimisation/
β”œβ”€β”€ java-api-gateway/          # Spring Boot Edge Service (JWT Auth, LSTM/RL Orchestration)
β”œβ”€β”€ rl-inference-service/      # Python FastAPI (MAPPO Multi-Agent RL Inference)
β”œβ”€β”€ lstm-predictor-service/    # Python FastAPI (Time-Series Traffic Density Forecasting)
β”œβ”€β”€ SUMO/                      # Traffic Simulation (Athlone 'Orange Loop' Network & Results)
β”œβ”€β”€ docs/                      # Central Documentation (MkDocs source & guides)
β”œβ”€β”€ docker-compose.yml         # Container orchestration for all services
β”œβ”€β”€ start.bat / start.sh       # Multi-platform quickstart scripts
└── README.md                  # This file

For a detailed breakdown of every file, please refer to our detailed Project Structure documentation.


2026 β€’ Edgars Peskaitis β€’ Joe O'Regan β€’ David Claffey β€’ Adam O Neill Mc Knight