# cohortjuan/rwr architecture

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

- Interactive diagram: https://gitdiagram.com/cohortjuan/rwr
- Repository: https://github.com/cohortjuan/rwr

## Overview

RWR is a browser-based career-exploration adventure: players answer guided quests across four purpose circles, record evidence, compare the circles at Crossroads, choose or write a goal, and test it through real-world steps before celebrating completion. The map also includes supporting branches for a friend's witness, saved letters, lion progression/customization, and pride connections. Core interview, persistence, map, and AI-route relationships are shown where the excerpts or README document them; several feature screens are represented by their exact component paths, but their internal calls were not sampled.

Main entry points: [`components/LevelQuest.tsx`](https://github.com/cohortjuan/rwr/blob/main/components/LevelQuest.tsx) (Circle quests), [`app/api/todah/route.ts`](https://github.com/cohortjuan/rwr/blob/main/app/api/todah/route.ts) (Todah API), [`components/CrossroadsScreen.tsx`](https://github.com/cohortjuan/rwr/blob/main/components/CrossroadsScreen.tsx) (Crossroads paths), [`components/TrailMapScreen.tsx`](https://github.com/cohortjuan/rwr/blob/main/components/TrailMapScreen.tsx) (Evidence map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trail["Career trail"]
  node_onboarding["Onboarding quest"]
  node_level["Circle quests<br/>[LevelQuest.tsx]"]
  node_map["Evidence map<br/>[TrailMapScreen.tsx]"]
  node_crossroads["Crossroads paths"]
  node_road["Goal experiments<br/>[RoadScreen.tsx]"]
end

subgraph group_guidance["Todah guidance"]
  node_api["Todah API<br/>[route.ts]"]
  node_prompts["Prompt construction<br/>[prompts.ts]"]
  node_llm["AI provider access<br/>[llm.ts]"]
  node_script["Scripted dialogue<br/>[lines.ts]"]
  node_occupations["Occupation pool<br/>[occupations.ts]"]
end

subgraph group_growth["Lion growth"]
  node_pride["My Pride<br/>[PrideScreen.tsx]"]
  node_upgrades["Lion upgrades<br/>[UpgradesScreen.tsx]"]
  node_wardrobe["Wardrobe<br/>[WardrobeScreen.tsx]"]
  node_suggest["Suggestion endpoint<br/>[route.ts]"]
  node_mail["Mail service<br/>[mail.ts]"]
end

subgraph group_community["Pride and keepsakes"]
  node_witness["Friend witness<br/>[WitnessScreen.tsx]"]
  node_letter["Sealed letter<br/>[SealedLetter.tsx]"]
  node_card["Trail keepsake"]
  node_roar["Roar and credits<br/>[RoarScreen.tsx]"]
end

subgraph group_platform["Browser services"]
  node_progress[("Trail progress<br/>[progress.ts]")]
  node_compass["Evidence scoring<br/>[compass.ts]"]
  node_settings[("Player settings<br/>[settings.ts]")]
end

node_player(("Player"))
node_occupation_data[("BLS occupations")]
node_ai_provider{{"AI providers"}}

node_player -->|"starts journey"| node_onboarding
node_player -->|"answers quests"| node_level
node_level -->|"uses fallback lines"| node_script
node_level -->|"saves answers"| node_progress
node_level -->|"marks claims"| node_map
node_player -->|"ticks evidence"| node_map
node_map -->|"scores circles"| node_compass
node_player -->|"compares circles"| node_crossroads
node_crossroads -.->|"requests guidance"| node_api
node_api -->|"builds prompts"| node_prompts
node_api -->|"generates reply"| node_llm
node_llm -.->|"calls provider"| node_ai_provider
node_api -->|"filters paths"| node_occupations
node_occupations -.->|"selects occupations"| node_occupation_data
node_crossroads -->|"saves goal"| node_progress
node_player -->|"tests goal"| node_road
node_road -->|"updates trail"| node_progress
node_player -->|"requests witness"| node_witness
node_player -->|"seals letter"| node_letter
node_player -->|"views keepsake"| node_card
node_player -->|"confirms reached"| node_roar
node_player -->|"follows lions"| node_pride
node_player -->|"fills resume"| node_upgrades
node_player -->|"customizes lion"| node_wardrobe
node_wardrobe -->|"sends idea"| node_suggest
node_suggest -->|"sends suggestion"| node_mail
node_level -->|"reads settings"| node_settings

click node_onboarding "https://github.com/cohortjuan/rwr/blob/main/components/OnboardingQuest.tsx"
click node_level "https://github.com/cohortjuan/rwr/blob/main/components/LevelQuest.tsx"
click node_map "https://github.com/cohortjuan/rwr/blob/main/components/TrailMapScreen.tsx"
click node_crossroads "https://github.com/cohortjuan/rwr/blob/main/components/CrossroadsScreen.tsx"
click node_road "https://github.com/cohortjuan/rwr/blob/main/components/RoadScreen.tsx"
click node_api "https://github.com/cohortjuan/rwr/blob/main/app/api/todah/route.ts"
click node_prompts "https://github.com/cohortjuan/rwr/blob/main/lib/prompts.ts"
click node_llm "https://github.com/cohortjuan/rwr/blob/main/lib/llm.ts"
click node_script "https://github.com/cohortjuan/rwr/blob/main/lib/lines.ts"
click node_occupations "https://github.com/cohortjuan/rwr/blob/main/lib/occupations.ts"
click node_progress "https://github.com/cohortjuan/rwr/blob/main/lib/progress.ts"
click node_compass "https://github.com/cohortjuan/rwr/blob/main/lib/compass.ts"
click node_settings "https://github.com/cohortjuan/rwr/blob/main/lib/settings.ts"
click node_witness "https://github.com/cohortjuan/rwr/blob/main/components/WitnessScreen.tsx"
click node_letter "https://github.com/cohortjuan/rwr/blob/main/components/SealedLetter.tsx"
click node_card "https://github.com/cohortjuan/rwr/blob/main/components/TrailCardScreen.tsx"
click node_roar "https://github.com/cohortjuan/rwr/blob/main/components/RoarScreen.tsx"
click node_pride "https://github.com/cohortjuan/rwr/blob/main/components/PrideScreen.tsx"
click node_upgrades "https://github.com/cohortjuan/rwr/blob/main/components/UpgradesScreen.tsx"
click node_wardrobe "https://github.com/cohortjuan/rwr/blob/main/components/WardrobeScreen.tsx"
click node_suggest "https://github.com/cohortjuan/rwr/blob/main/app/api/suggest/route.ts"
click node_mail "https://github.com/cohortjuan/rwr/blob/main/lib/mail.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_onboarding,node_level,node_map,node_crossroads,node_road toneBlue
class node_api,node_prompts,node_llm,node_script,node_occupations,node_occupation_data toneAmber
class node_pride,node_upgrades,node_wardrobe,node_suggest,node_mail toneMint
class node_witness,node_letter,node_card,node_roar toneRose
class node_progress,node_compass,node_settings,node_player,node_ai_provider toneIndigo
```

## Components

### Career trail

- [Onboarding quest](https://github.com/cohortjuan/rwr/blob/main/components/OnboardingQuest.tsx): `components/OnboardingQuest.tsx`
- [Circle quests](https://github.com/cohortjuan/rwr/blob/main/components/LevelQuest.tsx): `components/LevelQuest.tsx`
- [Evidence map](https://github.com/cohortjuan/rwr/blob/main/components/TrailMapScreen.tsx): `components/TrailMapScreen.tsx`
- [Crossroads paths](https://github.com/cohortjuan/rwr/blob/main/components/CrossroadsScreen.tsx): `components/CrossroadsScreen.tsx`
- [Goal experiments](https://github.com/cohortjuan/rwr/blob/main/components/RoadScreen.tsx): `components/RoadScreen.tsx`

### Todah guidance

- [Todah API](https://github.com/cohortjuan/rwr/blob/main/app/api/todah/route.ts): `app/api/todah/route.ts`
- [Prompt construction](https://github.com/cohortjuan/rwr/blob/main/lib/prompts.ts): `lib/prompts.ts`
- [AI provider access](https://github.com/cohortjuan/rwr/blob/main/lib/llm.ts): `lib/llm.ts`
- [Scripted dialogue](https://github.com/cohortjuan/rwr/blob/main/lib/lines.ts): `lib/lines.ts`
- [Occupation pool](https://github.com/cohortjuan/rwr/blob/main/lib/occupations.ts): `lib/occupations.ts`

### Lion growth

- [My Pride](https://github.com/cohortjuan/rwr/blob/main/components/PrideScreen.tsx): `components/PrideScreen.tsx`
- [Lion upgrades](https://github.com/cohortjuan/rwr/blob/main/components/UpgradesScreen.tsx): `components/UpgradesScreen.tsx`
- [Wardrobe](https://github.com/cohortjuan/rwr/blob/main/components/WardrobeScreen.tsx): `components/WardrobeScreen.tsx`
- [Suggestion endpoint](https://github.com/cohortjuan/rwr/blob/main/app/api/suggest/route.ts): `app/api/suggest/route.ts`
- [Mail service](https://github.com/cohortjuan/rwr/blob/main/lib/mail.ts): `lib/mail.ts`

### Pride and keepsakes

- [Friend witness](https://github.com/cohortjuan/rwr/blob/main/components/WitnessScreen.tsx): `components/WitnessScreen.tsx`
- [Sealed letter](https://github.com/cohortjuan/rwr/blob/main/components/SealedLetter.tsx): `components/SealedLetter.tsx`
- [Trail keepsake](https://github.com/cohortjuan/rwr/blob/main/components/TrailCardScreen.tsx): `components/TrailCardScreen.tsx`
- [Roar and credits](https://github.com/cohortjuan/rwr/blob/main/components/RoarScreen.tsx): `components/RoarScreen.tsx`

### Browser services

- [Trail progress](https://github.com/cohortjuan/rwr/blob/main/lib/progress.ts): `lib/progress.ts`
- [Evidence scoring](https://github.com/cohortjuan/rwr/blob/main/lib/compass.ts): `lib/compass.ts`
- [Player settings](https://github.com/cohortjuan/rwr/blob/main/lib/settings.ts): `lib/settings.ts`

### Other components

- **Player**
- **BLS occupations**
- **AI providers**

## Connections

- Player → Onboarding quest: starts journey
- Player → Circle quests: answers quests
- Circle quests → Scripted dialogue: uses fallback lines (evidence: `components/LevelQuest.tsx`)
- Circle quests → Trail progress: saves answers (evidence: `components/LevelQuest.tsx`)
- Circle quests → Evidence map: marks claims (evidence: `components/LevelQuest.tsx`)
- Player → Evidence map: ticks evidence
- Evidence map → Evidence scoring: scores circles
- Player → Crossroads paths: compares circles
- Crossroads paths → Todah API: requests guidance
- Todah API → Prompt construction: builds prompts (evidence: `app/api/todah/route.ts`)
- Todah API → AI provider access: generates reply (evidence: `app/api/todah/route.ts`)
- AI provider access → AI providers: calls provider
- Todah API → Occupation pool: filters paths (evidence: `app/api/todah/route.ts`)
- Occupation pool → BLS occupations: selects occupations
- Crossroads paths → Trail progress: saves goal (evidence: `components/CrossroadsScreen.tsx`)
- Player → Goal experiments: tests goal
- Goal experiments → Trail progress: updates trail (evidence: `components/RoadScreen.tsx`)
- Player → Friend witness: requests witness
- Player → Sealed letter: seals letter
- Player → Trail keepsake: views keepsake
- Player → Roar and credits: confirms reached
- Player → My Pride: follows lions
- Player → Lion upgrades: fills resume
- Player → Wardrobe: customizes lion
- Wardrobe → Suggestion endpoint: sends idea
- Suggestion endpoint → Mail service: sends suggestion (evidence: `app/api/suggest/route.ts`)
- Circle quests → Player settings: reads settings (evidence: `components/LevelQuest.tsx`)
