# bryanjl/teckin architecture

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

- Interactive diagram: https://gitdiagram.com/bryanjl/teckin
- Repository: https://github.com/bryanjl/teckin

## Overview

Teckin is a mobile-first platform for classroom games: hosts sign in, author or select question sets, launch a live game, and review recorded results; players join by code and play on phones. The main game path runs through the web app, realtime rooms, shared question/session contracts, and the Climber game. Separate branches cover solo play, authentication, reports, and operations such as retention. Edges cite README relationships or shown source references; some dashboard and game internals are unsampled, so those links are limited to documented behavior.

Main entry points: [`apps/realtime/src/server.ts`](https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/server.ts) (Realtime endpoints), [`packages/room-core/src/base-game-room.ts`](https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/base-game-room.ts) (Room lifecycle), [`apps/web/src/app/dashboard/page.tsx`](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/page.tsx) (Host dashboard), [`packages/room-core/src/question-sessions.ts`](https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/question-sessions.ts) (Question sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web platform"]
  node_dashboard["Host dashboard<br/>[page.tsx]"]
  node_auth["Host sign-in<br/>[auth.ts]"]
  node_sets["Question sets<br/>[actions.ts]"]
  node_launcher["Game launch<br/>[game-launch.ts]"]
  node_join["Join flow<br/>[join.ts]"]
  node_hostscreen["Host screen<br/>[host-screen.tsx]"]
  node_playpage["Play page<br/>[page.tsx]"]
  node_reports["Past games and reports<br/>[page.tsx]"]
end

subgraph group_realtime["Live game service"]
  node_realtime_server["Realtime endpoints<br/>[server.ts]"]
  node_recorder["Session recorder"]
  node_retention["Data retention"]
end

subgraph group_shared["Game foundations"]
  node_rooms["Room lifecycle<br/>[base-game-room.ts]"]
  node_livegame["Live game state<br/>[live-game.ts]"]
  node_sessions["Question sessions"]
  node_contracts["Game session contract<br/>[session.ts]"]
  node_questions["Question engine<br/>[quiz.ts]"]
end

subgraph group_climber["Climber game"]
  node_climber_client["Climber client<br/>[index.ts]"]
  node_climber_scene["Course scene<br/>[course-scene.ts]"]
  node_climber_run["Climb simulation<br/>[climber-run.ts]"]
  node_climber_room["Climber room<br/>[climber-room.ts]"]
end

subgraph group_data["Accounts and records"]
  node_db[("PostgreSQL<br/>[client.ts]")]
end

node_host(("Host"))
node_player(("Player"))
node_redis[("Redis presence")]

node_host -->|"signs in"| node_auth
node_auth -->|"stores account"| node_db
node_host -->|"manages games"| node_dashboard
node_dashboard -->|"authors sets"| node_sets
node_dashboard -->|"launches game"| node_launcher
node_launcher -->|"sends signed launch"| node_realtime_server
node_player -->|"enters join code"| node_join
node_join -->|"looks up code"| node_realtime_server
node_realtime_server -->|"dispatches room"| node_rooms
node_realtime_server -.->|"shares presence"| node_redis
node_host -->|"hosts game"| node_hostscreen
node_player -->|"plays game"| node_playpage
node_rooms -.->|"manages live state"| node_livegame
node_livegame -.->|"uses question sessions"| node_sessions
node_sessions -->|"implements session"| node_contracts
node_sessions -->|"uses question engine"| node_questions
node_playpage -->|"loads game"| node_climber_client
node_climber_client -->|"creates scene"| node_climber_scene
node_climber_scene -->|"creates run"| node_climber_run
node_climber_client -->|"uses session"| node_contracts
node_rooms -.->|"runs game room"| node_climber_room
node_rooms -->|"records session events"| node_recorder
node_recorder -->|"writes game data"| node_db
node_realtime_server -->|"schedules cleanup"| node_retention
node_hostscreen -->|"reviews past games"| node_reports
node_reports -->|"reads recorded results"| node_db

click node_dashboard "https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/page.tsx"
click node_auth "https://github.com/bryanjl/teckin/blob/main/apps/web/src/auth.ts"
click node_sets "https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/sets/actions.ts"
click node_launcher "https://github.com/bryanjl/teckin/blob/main/apps/web/src/lib/game-launch.ts"
click node_join "https://github.com/bryanjl/teckin/blob/main/apps/web/src/lib/join.ts"
click node_hostscreen "https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/host/%5BgameSessionId%5D/host-screen.tsx"
click node_playpage "https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/play/%5Bcode%5D/page.tsx"
click node_reports "https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/games/%5BgameSessionId%5D/page.tsx"
click node_realtime_server "https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/server.ts"
click node_recorder "https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/database-recorder.ts"
click node_retention "https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/retention-schedule.ts"
click node_rooms "https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/base-game-room.ts"
click node_livegame "https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/live-game.ts"
click node_sessions "https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/question-sessions.ts"
click node_contracts "https://github.com/bryanjl/teckin/blob/main/packages/game-contracts/src/session.ts"
click node_questions "https://github.com/bryanjl/teckin/blob/main/packages/questions/src/quiz.ts"
click node_climber_client "https://github.com/bryanjl/teckin/blob/main/games/climber/src/client/index.ts"
click node_climber_scene "https://github.com/bryanjl/teckin/blob/main/games/climber/src/client/course-scene.ts"
click node_climber_run "https://github.com/bryanjl/teckin/blob/main/games/climber/src/run/climber-run.ts"
click node_climber_room "https://github.com/bryanjl/teckin/blob/main/games/climber/src/server/climber-room.ts"
click node_db "https://github.com/bryanjl/teckin/blob/main/packages/db/src/client.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_dashboard,node_auth,node_sets,node_launcher,node_join,node_hostscreen,node_playpage,node_reports toneBlue
class node_realtime_server,node_recorder,node_retention,node_redis toneAmber
class node_rooms,node_livegame,node_sessions,node_contracts,node_questions toneMint
class node_climber_client,node_climber_scene,node_climber_run,node_climber_room toneRose
class node_db,node_host,node_player toneIndigo
```

## Components

### Web platform

- [Host dashboard](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/page.tsx): `apps/web/src/app/dashboard/page.tsx`
- [Host sign-in](https://github.com/bryanjl/teckin/blob/main/apps/web/src/auth.ts): `apps/web/src/auth.ts`
- [Question sets](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/sets/actions.ts): `apps/web/src/app/dashboard/sets/actions.ts`
- [Game launch](https://github.com/bryanjl/teckin/blob/main/apps/web/src/lib/game-launch.ts): `apps/web/src/lib/game-launch.ts`
- [Join flow](https://github.com/bryanjl/teckin/blob/main/apps/web/src/lib/join.ts): `apps/web/src/lib/join.ts`
- [Host screen](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/host/%5BgameSessionId%5D/host-screen.tsx): `apps/web/src/app/host/[gameSessionId]/host-screen.tsx`
- [Play page](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/play/%5Bcode%5D/page.tsx): `apps/web/src/app/play/[code]/page.tsx`
- [Past games and reports](https://github.com/bryanjl/teckin/blob/main/apps/web/src/app/dashboard/games/%5BgameSessionId%5D/page.tsx): `apps/web/src/app/dashboard/games/[gameSessionId]/page.tsx`

### Live game service

- [Realtime endpoints](https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/server.ts): `apps/realtime/src/server.ts`
- [Session recorder](https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/database-recorder.ts): `apps/realtime/src/database-recorder.ts`
- [Data retention](https://github.com/bryanjl/teckin/blob/main/apps/realtime/src/retention-schedule.ts): `apps/realtime/src/retention-schedule.ts`

### Game foundations

- [Room lifecycle](https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/base-game-room.ts): `packages/room-core/src/base-game-room.ts`
- [Live game state](https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/live-game.ts): `packages/room-core/src/live-game.ts`
- [Question sessions](https://github.com/bryanjl/teckin/blob/main/packages/room-core/src/question-sessions.ts): `packages/room-core/src/question-sessions.ts`
- [Game session contract](https://github.com/bryanjl/teckin/blob/main/packages/game-contracts/src/session.ts): `packages/game-contracts/src/session.ts`
- [Question engine](https://github.com/bryanjl/teckin/blob/main/packages/questions/src/quiz.ts): `packages/questions/src/quiz.ts`

### Climber game

- [Climber client](https://github.com/bryanjl/teckin/blob/main/games/climber/src/client/index.ts): `games/climber/src/client/index.ts`
- [Course scene](https://github.com/bryanjl/teckin/blob/main/games/climber/src/client/course-scene.ts): `games/climber/src/client/course-scene.ts`
- [Climb simulation](https://github.com/bryanjl/teckin/blob/main/games/climber/src/run/climber-run.ts): `games/climber/src/run/climber-run.ts`
- [Climber room](https://github.com/bryanjl/teckin/blob/main/games/climber/src/server/climber-room.ts): `games/climber/src/server/climber-room.ts`

### Accounts and records

- [PostgreSQL](https://github.com/bryanjl/teckin/blob/main/packages/db/src/client.ts): `packages/db/src/client.ts`

### Other components

- **Host**
- **Player**
- **Redis presence**

## Connections

- Host → Host sign-in: signs in (evidence: `README.md`)
- Host sign-in → PostgreSQL: stores account (evidence: `apps/web/src/auth.ts`)
- Host → Host dashboard: manages games (evidence: `README.md`)
- Host dashboard → Question sets: authors sets (evidence: `README.md`)
- Host dashboard → Game launch: launches game (evidence: `README.md`)
- Game launch → Realtime endpoints: sends signed launch (evidence: `README.md`)
- Player → Join flow: enters join code (evidence: `README.md`)
- Join flow → Realtime endpoints: looks up code (evidence: `README.md`)
- Realtime endpoints → Room lifecycle: dispatches room (evidence: `apps/realtime/src/server.ts`)
- Realtime endpoints → Redis presence: shares presence (evidence: `README.md`)
- Host → Host screen: hosts game (evidence: `README.md`)
- Player → Play page: plays game (evidence: `README.md`)
- Room lifecycle → Live game state: manages live state
- Live game state → Question sessions: uses question sessions
- Question sessions → Game session contract: implements session (evidence: `packages/room-core/src/question-sessions.ts`)
- Question sessions → Question engine: uses question engine (evidence: `packages/room-core/src/question-sessions.ts`)
- Play page → Climber client: loads game (evidence: `README.md`)
- Climber client → Course scene: creates scene (evidence: `games/climber/src/client/index.ts`)
- Course scene → Climb simulation: creates run (evidence: `games/climber/src/client/course-scene.ts`)
- Climber client → Game session contract: uses session (evidence: `games/climber/src/client/index.ts`)
- Room lifecycle → Climber room: runs game room
- Room lifecycle → Session recorder: records session events
- Session recorder → PostgreSQL: writes game data (evidence: `apps/realtime/src/database-recorder.ts`)
- Realtime endpoints → Data retention: schedules cleanup (evidence: `apps/realtime/src/main.ts`)
- Host screen → Past games and reports: reviews past games (evidence: `README.md`)
- Past games and reports → PostgreSQL: reads recorded results (evidence: `README.md`)
