# scifimegahype/habemus-papam-online architecture

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

- Interactive diagram: https://gitdiagram.com/scifimegahype/habemus-papam-online
- Repository: https://github.com/scifimegahype/habemus-papam-online

## Overview

Habemus Papam is an online 3–6 player game: players create or join a coded room, choose actions privately, and follow the game through live updates until a candidate wins. The server owns in-memory rooms and the authoritative rules engine, mediating player decisions and keeping hidden actions private. The README also documents lobby options, computer players, reconnects, ballots and final eliminations, private whispers, and separately hosted pages. Those UI capabilities are represented at the client boundary; client implementation was not sampled, so its detailed calls are not shown.

Main entry points: [`server.js`](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js) (Room API), [`engine.js`](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js) (Rules engine), [`public/index.html`](https://github.com/scifimegahype/habemus-papam-online/blob/main/public/index.html) (Game page), [`public/config.js`](https://github.com/scifimegahype/habemus-papam-online/blob/main/public/config.js) (Server address)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Player experience"]
  node_web_client["Game page<br/>[index.html]"]
  node_config["Server address<br/>[config.js]"]
end

subgraph group_server["Room server"]
  node_room_api["Room API<br/>[server.js]"]
  node_room_state[("In-memory rooms<br/>[server.js]")]
  node_lobby["Lobby and seats<br/>[server.js]"]
  node_prompts["Decision prompts<br/>[server.js]"]
  node_live_updates["Live updates<br/>[server.js]"]
  node_chat["Table Talk<br/>[server.js]"]
  node_bots["Computer players<br/>[server.js]"]
end

subgraph group_game["Game rules"]
  node_game_engine["Rules engine<br/>[engine.js]"]
  node_action_round["Secret action round<br/>[engine.js]"]
  node_spirit_cards["Spirit cards<br/>[engine.js]"]
  node_ballot["Conclave ballot<br/>[engine.js]"]
  node_final_phase["Final phase<br/>[engine.js]"]
end

node_player(("Players"))

node_player -->|"plays through"| node_web_client
node_web_client -->|"sends decisions"| node_room_api
node_web_client -->|"receives updates"| node_live_updates
node_config -->|"configures server"| node_web_client
node_room_api -->|"manages rooms"| node_room_state
node_room_api -->|"handles lobby"| node_lobby
node_room_api -->|"validates answers"| node_prompts
node_room_api -->|"serves streams"| node_live_updates
node_room_api -.->|"routes whispers"| node_chat
node_room_api -->|"supports takeover"| node_bots
node_room_api -->|"runs authoritative game"| node_game_engine
node_game_engine -->|"resolves actions"| node_action_round
node_game_engine -->|"resolves cards"| node_spirit_cards
node_game_engine -->|"awards votes"| node_ballot
node_game_engine -.->|"runs eliminations"| node_final_phase
node_action_round -.->|"requests choices"| node_prompts
node_bots -->|"answers prompts"| node_prompts

click node_web_client "https://github.com/scifimegahype/habemus-papam-online/blob/main/public/index.html"
click node_config "https://github.com/scifimegahype/habemus-papam-online/blob/main/public/config.js"
click node_room_api "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_room_state "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_lobby "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_prompts "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_live_updates "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_chat "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_bots "https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js"
click node_game_engine "https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js"
click node_action_round "https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js"
click node_spirit_cards "https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js"
click node_ballot "https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js"
click node_final_phase "https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.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_web_client,node_config toneBlue
class node_room_api,node_room_state,node_lobby,node_prompts,node_live_updates,node_chat,node_bots toneAmber
class node_game_engine,node_action_round,node_spirit_cards,node_ballot,node_final_phase toneMint
class node_player toneIndigo
```

## Components

### Player experience

- [Game page](https://github.com/scifimegahype/habemus-papam-online/blob/main/public/index.html): `public/index.html`
- [Server address](https://github.com/scifimegahype/habemus-papam-online/blob/main/public/config.js): `public/config.js`

### Room server

- [Room API](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [In-memory rooms](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [Lobby and seats](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [Decision prompts](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [Live updates](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [Table Talk](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`
- [Computer players](https://github.com/scifimegahype/habemus-papam-online/blob/main/server.js): `server.js`

### Game rules

- [Rules engine](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js): `engine.js`
- [Secret action round](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js): `engine.js`
- [Spirit cards](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js): `engine.js`
- [Conclave ballot](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js): `engine.js`
- [Final phase](https://github.com/scifimegahype/habemus-papam-online/blob/main/engine.js): `engine.js`

### Other components

- **Players**

## Connections

- Players → Game page: plays through (evidence: `README.md`)
- Game page → Room API: sends decisions (evidence: `README.md`)
- Game page → Live updates: receives updates (evidence: `README.md`)
- Server address → Game page: configures server (evidence: `public/config.js`)
- Room API → In-memory rooms: manages rooms (evidence: `server.js`)
- Room API → Lobby and seats: handles lobby (evidence: `server.js`)
- Room API → Decision prompts: validates answers (evidence: `server.js`)
- Room API → Live updates: serves streams (evidence: `server.js`)
- Room API → Table Talk: routes whispers (evidence: `README.md`)
- Room API → Computer players: supports takeover (evidence: `server.js`)
- Room API → Rules engine: runs authoritative game (evidence: `README.md`)
- Rules engine → Secret action round: resolves actions (evidence: `engine.js`)
- Rules engine → Spirit cards: resolves cards (evidence: `engine.js`)
- Rules engine → Conclave ballot: awards votes (evidence: `engine.js`)
- Rules engine → Final phase: runs eliminations (evidence: `README.md`)
- Secret action round → Decision prompts: requests choices (evidence: `server.js`)
- Computer players → Decision prompts: answers prompts (evidence: `server.js`)
