Overview
Transit Planner is a Next.js (App Router) frontend centered around an interactive Mapbox GL editor. It includes GTFS import/export utilities and an AI council interface that can stream route proposals. Some analysis modules are not yet implemented and are called out as "in the works."
The application is structured as a single Next.js project under /web. All client-facing logic lives in src/app and src/lib. Server-side API routes live under src/app/api and should not be modified unless you are extending server functionality.
Technology Stack
Primary Modules
Map Editor
src/app/_components/TransitMap.tsxThe main Mapbox GL editor. Manages all map state: routes, stops, neighbourhoods, draw modes, overlays, undo/redo, GTFS export/import, and council preview visualization.
src/app/_components/map/RoutePanel.tsxDisplays route details, stops list, population served, and line controls. Used for both static and generated routes.
src/app/_components/map/StationPopup.tsxPositioned popup with station info, connections, AI-generated station analysis, and estimated ridership.
src/app/_components/map/NeighbourhoodPanel.tsxShows neighbourhood context: population density, traffic level, employment info, street view imagery, and transit lines in the area.
AI & Chat
src/app/_components/ChatPanel.tsxMulti-agent chat interface. Hosts five distinct planning agents, streams responses, extracts route proposals from markdown, and generates HTML reports.
GTFS Utilities
src/lib/gtfs.tsGenerates core GTFS CSVs (routes, stops, stop_times, trips, shapes) and zips them for download. Includes built-in validation before export.
src/lib/gtfs-import.tsReads a GTFS ZIP and converts it into Route objects compatible with the map editor's internal state.
Data
src/app/map/transit-data.tsBase routes and stops pre-loaded into the editor. Contains the default Toronto transit network (~745KB). Used as the starting dataset.
src/app/map/geo-utils.tsGeospatial helper functions: great-circle calculations, bounds computation, coordinate projections, and stop distance utilities.
Runtime & Deployment
Environment Variables
Set these in a .env.local file at the project root (or in your deployment platform's environment settings).
NEXT_PUBLIC_MAPBOX_TOKENRequiredPublic Mapbox access token. Used for map tile rendering, geocoding, and map interactions. Exposed to the browser.
AUTH0_SECRETOptionalAuth0 session secret for server-side session encryption. Required if authentication is enabled.
AUTH0_BASE_URLOptionalThe base URL of your deployment (e.g., http://localhost:3000). Used by the Auth0 SDK for callback URLs.
AUTH0_ISSUER_BASE_URLOptionalYour Auth0 tenant domain (e.g., https://your-tenant.auth0.com).
AUTH0_CLIENT_IDOptionalAuth0 application client ID.
AUTH0_CLIENT_SECRETOptionalAuth0 application client secret. Server-side only, never exposed to the browser.
NEXT_PUBLIC_SUPABASE_URLOptionalSupabase project URL for data persistence features.
NEXT_PUBLIC_SUPABASE_ANON_KEYOptionalSupabase anonymous public key. Used for client-side data operations.
Roadmap (In the Works)
The following modules are planned and not yet fully implemented: