# daisynbn/tquest architecture

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

- Interactive diagram: https://gitdiagram.com/daisynbn/tquest
- Repository: https://github.com/daisynbn/tquest

## Overview

TQuest is an Expo app that layers collectible-card gameplay onto MBTA rides. The rider-facing flow centers on the home screen and trip tracker: transit data and trip planning support a ride, while ride check-ins can lead to stamp pulls, stories, and collection progress. Separate screens provide station and art views, rewards, and train-card duels. The graph includes the major transit, collection, duel, and account/theme layers. Evidence is limited to the README and sampled/indexed references; unsampled screen behavior and several integrations are not asserted.

Main entry points: [`src/app/duel/[matchId].tsx`](https://github.com/daisynbn/tquest/blob/main/src/app/duel/%5BmatchId%5D.tsx) (Duel match), [`src/app/(tabs)/index.tsx`](https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/index.tsx) (Ride home), [`src/state/auth.tsx`](https://github.com/daisynbn/tquest/blob/main/src/state/auth.tsx) (Authentication), [`src/state/game.tsx`](https://github.com/daisynbn/tquest/blob/main/src/state/game.tsx) (Game state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transit["Transit and rides"]
  node_home["Ride home<br/>[index.tsx]"]
  node_trip["Trip tracker<br/>[useTrip.ts]"]
  node_planning["Trip planning<br/>[linePlan.ts]"]
  node_mbta["MBTA client<br/>[mbta.ts]"]
  node_line_data["Lines and stations<br/>[lines.ts]"]
  node_station_data["Station catalog<br/>[stations.ts]"]
  node_station_screen["Station details<br/>[&#91;id&#93;.tsx]"]
end

subgraph group_collect["Questie and collection"]
  node_pull["Stamp pull<br/>[PullModal.tsx]"]
  node_quest["Questie stories<br/>[questie.ts]"]
  node_cards["Stamp cards<br/>[StampCard.tsx]"]
  node_offline["Offline content<br/>[offline.ts]"]
  node_rewards["Rewards screen<br/>[rewards.tsx]"]
  node_art["Station art<br/>[&#91;id&#93;.tsx]"]
end

subgraph group_duels["Card duels"]
  node_duel_screen["Duel match<br/>[&#91;matchId&#93;.tsx]"]
  node_matchmaking["Matchmaking<br/>[useMatchmaking.ts]"]
  node_duel_ui["Duel interface<br/>[ClashArena.tsx]"]
  node_transport["Duel transport<br/>[transport.ts]"]
  node_bot["Bot transport<br/>[botTransport.ts]"]
  node_supabase_duel["Realtime duel"]
end

subgraph group_platform["Account and app"]
  node_auth["Authentication<br/>[auth.tsx]"]
  node_game["Game state<br/>[game.tsx]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_feedback["Feedback settings<br/>[feedback.tsx]"]
  node_theme["Theme provider<br/>[ThemeContext.tsx]"]
  node_account["Profile screen<br/>[you.tsx]"]
end

node_rider(("Rider"))

node_rider -.->|"opens"| node_home
node_home -->|"tracks trip"| node_trip
node_trip -->|"ticks plan"| node_planning
node_planning -->|"uses routes"| node_line_data
node_planning -->|"looks up stops"| node_station_data
node_trip -->|"fetches arrivals"| node_mbta
node_mbta -->|"maps stops"| node_station_data
node_home -.->|"links stations"| node_station_screen
node_home -.->|"opens pull"| node_pull
node_pull -->|"requests story"| node_quest
node_pull -->|"renders card"| node_cards
node_quest -->|"uses fallback"| node_offline
node_rewards -.->|"reads collection"| node_game
node_art -.->|"records art"| node_game
node_duel_screen -.->|"starts matching"| node_matchmaking
node_duel_screen -.->|"renders duel"| node_duel_ui
node_duel_screen -->|"selects transport"| node_transport
node_transport -->|"implemented by"| node_bot
node_duel_screen -->|"uses realtime"| node_supabase_duel
node_supabase_duel -->|"uses client"| node_supabase
node_duel_screen -->|"reads rider"| node_auth
node_duel_screen -->|"uses cards"| node_game
node_auth -->|"auth and profiles"| node_supabase
node_game -->|"syncs game data"| node_supabase
node_game -->|"uses session"| node_auth
node_auth -->|"syncs preferences"| node_feedback
node_account -.->|"manages profile"| node_auth
node_home -.->|"uses theme"| node_theme

click node_home "https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/index.tsx"
click node_trip "https://github.com/daisynbn/tquest/blob/main/src/hooks/useTrip.ts"
click node_planning "https://github.com/daisynbn/tquest/blob/main/src/lib/linePlan.ts"
click node_mbta "https://github.com/daisynbn/tquest/blob/main/src/api/mbta.ts"
click node_line_data "https://github.com/daisynbn/tquest/blob/main/src/data/lines.ts"
click node_station_data "https://github.com/daisynbn/tquest/blob/main/src/data/stations.ts"
click node_station_screen "https://github.com/daisynbn/tquest/blob/main/src/app/station/%5Bid%5D.tsx"
click node_pull "https://github.com/daisynbn/tquest/blob/main/src/components/PullModal.tsx"
click node_quest "https://github.com/daisynbn/tquest/blob/main/src/api/questie.ts"
click node_cards "https://github.com/daisynbn/tquest/blob/main/src/components/StampCard.tsx"
click node_offline "https://github.com/daisynbn/tquest/blob/main/src/data/offline.ts"
click node_rewards "https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/rewards.tsx"
click node_art "https://github.com/daisynbn/tquest/blob/main/src/app/art/%5Bid%5D.tsx"
click node_duel_screen "https://github.com/daisynbn/tquest/blob/main/src/app/duel/%5BmatchId%5D.tsx"
click node_matchmaking "https://github.com/daisynbn/tquest/blob/main/src/duel/match/useMatchmaking.ts"
click node_duel_ui "https://github.com/daisynbn/tquest/blob/main/src/duel/ui/ClashArena.tsx"
click node_transport "https://github.com/daisynbn/tquest/blob/main/src/features/duel/transport.ts"
click node_bot "https://github.com/daisynbn/tquest/blob/main/src/features/duel/botTransport.ts"
click node_supabase_duel "https://github.com/daisynbn/tquest/blob/main/src/duel/supabaseTransport.ts"
click node_auth "https://github.com/daisynbn/tquest/blob/main/src/state/auth.tsx"
click node_game "https://github.com/daisynbn/tquest/blob/main/src/state/game.tsx"
click node_supabase "https://github.com/daisynbn/tquest/blob/main/src/lib/supabase.ts"
click node_feedback "https://github.com/daisynbn/tquest/blob/main/src/state/feedback.tsx"
click node_theme "https://github.com/daisynbn/tquest/blob/main/src/theme/ThemeContext.tsx"
click node_account "https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/you.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_home,node_trip,node_planning,node_mbta,node_line_data,node_station_data,node_station_screen toneBlue
class node_pull,node_quest,node_cards,node_offline,node_rewards,node_art toneAmber
class node_duel_screen,node_matchmaking,node_duel_ui,node_transport,node_bot,node_supabase_duel toneMint
class node_auth,node_game,node_supabase,node_feedback,node_theme,node_account toneRose
class node_rider toneIndigo
```

## Components

### Transit and rides

- [Ride home](https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Trip tracker](https://github.com/daisynbn/tquest/blob/main/src/hooks/useTrip.ts): `src/hooks/useTrip.ts`
- [Trip planning](https://github.com/daisynbn/tquest/blob/main/src/lib/linePlan.ts): `src/lib/linePlan.ts`
- [MBTA client](https://github.com/daisynbn/tquest/blob/main/src/api/mbta.ts): `src/api/mbta.ts`
- [Lines and stations](https://github.com/daisynbn/tquest/blob/main/src/data/lines.ts): `src/data/lines.ts`
- [Station catalog](https://github.com/daisynbn/tquest/blob/main/src/data/stations.ts): `src/data/stations.ts`
- [Station details](https://github.com/daisynbn/tquest/blob/main/src/app/station/%5Bid%5D.tsx): `src/app/station/[id].tsx`

### Questie and collection

- [Stamp pull](https://github.com/daisynbn/tquest/blob/main/src/components/PullModal.tsx): `src/components/PullModal.tsx`
- [Questie stories](https://github.com/daisynbn/tquest/blob/main/src/api/questie.ts): `src/api/questie.ts`
- [Stamp cards](https://github.com/daisynbn/tquest/blob/main/src/components/StampCard.tsx): `src/components/StampCard.tsx`
- [Offline content](https://github.com/daisynbn/tquest/blob/main/src/data/offline.ts): `src/data/offline.ts`
- [Rewards screen](https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/rewards.tsx): `src/app/(tabs)/rewards.tsx`
- [Station art](https://github.com/daisynbn/tquest/blob/main/src/app/art/%5Bid%5D.tsx): `src/app/art/[id].tsx`

### Card duels

- [Duel match](https://github.com/daisynbn/tquest/blob/main/src/app/duel/%5BmatchId%5D.tsx): `src/app/duel/[matchId].tsx`
- [Matchmaking](https://github.com/daisynbn/tquest/blob/main/src/duel/match/useMatchmaking.ts): `src/duel/match/useMatchmaking.ts`
- [Duel interface](https://github.com/daisynbn/tquest/blob/main/src/duel/ui/ClashArena.tsx): `src/duel/ui/ClashArena.tsx`
- [Duel transport](https://github.com/daisynbn/tquest/blob/main/src/features/duel/transport.ts): `src/features/duel/transport.ts`
- [Bot transport](https://github.com/daisynbn/tquest/blob/main/src/features/duel/botTransport.ts): `src/features/duel/botTransport.ts`
- [Realtime duel](https://github.com/daisynbn/tquest/blob/main/src/duel/supabaseTransport.ts): `src/duel/supabaseTransport.ts`

### Account and app

- [Authentication](https://github.com/daisynbn/tquest/blob/main/src/state/auth.tsx): `src/state/auth.tsx`
- [Game state](https://github.com/daisynbn/tquest/blob/main/src/state/game.tsx): `src/state/game.tsx`
- [Supabase client](https://github.com/daisynbn/tquest/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Feedback settings](https://github.com/daisynbn/tquest/blob/main/src/state/feedback.tsx): `src/state/feedback.tsx`
- [Theme provider](https://github.com/daisynbn/tquest/blob/main/src/theme/ThemeContext.tsx): `src/theme/ThemeContext.tsx`
- [Profile screen](https://github.com/daisynbn/tquest/blob/main/src/app/(tabs)/you.tsx): `src/app/(tabs)/you.tsx`

### Other components

- **Rider**

## Connections

- Rider → Ride home: opens
- Ride home → Trip tracker: tracks trip (evidence: `src/app/(tabs)/index.tsx`)
- Trip tracker → Trip planning: ticks plan (evidence: `src/hooks/useTrip.ts`)
- Trip planning → Lines and stations: uses routes (evidence: `src/lib/linePlan.ts`)
- Trip planning → Station catalog: looks up stops (evidence: `src/lib/linePlan.ts`)
- Trip tracker → MBTA client: fetches arrivals (evidence: `src/hooks/useTrip.ts`)
- MBTA client → Station catalog: maps stops (evidence: `src/api/mbta.ts`)
- Ride home → Station details: links stations
- Ride home → Stamp pull: opens pull (evidence: `src/app/(tabs)/index.tsx`)
- Stamp pull → Questie stories: requests story (evidence: `src/components/PullModal.tsx`)
- Stamp pull → Stamp cards: renders card (evidence: `src/components/PullModal.tsx`)
- Questie stories → Offline content: uses fallback (evidence: `src/api/questie.ts`)
- Rewards screen → Game state: reads collection
- Station art → Game state: records art
- Duel match → Matchmaking: starts matching
- Duel match → Duel interface: renders duel
- Duel match → Duel transport: selects transport (evidence: `src/app/duel/[matchId].tsx`)
- Duel transport → Bot transport: implemented by (evidence: `src/features/duel/botTransport.ts`)
- Duel match → Realtime duel: uses realtime (evidence: `src/app/duel/[matchId].tsx`)
- Realtime duel → Supabase client: uses client (evidence: `src/duel/supabaseTransport.ts`)
- Duel match → Authentication: reads rider (evidence: `src/app/duel/[matchId].tsx`)
- Duel match → Game state: uses cards (evidence: `src/app/duel/[matchId].tsx`)
- Authentication → Supabase client: auth and profiles (evidence: `src/state/auth.tsx`)
- Game state → Supabase client: syncs game data (evidence: `src/state/game.tsx`)
- Game state → Authentication: uses session (evidence: `src/state/game.tsx`)
- Authentication → Feedback settings: syncs preferences (evidence: `src/state/auth.tsx`)
- Profile screen → Authentication: manages profile
- Ride home → Theme provider: uses theme (evidence: `src/app/(tabs)/index.tsx`)
