FS
FlowSync
Reinforcement Learning · Real-time Simulation

Smart Traffic,
Learned by AI

A Deep Q-Network agent watches your intersection, learns signal timing in real time, and consistently outperforms fixed-timer systems — live in your browser.

View on GitHub
DQN AgentWebSocket StreamLive Three.js Viz

How it works

From stochastic vehicle generation to neural network optimization.

1. Simulate

Experience a high-fidelity 4-way intersection simulation. Vehicles are dynamically generated using a Poisson distribution to model real-world traffic patterns. A robust fixed-timer controller provides the baseline performance metric.

2. Train

Deploy a Deep Q-Network (DQN) agent that learns through trial and error. By observing lane queue lengths and vehicle wait times, the AI receives rewards for optimizing flow, eventually discovering complex timing strategies that traditional systems miss.

3. Compare

Evaluate the AI's performance against the baseline. Watch as average wait times decrease and throughput increases in real-time. Our dashboard provides granular metrics, showing exactly how much more efficient the AI is compared to fixed intervals.

Everything you need

Live Simulation

Top-down Three.js intersection with real vehicles, lane queues, and switching traffic lights rendered at 10fps via WebSocket.

Deep Q-Network

PyTorch DQN with replay buffer, target network, and ε-greedy exploration. State: queue lengths + phase. Action: signal phase selection.

Real-time Training

Click Train Agent and watch the reward curve climb episode by episode. Training streams live metrics to your browser.

Fixed vs AI Comparison

Run both modes and compare avg wait time, throughput, and max queue length side by side with improvement percentage.

Persistent History

Every simulation, episode, and model checkpoint is saved to Supabase. Load any past model and replay its behavior.

Configurable Traffic

Tune vehicle arrival rate (λ) with a slider. Higher λ = more congestion. Test how the AI handles pressure.

Built with

Modern stack, clean architecture

Next.js
React
TypeScript
Three.js
Tailwind CSS
Shadcn/ui
FastAPI
PyTorch
DQN
Gymnasium
WebSockets
Supabase

See the AI learn.

Open the simulation, hit Train, and watch a neural network figure out traffic — in real time.