# srujan-017/transitswap architecture

> Architecture diagram of the GitHub repository srujan-017/transitswap, 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/srujan-017/transitswap
- Repository: https://github.com/srujan-017/transitswap

## Overview

TransitSwap is an urban-mobility web app that helps commuters find and compare routes by time, cost, walking, accessibility, weather, crowding, and reliability. The principal workflow is a route request through the REST API to multimodal candidate generation, route enrichment, and preference-aware ranking, then results for the user. Other major capabilities include authentication, saved journeys, accessibility and crowd reporting, and research evaluation. The documented architecture and sampled controller support the main engine links; unsampled UI and backend route wiring are shown only where README or source-index evidence supports them.

Main entry points: [`backend/src/controllers/multimodalController.ts`](https://github.com/srujan-017/transitswap/blob/main/backend/src/controllers/multimodalController.ts) (Route request handler), [`src/services/intelligenceService.ts`](https://github.com/srujan-017/transitswap/blob/main/src/services/intelligenceService.ts) (Intelligence client), [`backend/src/app.ts`](https://github.com/srujan-017/transitswap/blob/main/backend/src/app.ts) (Express REST API), [`src/pages/PlanTripPage.tsx`](https://github.com/srujan-017/transitswap/blob/main/src/pages/PlanTripPage.tsx) (Plan trip UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_trip_ui["Plan trip UI<br/>[PlanTripPage.tsx]"]
  node_trip_client["Trip API client<br/>[tripService.ts]"]
  node_intelligence_client["Intelligence client"]
  node_research_ui["Research dashboard<br/>[ResearchPage.tsx]"]
end

subgraph group_api["REST API"]
  node_api_gateway["Express REST API<br/>[app.ts]"]
  node_multimodal_controller["Route request handler"]
end

subgraph group_intelligence["Route intelligence"]
  node_multimodal_engine["Multimodal candidates"]
  node_accessibility["Accessibility filter"]
  node_weather["Weather enrichment<br/>[weatherService.ts]"]
  node_crowd["Crowd enrichment<br/>[crowdService.ts]"]
  node_reliability["Reliability analysis"]
  node_transitdna["TransitDNA scoring"]
  node_ml_preferences["Pairwise preference learning"]
  node_accessibility_reports[("Accessibility reports")]
end

subgraph group_accounts["Accounts and trips"]
  node_auth["Authentication<br/>[authService.ts]"]
  node_user_store[("User records<br/>[User.ts]")]
  node_journeys["Journey history<br/>[tripController.ts]"]
  node_saved_routes["Saved routes"]
end

subgraph group_research["Reporting and evaluation"]
  node_evaluation["Research evaluation"]
end

node_commuter(("Commuter"))

node_commuter -->|"plans trip"| node_trip_ui
node_trip_ui -.->|"requests trip data"| node_trip_client
node_trip_client -->|"calls trip endpoints"| node_api_gateway
node_intelligence_client -->|"calls intelligence endpoints"| node_api_gateway
node_api_gateway -->|"routes requests"| node_multimodal_controller
node_multimodal_controller -->|"generates candidates"| node_multimodal_engine
node_multimodal_controller -->|"filters routes"| node_accessibility
node_multimodal_controller -->|"gets conditions"| node_weather
node_multimodal_controller -->|"summarizes crowding"| node_crowd
node_multimodal_controller -->|"analyzes reliability"| node_reliability
node_multimodal_controller -->|"ranks routes"| node_transitdna
node_multimodal_controller -->|"uses learned preferences"| node_ml_preferences
node_transitdna -->|"loads learned weights"| node_ml_preferences
node_auth -->|"reads and writes users"| node_user_store
node_journeys -.->|"supports saved routes"| node_saved_routes
node_accessibility -->|"records reports"| node_accessibility_reports
node_research_ui -->|"requests metrics"| node_intelligence_client
node_intelligence_client -.->|"requests evaluation"| node_evaluation
node_commuter -.->|"views benchmarks"| node_research_ui

click node_trip_ui "https://github.com/srujan-017/transitswap/blob/main/src/pages/PlanTripPage.tsx"
click node_trip_client "https://github.com/srujan-017/transitswap/blob/main/src/services/tripService.ts"
click node_intelligence_client "https://github.com/srujan-017/transitswap/blob/main/src/services/intelligenceService.ts"
click node_api_gateway "https://github.com/srujan-017/transitswap/blob/main/backend/src/app.ts"
click node_multimodal_controller "https://github.com/srujan-017/transitswap/blob/main/backend/src/controllers/multimodalController.ts"
click node_multimodal_engine "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/multimodalService.ts"
click node_accessibility "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/accessibilityService.ts"
click node_weather "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/weatherService.ts"
click node_crowd "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/crowdService.ts"
click node_reliability "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/reliabilityService.ts"
click node_transitdna "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/transitDnaService.ts"
click node_ml_preferences "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/ml/mlPreferenceService.ts"
click node_auth "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/authService.ts"
click node_user_store "https://github.com/srujan-017/transitswap/blob/main/backend/src/models/User.ts"
click node_journeys "https://github.com/srujan-017/transitswap/blob/main/backend/src/controllers/tripController.ts"
click node_saved_routes "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/savedRouteService.ts"
click node_accessibility_reports "https://github.com/srujan-017/transitswap/blob/main/backend/src/models/AccessibilityReport.ts"
click node_evaluation "https://github.com/srujan-017/transitswap/blob/main/backend/src/services/evaluationService.ts"
click node_research_ui "https://github.com/srujan-017/transitswap/blob/main/src/pages/ResearchPage.tsx"

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_trip_ui,node_trip_client,node_intelligence_client,node_research_ui toneBlue
class node_api_gateway,node_multimodal_controller toneAmber
class node_multimodal_engine,node_accessibility,node_weather,node_crowd,node_reliability,node_transitdna,node_ml_preferences,node_accessibility_reports toneMint
class node_auth,node_user_store,node_journeys,node_saved_routes toneRose
class node_evaluation,node_commuter toneIndigo
```

## Components

### Web client

- [Plan trip UI](https://github.com/srujan-017/transitswap/blob/main/src/pages/PlanTripPage.tsx): `src/pages/PlanTripPage.tsx`
- [Trip API client](https://github.com/srujan-017/transitswap/blob/main/src/services/tripService.ts): `src/services/tripService.ts`
- [Intelligence client](https://github.com/srujan-017/transitswap/blob/main/src/services/intelligenceService.ts): `src/services/intelligenceService.ts`
- [Research dashboard](https://github.com/srujan-017/transitswap/blob/main/src/pages/ResearchPage.tsx): `src/pages/ResearchPage.tsx`

### REST API

- [Express REST API](https://github.com/srujan-017/transitswap/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Route request handler](https://github.com/srujan-017/transitswap/blob/main/backend/src/controllers/multimodalController.ts): `backend/src/controllers/multimodalController.ts`

### Route intelligence

- [Multimodal candidates](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/multimodalService.ts): `backend/src/services/multimodalService.ts`
- [Accessibility filter](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/accessibilityService.ts): `backend/src/services/accessibilityService.ts`
- [Weather enrichment](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/weatherService.ts): `backend/src/services/weatherService.ts`
- [Crowd enrichment](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/crowdService.ts): `backend/src/services/crowdService.ts`
- [Reliability analysis](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/reliabilityService.ts): `backend/src/services/reliabilityService.ts`
- [TransitDNA scoring](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/transitDnaService.ts): `backend/src/services/transitDnaService.ts`
- [Pairwise preference learning](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/ml/mlPreferenceService.ts): `backend/src/services/ml/mlPreferenceService.ts`
- [Accessibility reports](https://github.com/srujan-017/transitswap/blob/main/backend/src/models/AccessibilityReport.ts): `backend/src/models/AccessibilityReport.ts`

### Accounts and trips

- [Authentication](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/authService.ts): `backend/src/services/authService.ts`
- [User records](https://github.com/srujan-017/transitswap/blob/main/backend/src/models/User.ts): `backend/src/models/User.ts`
- [Journey history](https://github.com/srujan-017/transitswap/blob/main/backend/src/controllers/tripController.ts): `backend/src/controllers/tripController.ts`
- [Saved routes](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/savedRouteService.ts): `backend/src/services/savedRouteService.ts`

### Reporting and evaluation

- [Research evaluation](https://github.com/srujan-017/transitswap/blob/main/backend/src/services/evaluationService.ts): `backend/src/services/evaluationService.ts`

### Other components

- **Commuter**

## Connections

- Commuter → Plan trip UI: plans trip
- Plan trip UI → Trip API client: requests trip data
- Trip API client → Express REST API: calls trip endpoints (evidence: `src/services/tripService.ts`)
- Intelligence client → Express REST API: calls intelligence endpoints (evidence: `src/services/intelligenceService.ts`)
- Express REST API → Route request handler: routes requests (evidence: `backend/src/app.ts`)
- Route request handler → Multimodal candidates: generates candidates (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → Accessibility filter: filters routes (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → Weather enrichment: gets conditions (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → Crowd enrichment: summarizes crowding (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → Reliability analysis: analyzes reliability (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → TransitDNA scoring: ranks routes (evidence: `backend/src/controllers/multimodalController.ts`)
- Route request handler → Pairwise preference learning: uses learned preferences (evidence: `backend/src/controllers/multimodalController.ts`)
- TransitDNA scoring → Pairwise preference learning: loads learned weights (evidence: `backend/src/services/transitDnaService.ts`)
- Authentication → User records: reads and writes users (evidence: `backend/src/services/authService.ts`)
- Journey history → Saved routes: supports saved routes
- Accessibility filter → Accessibility reports: records reports (evidence: `backend/src/services/accessibilityService.ts`)
- Research dashboard → Intelligence client: requests metrics (evidence: `src/pages/ResearchPage.tsx`)
- Intelligence client → Research evaluation: requests evaluation
- Commuter → Research dashboard: views benchmarks
