Skip to content
zhe-jacPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

flowTO logo

flowTO

See what road closures, construction, events and weather do to Toronto traffic, before they happen.

Place a disruption on a map of Toronto, and flowTO simulates how traffic diverts, where queues form and how long the city takes to recover, compared with a normal day.

Built for Hack the Valley 2026 (Hack the Valley x School of Cities track). It tests plans and policies, not candidates: there are no election predictions or voting recommendations.

What it does

  • Citywide traffic map: about 43,000 Toronto road segments, coloured by estimated congestion, in 2D or 3D, with day/night lighting.
  • Disruption toolbox: drag a road closure, lane reduction, accident, construction zone or event onto the map, with optional times.
  • Traffic simulation: a local network solver reroutes trips, builds queues, spills back onto nearby streets and recovers after a disruption ends.
  • Before/After: compare the scenario with a normal day at any time.
  • Time controls: pick a date, play at different speeds, or follow the current Toronto time.
  • Weather: live Toronto conditions or manual rain and snow, which slow traffic.
  • Assistant (Gemini): describe a disruption in plain English ("Close Queen St W from Spadina to University, 5–7 PM") and get explanations grounded in the simulated results.
  • Street info: click any road for its volume, speed, queue and the City count behind it.

How it works

  • Traffic volumes come from City of Toronto counts (midblock and intersection), merged across years and adjusted to recent levels. Uncounted roads borrow nearby counts on the same street or use typical values for their road type.
  • Demand context includes employment hubs and published Blue Jays home games.
  • The simulation runs on the server in a Node worker. It keeps track of every vehicle (on the road, queued or still waiting to leave), respects finite lane storage, and updates routing costs every 30 simulated seconds. The map plays back its results.
  • Gemini is optional. It turns text into proposed disruptions and explains results, but it doesn't produce the traffic numbers.

Placement and editing pause playback. Pressing Play before processing finishes shows a message. Expired disruptions leave the map while traffic queues continue clearing. Completed simulation windows remain cached for the current scenario, so revisiting calculated times reuses their results until disruptions or weather change.

See simulation implementation notes and the solver comparison for calculation details and limitations.

Results and saved runs (Tiger Data)

The Results button on the left rail compares the scenario with a normal day: extra vehicle-hours of delay, peak extra vehicles, unfinished trips, the worst street, a chart over time and the most affected streets.

With TIGER_DATABASE_URL set, Save run stores the run in Tiger Data (Timescale Postgres):

  • scenario_runs holds each run's inputs and headline results.
  • run_metrics is a hypertable of minute-by-minute baseline vs. scenario metrics.
  • run_metrics_hourly is a continuous aggregate that compares saved runs by hour of day.

Without the variable, the dashboard still works; only saving is off.

Getting started

Requirements: Node.js 22+ and pnpm 9 (or corepack pnpm).

corepack pnpm install
cp .env.example .env.local
corepack pnpm dev
Variable Needed for
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN Mapbox map with 3D buildings (without it, a free MapLibre map is used)
GEMINI_API_KEY, GEMINI_MODEL The assistant (server-only; the simulation works without it)
TIGER_DATABASE_URL Saving and comparing runs in Tiger Data (server-only, optional)

Add your keys to .env.local, then open http://localhost:3000.

The simulation needs a long-running Node server (pnpm dev or pnpm start), not serverless functions.

For Render, use the included render.yaml Blueprint. See the deployment guide for environment variables, compute settings and verification.

Script What it does
pnpm dev / build / start Develop, build and serve
pnpm test / check Run tests and the TypeScript check
pnpm data:traffic Rebuild traffic volumes from City data (cached in data/raw/)
pnpm data:traffic-topology Rebuild road junction links for the simulation
pnpm data:events Refresh the Blue Jays home-game schedule
pnpm data:boundary Rebuild the Toronto boundary and edge fade

Data

City of Toronto Open Data (Centreline, traffic counts, boundary) under the Open Government Licence – Toronto; MLB schedule; Open-Meteo weather; © Mapbox and © OpenStreetMap contributors.

Limitations

Results are illustrative estimates, not forecasts:

  • Trips are inferred from road counts, not measured origins and destinations.
  • Lanes and capacities are assumed by road type.
  • Turn restrictions and signal timing aren't modelled.
  • Some counts are old.

Use the Before/After comparison to judge relative effects rather than exact minutes.

See ROADMAP.md for what's planned next.

Team

A team of three at Hack the Valley 2026. Code licence: MIT (a LICENSE file is still to be added). Data and map assets keep their own licences.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages