# tonao1/vtpaths architecture

> Architecture diagram of the GitHub repository tonao1/vtpaths, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tonao1/vtpaths
- Repository: https://github.com/tonao1/vtpaths

## Overview

VTPaths is a campus accessibility web app: students choose endpoints and accessibility preferences, receive a step-free route, and can report barriers that trigger rerouting on open clients. The laptop workflow loads campus geometry, snaps locations to the route network, computes and displays directions, while a separate phone form submits reports without the map. Reports are shared through Supabase realtime. The map and place search use Mapbox. Sampled source confirms the routing and map responsibilities; the report persistence and phone form internals were not sampled, so their detailed wiring is limited to the README and visible imports.

Main entry points: [`src/App.tsx`](https://github.com/tonao1/vtpaths/blob/main/src/App.tsx) (Route orchestrator), [`src/lib/reports.ts`](https://github.com/tonao1/vtpaths/blob/main/src/lib/reports.ts) (Report service), [`src/components/Map.tsx`](https://github.com/tonao1/vtpaths/blob/main/src/components/Map.tsx) (Campus map), [`src/lib/graph.ts`](https://github.com/tonao1/vtpaths/blob/main/src/lib/graph.ts) (Network builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["Route selection<br/>[main.tsx]"]
  node_appflow["Route orchestrator<br/>[App.tsx]"]
  node_controls["Endpoint controls<br/>[Controls.tsx]"]
  node_map["Campus map<br/>[Map.tsx]"]
  node_directions_ui["Route directions<br/>[Directions.tsx]"]
  node_alerts_ui["Live alerts<br/>[AlertPanel.tsx]"]
end

subgraph group_routing["Accessible routing"]
  node_campus_data["Campus path data<br/>[campus.geojson]"]
  node_graph["Network builder<br/>[graph.ts]"]
  node_nearest["Network snapping<br/>[nearest.ts]"]
  node_route["Route solver<br/>[route.ts]"]
  node_directions["Distance and steps<br/>[directions.ts]"]
end

subgraph group_reports["Barrier reports"]
  node_report_ui["Phone report form<br/>[ReportForm.tsx]"]
  node_popover["Map report form<br/>[ReportPopover.tsx]"]
  node_expiry["Report expiry<br/>[expiry.ts]"]
  node_reports["Report service<br/>[reports.ts]"]
end

subgraph group_integrations["External services"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_report_store[("Reports database<br/>[schema.sql]")]
  node_geocode["Place search<br/>[geocode.ts]"]
end

node_student(("Student"))
node_mapbox["Mapbox"]

node_student -->|"opens app"| node_entry
node_entry -->|"renders route view"| node_appflow
node_entry -->|"renders report view"| node_report_ui
node_appflow -->|"fetches geometry"| node_campus_data
node_appflow -->|"builds network"| node_graph
node_campus_data -->|"provides geometry"| node_graph
node_appflow -->|"renders controls"| node_controls
node_controls -->|"searches places"| node_geocode
node_geocode -.->|"queries geocoder"| node_mapbox
node_controls -->|"snaps place"| node_nearest
node_appflow -->|"snaps location"| node_nearest
node_appflow -->|"solves route"| node_route
node_appflow -->|"formats route"| node_directions
node_appflow -->|"supplies network and route"| node_map
node_map -.->|"renders map"| node_mapbox
node_appflow -->|"renders directions"| node_directions_ui
node_appflow -->|"renders active reports"| node_alerts_ui
node_map -->|"finds clicked edge"| node_nearest
node_map -->|"selects edge"| node_popover
node_popover -->|"submits report"| node_reports
node_report_ui -->|"submits report"| node_reports
node_appflow -->|"subscribes and resets"| node_reports
node_reports -->|"uses client"| node_supabase_client
node_supabase_client -->|"reads and writes"| node_report_store
node_reports -->|"expires reports"| node_expiry
node_reports -->|"delivers updates"| node_appflow
node_appflow -->|"applies active reports"| node_graph
node_graph -->|"provides weighted network"| node_route

click node_entry "https://github.com/tonao1/vtpaths/blob/main/src/main.tsx"
click node_appflow "https://github.com/tonao1/vtpaths/blob/main/src/App.tsx"
click node_controls "https://github.com/tonao1/vtpaths/blob/main/src/components/Controls.tsx"
click node_map "https://github.com/tonao1/vtpaths/blob/main/src/components/Map.tsx"
click node_directions_ui "https://github.com/tonao1/vtpaths/blob/main/src/components/Directions.tsx"
click node_alerts_ui "https://github.com/tonao1/vtpaths/blob/main/src/components/AlertPanel.tsx"
click node_report_ui "https://github.com/tonao1/vtpaths/blob/main/src/components/ReportForm.tsx"
click node_popover "https://github.com/tonao1/vtpaths/blob/main/src/components/ReportPopover.tsx"
click node_campus_data "https://github.com/tonao1/vtpaths/blob/main/src/data/campus.geojson"
click node_graph "https://github.com/tonao1/vtpaths/blob/main/src/lib/graph.ts"
click node_nearest "https://github.com/tonao1/vtpaths/blob/main/src/lib/nearest.ts"
click node_route "https://github.com/tonao1/vtpaths/blob/main/src/lib/route.ts"
click node_directions "https://github.com/tonao1/vtpaths/blob/main/src/lib/directions.ts"
click node_expiry "https://github.com/tonao1/vtpaths/blob/main/src/lib/expiry.ts"
click node_reports "https://github.com/tonao1/vtpaths/blob/main/src/lib/reports.ts"
click node_supabase_client "https://github.com/tonao1/vtpaths/blob/main/src/lib/supabase.ts"
click node_report_store "https://github.com/tonao1/vtpaths/blob/main/supabase/schema.sql"
click node_geocode "https://github.com/tonao1/vtpaths/blob/main/src/lib/geocode.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_appflow,node_controls,node_map,node_directions_ui,node_alerts_ui toneBlue
class node_campus_data,node_graph,node_nearest,node_route,node_directions toneAmber
class node_report_ui,node_popover,node_expiry,node_reports toneMint
class node_supabase_client,node_report_store,node_geocode toneRose
class node_student,node_mapbox toneIndigo
```

## Components

### Application

- [Route selection](https://github.com/tonao1/vtpaths/blob/main/src/main.tsx): `src/main.tsx`
- [Route orchestrator](https://github.com/tonao1/vtpaths/blob/main/src/App.tsx): `src/App.tsx`
- [Endpoint controls](https://github.com/tonao1/vtpaths/blob/main/src/components/Controls.tsx): `src/components/Controls.tsx`
- [Campus map](https://github.com/tonao1/vtpaths/blob/main/src/components/Map.tsx): `src/components/Map.tsx`
- [Route directions](https://github.com/tonao1/vtpaths/blob/main/src/components/Directions.tsx): `src/components/Directions.tsx`
- [Live alerts](https://github.com/tonao1/vtpaths/blob/main/src/components/AlertPanel.tsx): `src/components/AlertPanel.tsx`

### Accessible routing

- [Campus path data](https://github.com/tonao1/vtpaths/blob/main/src/data/campus.geojson): `src/data/campus.geojson`
- [Network builder](https://github.com/tonao1/vtpaths/blob/main/src/lib/graph.ts): `src/lib/graph.ts`
- [Network snapping](https://github.com/tonao1/vtpaths/blob/main/src/lib/nearest.ts): `src/lib/nearest.ts`
- [Route solver](https://github.com/tonao1/vtpaths/blob/main/src/lib/route.ts): `src/lib/route.ts`
- [Distance and steps](https://github.com/tonao1/vtpaths/blob/main/src/lib/directions.ts): `src/lib/directions.ts`

### Barrier reports

- [Phone report form](https://github.com/tonao1/vtpaths/blob/main/src/components/ReportForm.tsx): `src/components/ReportForm.tsx`
- [Map report form](https://github.com/tonao1/vtpaths/blob/main/src/components/ReportPopover.tsx): `src/components/ReportPopover.tsx`
- [Report expiry](https://github.com/tonao1/vtpaths/blob/main/src/lib/expiry.ts): `src/lib/expiry.ts`
- [Report service](https://github.com/tonao1/vtpaths/blob/main/src/lib/reports.ts): `src/lib/reports.ts`

### External services

- [Supabase client](https://github.com/tonao1/vtpaths/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Reports database](https://github.com/tonao1/vtpaths/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Place search](https://github.com/tonao1/vtpaths/blob/main/src/lib/geocode.ts): `src/lib/geocode.ts`

### Other components

- **Student**
- **Mapbox**

## Connections

- Student → Route selection: opens app
- Route selection → Route orchestrator: renders route view
- Route selection → Phone report form: renders report view
- Route orchestrator → Campus path data: fetches geometry
- Route orchestrator → Network builder: builds network
- Campus path data → Network builder: provides geometry
- Route orchestrator → Endpoint controls: renders controls
- Endpoint controls → Place search: searches places
- Place search → Mapbox: queries geocoder
- Endpoint controls → Network snapping: snaps place
- Route orchestrator → Network snapping: snaps location
- Route orchestrator → Route solver: solves route
- Route orchestrator → Distance and steps: formats route
- Route orchestrator → Campus map: supplies network and route
- Campus map → Mapbox: renders map
- Route orchestrator → Route directions: renders directions
- Route orchestrator → Live alerts: renders active reports
- Campus map → Network snapping: finds clicked edge
- Campus map → Map report form: selects edge
- Map report form → Report service: submits report
- Phone report form → Report service: submits report
- Route orchestrator → Report service: subscribes and resets
- Report service → Supabase client: uses client
- Supabase client → Reports database: reads and writes
- Report service → Report expiry: expires reports
- Report service → Route orchestrator: delivers updates
- Route orchestrator → Network builder: applies active reports
- Network builder → Route solver: provides weighted network
