# ouss-elk/campus-type-rush architecture

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

- Interactive diagram: https://gitdiagram.com/ouss-elk/campus-type-rush
- Repository: https://github.com/ouss-elk/campus-type-rush

## Overview

Campus Type Rush is a local-first typing tournament: players join and race, an operator manages rounds and qualification, and a projector displays live standings and the final podium. The backend coordinates live sessions and tournament state, with SQLite preserving identities, settings, rounds, and results. The graph includes the main player, admin, and projector views plus configuration and protocol layers. Some detailed API and engine behavior is only partially excerpted, so those links rely on README statements rather than assumptions about unsampled code.

Main entry points: [`server/app.ts`](https://github.com/ouss-elk/campus-type-rush/blob/master/server/app.ts) (HTTP and sockets), [`server/engine.ts`](https://github.com/ouss-elk/campus-type-rush/blob/master/server/engine.ts) (Tournament engine), [`shared/protocol.ts`](https://github.com/ouss-elk/campus-type-rush/blob/master/shared/protocol.ts) (Shared protocol), [`client/src/player.tsx`](https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/player.tsx) (Player view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Tournament views"]
  node_player_view["Player view<br/>[player.tsx]"]
  node_admin_view["Admin console<br/>[admin.tsx]"]
  node_screen_view["Projector view<br/>[screen.tsx]"]
end

subgraph group_runtime["Application runtime"]
  node_configuration["Runtime configuration<br/>[config.ts]"]
  node_application["HTTP and sockets<br/>[app.ts]"]
  node_startup["Server startup<br/>[main.ts]"]
end

subgraph group_domain["Tournament domain"]
  node_engine["Tournament engine<br/>[engine.ts]"]
  node_passages["Typing passages<br/>[passages.json]"]
  node_utilities["Security utilities<br/>[util.ts]"]
end

subgraph group_state["Contracts and storage"]
  node_protocol["Shared protocol<br/>[protocol.ts]"]
  node_store[("Tournament store<br/>[store.ts]")]
end

node_players(("Players"))
node_operator(("Operator"))
node_audience(("Projector audience"))

node_players -->|"join and race"| node_player_view
node_operator -->|"manage rounds"| node_admin_view
node_audience -->|"view tournament"| node_screen_view
node_player_view -->|"join and connect"| node_application
node_admin_view -->|"authenticate and command"| node_application
node_screen_view -->|"receive live state"| node_application
node_startup -->|"loads settings"| node_configuration
node_startup -->|"creates and starts"| node_application
node_application -->|"serve tournament state"| node_engine
node_engine -->|"load and persist"| node_store
node_engine -->|"load passages"| node_passages
node_player_view -->|"uses message types"| node_protocol
node_admin_view -->|"uses command types"| node_protocol
node_screen_view -->|"uses state types"| node_protocol
node_application -->|"validates messages"| node_protocol
node_application -->|"uses security helpers"| node_utilities
node_engine -->|"uses validation helpers"| node_utilities
node_engine -->|"persist results"| node_store

click node_player_view "https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/player.tsx"
click node_admin_view "https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/admin.tsx"
click node_screen_view "https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/screen.tsx"
click node_configuration "https://github.com/ouss-elk/campus-type-rush/blob/master/server/config.ts"
click node_application "https://github.com/ouss-elk/campus-type-rush/blob/master/server/app.ts"
click node_startup "https://github.com/ouss-elk/campus-type-rush/blob/master/server/main.ts"
click node_engine "https://github.com/ouss-elk/campus-type-rush/blob/master/server/engine.ts"
click node_passages "https://github.com/ouss-elk/campus-type-rush/blob/master/server/passages.json"
click node_utilities "https://github.com/ouss-elk/campus-type-rush/blob/master/server/util.ts"
click node_protocol "https://github.com/ouss-elk/campus-type-rush/blob/master/shared/protocol.ts"
click node_store "https://github.com/ouss-elk/campus-type-rush/blob/master/server/store.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_player_view,node_admin_view,node_screen_view toneBlue
class node_configuration,node_application,node_startup toneAmber
class node_engine,node_passages,node_utilities toneMint
class node_protocol,node_store toneRose
class node_players,node_operator,node_audience toneIndigo
```

## Components

### Tournament views

- [Player view](https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/player.tsx): `client/src/player.tsx`
- [Admin console](https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/admin.tsx): `client/src/admin.tsx`
- [Projector view](https://github.com/ouss-elk/campus-type-rush/blob/master/client/src/screen.tsx): `client/src/screen.tsx`

### Application runtime

- [Runtime configuration](https://github.com/ouss-elk/campus-type-rush/blob/master/server/config.ts): `server/config.ts`
- [HTTP and sockets](https://github.com/ouss-elk/campus-type-rush/blob/master/server/app.ts): `server/app.ts`
- [Server startup](https://github.com/ouss-elk/campus-type-rush/blob/master/server/main.ts): `server/main.ts`

### Tournament domain

- [Tournament engine](https://github.com/ouss-elk/campus-type-rush/blob/master/server/engine.ts): `server/engine.ts`
- [Typing passages](https://github.com/ouss-elk/campus-type-rush/blob/master/server/passages.json): `server/passages.json`
- [Security utilities](https://github.com/ouss-elk/campus-type-rush/blob/master/server/util.ts): `server/util.ts`

### Contracts and storage

- [Shared protocol](https://github.com/ouss-elk/campus-type-rush/blob/master/shared/protocol.ts): `shared/protocol.ts`
- [Tournament store](https://github.com/ouss-elk/campus-type-rush/blob/master/server/store.ts): `server/store.ts`

### Other components

- **Players**
- **Operator**
- **Projector audience**

## Connections

- Players → Player view: join and race (evidence: `README.md`)
- Operator → Admin console: manage rounds (evidence: `README.md`)
- Projector audience → Projector view: view tournament (evidence: `README.md`)
- Player view → HTTP and sockets: join and connect (evidence: `client/src/player.tsx`)
- Admin console → HTTP and sockets: authenticate and command (evidence: `README.md`)
- Projector view → HTTP and sockets: receive live state (evidence: `client/src/screen.tsx`)
- Server startup → Runtime configuration: loads settings (evidence: `server/main.ts`)
- Server startup → HTTP and sockets: creates and starts (evidence: `server/main.ts`)
- HTTP and sockets → Tournament engine: serve tournament state (evidence: `server/app.ts`)
- Tournament engine → Tournament store: load and persist (evidence: `server/engine.ts`)
- Tournament engine → Typing passages: load passages (evidence: `server/engine.ts`)
- Player view → Shared protocol: uses message types (evidence: `client/src/player.tsx`)
- Admin console → Shared protocol: uses command types (evidence: `client/src/admin.tsx`)
- Projector view → Shared protocol: uses state types (evidence: `client/src/screen.tsx`)
- HTTP and sockets → Shared protocol: validates messages (evidence: `server/app.ts`)
- HTTP and sockets → Security utilities: uses security helpers (evidence: `server/app.ts`)
- Tournament engine → Security utilities: uses validation helpers (evidence: `server/engine.ts`)
- Tournament engine → Tournament store: persist results (evidence: `server/engine.ts`)
