# rohin19/bikesafe architecture

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

- Interactive diagram: https://gitdiagram.com/rohin19/bikesafe
- Repository: https://github.com/rohin19/bikesafe

## Overview

BikeSafe Vancouver is a cyclist-focused web app for planning safer routes and finding bike-share vehicles, with hazard reporting, community reviews, and administration. A cyclist signs in, plans a trip using map points or address search, compares safety-scored alternatives, and can save or navigate the selected route. Separate workflows support hazard reporting and discovery, bike-share lookup, and route reviews. The graph reflects documented capabilities; edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README, so some unsampled implementation links are omitted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rohin19/bikesafe/blob/main/frontend/src/App.tsx) (Session and page routing), [`backend/app.ts`](https://github.com/rohin19/bikesafe/blob/main/backend/app.ts) (Express API), [`frontend/src/services/api.ts`](https://github.com/rohin19/bikesafe/blob/main/frontend/src/services/api.ts) (REST API client), [`backend/db/index.ts`](https://github.com/rohin19/bikesafe/blob/main/backend/db/index.ts) (PostgreSQL connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Session and page routing<br/>[App.tsx]"]
  node_authui["Sign-in and registration<br/>[AuthPanel.tsx]"]
  node_routeui["Route planning and navigation<br/>[RoutesPage.tsx]"]
  node_alternatives["Alternative selection"]
  node_map["Interactive map<br/>[Map.tsx]"]
  node_hazardui["Hazard dashboard<br/>[Hazards.tsx]"]
  node_reportui["Hazard reporting<br/>[ReportHazard.tsx]"]
  node_bikeui["Bike-share map<br/>[BikeSharePage.tsx]"]
  node_reviewui["Route reviews<br/>[ReviewsPage.tsx]"]
  node_adminui["User administration<br/>[Admin.tsx]"]
  node_api_client["REST API client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_express["Express API<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_admin["Admin operations<br/>[admin.ts]"]
  node_hazards["Hazard service<br/>[hazards.ts]"]
  node_routes["Route planning and storage<br/>[routes.ts]"]
  node_geocode["Geocoding<br/>[geocode.ts]"]
  node_bikeshare["Bike-share proxy<br/>[bikeShare.ts]"]
  node_reviews["Review service<br/>[reviews.ts]"]
  node_auth_middleware["Auth and role checks<br/>[requireAuth.ts]"]
end

subgraph group_data["Persistence"]
  node_db_pool[("PostgreSQL connection<br/>[index.ts]")]
  node_postgres[("PostgreSQL")]
end

subgraph group_external["External services"]
  node_ors["OpenRouteService"]
  node_lime["Lime GBFS feed"]
end

node_cyclist(("Cyclist"))
node_browser_geo["Browser geolocation"]

node_cyclist -->|"uses"| node_app
node_app -->|"shows when signed out"| node_authui
node_app -->|"routes to"| node_routeui
node_app -->|"routes to"| node_hazardui
node_app -->|"routes to"| node_reportui
node_app -->|"routes to"| node_bikeui
node_app -->|"routes to"| node_reviewui
node_app -->|"routes to"| node_adminui
node_authui -->|"calls"| node_api_client
node_routeui -->|"calls"| node_api_client
node_routeui -->|"selects safest"| node_alternatives
node_routeui -->|"renders route on"| node_map
node_hazardui -->|"calls"| node_api_client
node_hazardui -->|"renders hazards on"| node_map
node_reportui -->|"calls"| node_api_client
node_reportui -->|"selects location on"| node_map
node_bikeui -->|"calls"| node_api_client
node_bikeui -->|"renders vehicles on"| node_map
node_reviewui -->|"calls"| node_api_client
node_adminui -->|"calls"| node_api_client
node_api_client -->|"sends REST requests"| node_express
node_express -->|"mounts"| node_auth
node_express -->|"mounts"| node_admin
node_express -->|"mounts"| node_hazards
node_express -->|"mounts"| node_routes
node_express -->|"mounts"| node_geocode
node_express -->|"mounts"| node_bikeshare
node_express -->|"mounts"| node_reviews
node_auth -->|"queries"| node_db_pool
node_admin -->|"queries"| node_db_pool
node_hazards -->|"queries"| node_db_pool
node_routes -->|"queries hazards and routes"| node_db_pool
node_reviews -->|"queries"| node_db_pool
node_db_pool -->|"connects to"| node_postgres
node_routes -->|"requests cycling directions"| node_ors
node_geocode -->|"requests geocoding"| node_ors
node_bikeshare -->|"proxies GBFS feed"| node_lime
node_routes -->|"guards route deletion"| node_auth_middleware
node_admin -->|"checks admin role"| node_auth_middleware
node_hazards -->|"checks protected actions"| node_auth_middleware
node_reviews -->|"guards mutations"| node_auth_middleware
node_routeui -->|"reads live position"| node_browser_geo

click node_app "https://github.com/rohin19/bikesafe/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/components/AuthPanel.tsx"
click node_routeui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/RoutesPage.tsx"
click node_alternatives "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/routeAlternatives.ts"
click node_map "https://github.com/rohin19/bikesafe/blob/main/frontend/src/components/Map.tsx"
click node_hazardui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/Hazards.tsx"
click node_reportui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/ReportHazard.tsx"
click node_bikeui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/BikeSharePage.tsx"
click node_reviewui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/ReviewsPage.tsx"
click node_adminui "https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/Admin.tsx"
click node_api_client "https://github.com/rohin19/bikesafe/blob/main/frontend/src/services/api.ts"
click node_express "https://github.com/rohin19/bikesafe/blob/main/backend/app.ts"
click node_auth "https://github.com/rohin19/bikesafe/blob/main/backend/routes/auth.ts"
click node_admin "https://github.com/rohin19/bikesafe/blob/main/backend/routes/admin.ts"
click node_hazards "https://github.com/rohin19/bikesafe/blob/main/backend/routes/hazards.ts"
click node_routes "https://github.com/rohin19/bikesafe/blob/main/backend/routes/routes.ts"
click node_geocode "https://github.com/rohin19/bikesafe/blob/main/backend/routes/geocode.ts"
click node_bikeshare "https://github.com/rohin19/bikesafe/blob/main/backend/routes/bikeShare.ts"
click node_reviews "https://github.com/rohin19/bikesafe/blob/main/backend/routes/reviews.ts"
click node_auth_middleware "https://github.com/rohin19/bikesafe/blob/main/backend/middleware/requireAuth.ts"
click node_db_pool "https://github.com/rohin19/bikesafe/blob/main/backend/db/index.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_app,node_authui,node_routeui,node_alternatives,node_map,node_hazardui,node_reportui,node_bikeui,node_reviewui,node_adminui,node_api_client,node_browser_geo toneBlue
class node_express,node_auth,node_admin,node_hazards,node_routes,node_geocode,node_bikeshare,node_reviews,node_auth_middleware toneAmber
class node_db_pool,node_postgres toneMint
class node_ors,node_lime toneRose
class node_cyclist toneIndigo
```

## Components

### Web application

- [Session and page routing](https://github.com/rohin19/bikesafe/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sign-in and registration](https://github.com/rohin19/bikesafe/blob/main/frontend/src/components/AuthPanel.tsx): `frontend/src/components/AuthPanel.tsx`
- [Route planning and navigation](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/RoutesPage.tsx): `frontend/src/pages/RoutesPage.tsx`
- [Alternative selection](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/routeAlternatives.ts): `frontend/src/pages/routeAlternatives.ts`
- [Interactive map](https://github.com/rohin19/bikesafe/blob/main/frontend/src/components/Map.tsx): `frontend/src/components/Map.tsx`
- [Hazard dashboard](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/Hazards.tsx): `frontend/src/pages/Hazards.tsx`
- [Hazard reporting](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/ReportHazard.tsx): `frontend/src/pages/ReportHazard.tsx`
- [Bike-share map](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/BikeSharePage.tsx): `frontend/src/pages/BikeSharePage.tsx`
- [Route reviews](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/ReviewsPage.tsx): `frontend/src/pages/ReviewsPage.tsx`
- [User administration](https://github.com/rohin19/bikesafe/blob/main/frontend/src/pages/Admin.tsx): `frontend/src/pages/Admin.tsx`
- [REST API client](https://github.com/rohin19/bikesafe/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Backend API

- [Express API](https://github.com/rohin19/bikesafe/blob/main/backend/app.ts): `backend/app.ts`
- [Authentication](https://github.com/rohin19/bikesafe/blob/main/backend/routes/auth.ts): `backend/routes/auth.ts`
- [Admin operations](https://github.com/rohin19/bikesafe/blob/main/backend/routes/admin.ts): `backend/routes/admin.ts`
- [Hazard service](https://github.com/rohin19/bikesafe/blob/main/backend/routes/hazards.ts): `backend/routes/hazards.ts`
- [Route planning and storage](https://github.com/rohin19/bikesafe/blob/main/backend/routes/routes.ts): `backend/routes/routes.ts`
- [Geocoding](https://github.com/rohin19/bikesafe/blob/main/backend/routes/geocode.ts): `backend/routes/geocode.ts`
- [Bike-share proxy](https://github.com/rohin19/bikesafe/blob/main/backend/routes/bikeShare.ts): `backend/routes/bikeShare.ts`
- [Review service](https://github.com/rohin19/bikesafe/blob/main/backend/routes/reviews.ts): `backend/routes/reviews.ts`
- [Auth and role checks](https://github.com/rohin19/bikesafe/blob/main/backend/middleware/requireAuth.ts): `backend/middleware/requireAuth.ts`

### Persistence

- [PostgreSQL connection](https://github.com/rohin19/bikesafe/blob/main/backend/db/index.ts): `backend/db/index.ts`
- **PostgreSQL**

### External services

- **OpenRouteService**
- **Lime GBFS feed**

### Other components

- **Cyclist**
- **Browser geolocation**

## Connections

- Cyclist → Session and page routing: uses
- Session and page routing → Sign-in and registration: shows when signed out (evidence: `frontend/src/App.tsx`)
- Session and page routing → Route planning and navigation: routes to (evidence: `frontend/src/App.tsx`)
- Session and page routing → Hazard dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Session and page routing → Hazard reporting: routes to (evidence: `frontend/src/App.tsx`)
- Session and page routing → Bike-share map: routes to (evidence: `frontend/src/App.tsx`)
- Session and page routing → Route reviews: routes to (evidence: `frontend/src/App.tsx`)
- Session and page routing → User administration: routes to (evidence: `frontend/src/App.tsx`)
- Sign-in and registration → REST API client: calls (evidence: `frontend/src/components/AuthPanel.tsx`)
- Route planning and navigation → REST API client: calls (evidence: `frontend/src/pages/RoutesPage.tsx`)
- Route planning and navigation → Alternative selection: selects safest (evidence: `frontend/src/pages/RoutesPage.tsx`)
- Route planning and navigation → Interactive map: renders route on (evidence: `frontend/src/pages/RoutesPage.tsx`)
- Hazard dashboard → REST API client: calls (evidence: `frontend/src/pages/Hazards.tsx`)
- Hazard dashboard → Interactive map: renders hazards on (evidence: `frontend/src/pages/Hazards.tsx`)
- Hazard reporting → REST API client: calls (evidence: `frontend/src/pages/ReportHazard.tsx`)
- Hazard reporting → Interactive map: selects location on (evidence: `frontend/src/pages/ReportHazard.tsx`)
- Bike-share map → REST API client: calls (evidence: `frontend/src/pages/BikeSharePage.tsx`)
- Bike-share map → Interactive map: renders vehicles on (evidence: `frontend/src/pages/BikeSharePage.tsx`)
- Route reviews → REST API client: calls (evidence: `frontend/src/pages/ReviewsPage.tsx`)
- User administration → REST API client: calls (evidence: `frontend/src/pages/Admin.tsx`)
- REST API client → Express API: sends REST requests (evidence: `frontend/src/services/api.ts`)
- Express API → Authentication: mounts (evidence: `backend/app.ts`)
- Express API → Admin operations: mounts (evidence: `backend/app.ts`)
- Express API → Hazard service: mounts (evidence: `backend/app.ts`)
- Express API → Route planning and storage: mounts (evidence: `backend/app.ts`)
- Express API → Geocoding: mounts (evidence: `backend/app.ts`)
- Express API → Bike-share proxy: mounts (evidence: `backend/app.ts`)
- Express API → Review service: mounts (evidence: `backend/app.ts`)
- Authentication → PostgreSQL connection: queries (evidence: `backend/routes/auth.ts`)
- Admin operations → PostgreSQL connection: queries (evidence: `backend/routes/admin.ts`)
- Hazard service → PostgreSQL connection: queries (evidence: `backend/routes/hazards.ts`)
- Route planning and storage → PostgreSQL connection: queries hazards and routes (evidence: `backend/routes/routes.ts`)
- Review service → PostgreSQL connection: queries (evidence: `backend/routes/reviews.ts`)
- PostgreSQL connection → PostgreSQL: connects to
- Route planning and storage → OpenRouteService: requests cycling directions
- Geocoding → OpenRouteService: requests geocoding
- Bike-share proxy → Lime GBFS feed: proxies GBFS feed
- Route planning and storage → Auth and role checks: guards route deletion (evidence: `backend/routes/routes.ts`)
- Admin operations → Auth and role checks: checks admin role (evidence: `backend/routes/admin.ts`)
- Hazard service → Auth and role checks: checks protected actions (evidence: `backend/routes/hazards.ts`)
- Review service → Auth and role checks: guards mutations (evidence: `backend/routes/reviews.ts`)
- Route planning and navigation → Browser geolocation: reads live position (evidence: `frontend/src/pages/RoutesPage.tsx`)
