# accesswarrior/distance_learner architecture

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

- Interactive diagram: https://gitdiagram.com/accesswarrior/distance_learner
- Repository: https://github.com/accesswarrior/distance_learner

## Overview

Werewolf is a classroom companion for username/PIN access, room setup, private role assignment, and limited in-app voting and elimination; the moderator runs the remaining rounds in person. The main path is sign in, create or join a room, ready in the lobby, assign roles, then follow the live game state. Firestore backs room, player, and vote state, while Firebase Authentication handles credentials. Night/day gameplay beyond the documented controls remains manual. The graph reflects the sampled runtime source and README capabilities; unsampled details are not inferred.

Main entry points: [`js/main.js`](https://github.com/accesswarrior/distance_learner/blob/main/js/main.js) (App routing), [`js/core/lobby.js`](https://github.com/accesswarrior/distance_learner/blob/main/js/core/lobby.js) (Ready lobby), [`js/games/werewolf/ui.js`](https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/ui.js) (Live game view), [`js/core/auth.js`](https://github.com/accesswarrior/distance_learner/blob/main/js/core/auth.js) (Sign in)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access"]
  node_auth_flow["Sign in<br/>[auth.js]"]
end

subgraph group_rooms["Rooms"]
  node_app_flow["App routing<br/>[main.js]"]
  node_room_lifecycle["Room lifecycle<br/>[engine.js]"]
  node_lobby["Ready lobby<br/>[lobby.js]"]
end

subgraph group_game["Game"]
  node_role_rules["Role rules<br/>[rules.js]"]
  node_game_view["Live game view<br/>[ui.js]"]
  node_voting["Voting and outcomes<br/>[voting.js]"]
end

subgraph group_cloud["Firebase"]
  node_firebase_setup["Firebase setup<br/>[firebaseConfig.js]"]
  node_firebase_auth["Firebase Auth"]
  node_firestore[("Firestore")]
end

node_player(("Player"))
node_moderator(("Moderator"))

node_player -->|"signs in"| node_auth_flow
node_moderator -->|"signs in"| node_auth_flow
node_auth_flow -->|"authenticates"| node_firebase_auth
node_auth_flow -->|"stores profiles"| node_firestore
node_firebase_setup -->|"initializes"| node_firebase_auth
node_firebase_setup -->|"initializes"| node_firestore
node_firebase_auth -->|"auth state"| node_app_flow
node_app_flow -->|"reads session"| node_firestore
node_app_flow -->|"creates or joins"| node_room_lifecycle
node_app_flow -->|"opens lobby"| node_lobby
node_app_flow -->|"opens game"| node_game_view
node_player -->|"chooses room"| node_app_flow
node_moderator -->|"creates room"| node_app_flow
node_room_lifecycle -->|"writes room state"| node_firestore
node_lobby -->|"reads and updates roster"| node_firestore
node_lobby -->|"removes player"| node_room_lifecycle
node_lobby -->|"assigns roles"| node_role_rules
node_lobby -->|"opens after start"| node_game_view
node_moderator -->|"starts game"| node_lobby
node_player -->|"marks ready"| node_lobby
node_game_view -->|"listens to game state"| node_firestore
node_game_view -->|"dispatches vote actions"| node_voting
node_player -->|"views role and votes"| node_game_view
node_moderator -->|"views roles and controls"| node_game_view
node_voting -->|"reads and writes votes"| node_firestore
node_voting -->|"checks win condition"| node_role_rules

click node_auth_flow "https://github.com/accesswarrior/distance_learner/blob/main/js/core/auth.js"
click node_app_flow "https://github.com/accesswarrior/distance_learner/blob/main/js/main.js"
click node_room_lifecycle "https://github.com/accesswarrior/distance_learner/blob/main/js/core/engine.js"
click node_lobby "https://github.com/accesswarrior/distance_learner/blob/main/js/core/lobby.js"
click node_role_rules "https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/rules.js"
click node_game_view "https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/ui.js"
click node_voting "https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/voting.js"
click node_firebase_setup "https://github.com/accesswarrior/distance_learner/blob/main/js/core/firebaseConfig.js"

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_auth_flow toneBlue
class node_app_flow,node_room_lifecycle,node_lobby toneAmber
class node_role_rules,node_game_view,node_voting toneMint
class node_firebase_setup,node_firebase_auth,node_firestore toneRose
class node_player,node_moderator toneIndigo
```

## Components

### Access

- [Sign in](https://github.com/accesswarrior/distance_learner/blob/main/js/core/auth.js): `js/core/auth.js`

### Rooms

- [App routing](https://github.com/accesswarrior/distance_learner/blob/main/js/main.js): `js/main.js`
- [Room lifecycle](https://github.com/accesswarrior/distance_learner/blob/main/js/core/engine.js): `js/core/engine.js`
- [Ready lobby](https://github.com/accesswarrior/distance_learner/blob/main/js/core/lobby.js): `js/core/lobby.js`

### Game

- [Role rules](https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/rules.js): `js/games/werewolf/rules.js`
- [Live game view](https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/ui.js): `js/games/werewolf/ui.js`
- [Voting and outcomes](https://github.com/accesswarrior/distance_learner/blob/main/js/games/werewolf/voting.js): `js/games/werewolf/voting.js`

### Firebase

- [Firebase setup](https://github.com/accesswarrior/distance_learner/blob/main/js/core/firebaseConfig.js): `js/core/firebaseConfig.js`
- **Firebase Auth**
- **Firestore**

### Other components

- **Player**
- **Moderator**

## Connections

- Player → Sign in: signs in
- Moderator → Sign in: signs in
- Sign in → Firebase Auth: authenticates
- Sign in → Firestore: stores profiles
- Firebase setup → Firebase Auth: initializes
- Firebase setup → Firestore: initializes
- Firebase Auth → App routing: auth state
- App routing → Firestore: reads session
- App routing → Room lifecycle: creates or joins
- App routing → Ready lobby: opens lobby
- App routing → Live game view: opens game
- Player → App routing: chooses room
- Moderator → App routing: creates room
- Room lifecycle → Firestore: writes room state
- Ready lobby → Firestore: reads and updates roster
- Ready lobby → Room lifecycle: removes player
- Ready lobby → Role rules: assigns roles
- Ready lobby → Live game view: opens after start
- Moderator → Ready lobby: starts game
- Player → Ready lobby: marks ready
- Live game view → Firestore: listens to game state
- Live game view → Voting and outcomes: dispatches vote actions
- Player → Live game view: views role and votes
- Moderator → Live game view: views roles and controls
- Voting and outcomes → Firestore: reads and writes votes
- Voting and outcomes → Role rules: checks win condition
