# cedardb/sqldoom architecture

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

- Interactive diagram: https://gitdiagram.com/cedardb/sqldoom
- Repository: https://github.com/cedardb/sqldoom

## Overview

SQLDoom is a Doom game whose game logic and rendering run in CedarDB; Python and browser clients handle input, timing, display, and audio. The main workflow is WAD import into database state, then client input drives fixed-rate game tics while frame requests render independently. The README documents the SQL runtime, renderer, and state paths, though those files are absent from the supplied tree. Relationships involving those unsampled SQL components are shown only where the README explicitly describes them.

Main entry points: [`doom_client.py`](https://github.com/cedardb/sqldoom/blob/main/doom_client.py) (Desktop client), [`doom_sql.py`](https://github.com/cedardb/sqldoom/blob/main/doom_sql.py) (SQL adapter), [`sql/schema.sql`](https://github.com/cedardb/sqldoom/blob/main/sql/schema.sql) (CedarDB state), [`web/app.js`](https://github.com/cedardb/sqldoom/blob/main/web/app.js) (Browser client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Game content"]
  node_wad["WAD importer<br/>[wad_loader.py]"]
  node_wadsql["WAD SQL<br/>[wad_sql.py]"]
  node_midi["MIDI renderer<br/>[midi_render.py]"]
end

subgraph group_database["Database game runtime"]
  node_db[("CedarDB state<br/>[schema.sql]")]
  node_runtime["Game runtime"]
  node_renderer["SQL renderer<br/>[renderer.sql]"]
end

subgraph group_clients["Game clients"]
  node_adapter["SQL adapter<br/>[doom_sql.py]"]
  node_desktop["Desktop client<br/>[doom_client.py]"]
  node_renderworker["Render worker<br/>[render_worker.py]"]
  node_audio["Audio devices<br/>[audio.py]"]
  node_dock["Diagnostics dock<br/>[dock.py]"]
  node_config["Client configuration<br/>[doom_config.py]"]
  node_webclient["Browser client<br/>[app.js]"]
  node_pgwire["Browser PG client<br/>[pgwire.js]"]
end

subgraph group_multiplayer["Multiplayer"]
  node_server["Match server<br/>[doom_server.py]"]
  node_webrelay["WebSocket relay<br/>[doom_web.py]"]
end

node_player(("Player"))

node_player -->|"provides input"| node_desktop
node_desktop -->|"calls"| node_adapter
node_desktop -->|"requests frames"| node_renderworker
node_desktop -->|"plays audio"| node_audio
node_desktop -->|"shows diagnostics"| node_dock
node_desktop -->|"reads settings"| node_config
node_renderworker -->|"renders through"| node_adapter
node_adapter -->|"queries state"| node_db
node_adapter -->|"runs game tics"| node_runtime
node_adapter -->|"requests frames"| node_renderer
node_runtime -->|"updates state"| node_db
node_renderer -->|"reads game state"| node_db
node_wad -->|"uses SQL helpers"| node_wadsql
node_wad -->|"renders music"| node_midi
node_wad -->|"loads game data"| node_db
node_webclient -->|"uses protocol"| node_pgwire
node_player -->|"provides input"| node_webclient
node_webclient -->|"connects by WebSocket"| node_webrelay
node_webclient -->|"sends game input"| node_db
node_server -->|"drives match"| node_runtime
node_server -->|"manages match state"| node_db
node_audio -->|"fetches audio data"| node_adapter

click node_wad "https://github.com/cedardb/sqldoom/blob/main/wad_loader.py"
click node_wadsql "https://github.com/cedardb/sqldoom/blob/main/wad_sql.py"
click node_midi "https://github.com/cedardb/sqldoom/blob/main/midi_render.py"
click node_db "https://github.com/cedardb/sqldoom/blob/main/sql/schema.sql"
click node_runtime "https://github.com/cedardb/sqldoom/blob/main/cedarscript_runtime.py"
click node_renderer "https://github.com/cedardb/sqldoom/blob/main/sql/renderer.sql"
click node_adapter "https://github.com/cedardb/sqldoom/blob/main/doom_sql.py"
click node_desktop "https://github.com/cedardb/sqldoom/blob/main/doom_client.py"
click node_renderworker "https://github.com/cedardb/sqldoom/blob/main/render_worker.py"
click node_audio "https://github.com/cedardb/sqldoom/blob/main/audio.py"
click node_dock "https://github.com/cedardb/sqldoom/blob/main/dock.py"
click node_config "https://github.com/cedardb/sqldoom/blob/main/doom_config.py"
click node_webclient "https://github.com/cedardb/sqldoom/blob/main/web/app.js"
click node_pgwire "https://github.com/cedardb/sqldoom/blob/main/web/pgwire.js"
click node_server "https://github.com/cedardb/sqldoom/blob/main/doom_server.py"
click node_webrelay "https://github.com/cedardb/sqldoom/blob/main/doom_web.py"

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_wad,node_wadsql,node_midi toneBlue
class node_db,node_runtime,node_renderer toneAmber
class node_adapter,node_desktop,node_renderworker,node_audio,node_dock,node_config,node_webclient,node_pgwire toneMint
class node_server,node_webrelay toneRose
class node_player toneIndigo
```

## Components

### Game content

- [WAD importer](https://github.com/cedardb/sqldoom/blob/main/wad_loader.py): `wad_loader.py`
- [WAD SQL](https://github.com/cedardb/sqldoom/blob/main/wad_sql.py): `wad_sql.py`
- [MIDI renderer](https://github.com/cedardb/sqldoom/blob/main/midi_render.py): `midi_render.py`

### Database game runtime

- [CedarDB state](https://github.com/cedardb/sqldoom/blob/main/sql/schema.sql): `sql/schema.sql`
- [Game runtime](https://github.com/cedardb/sqldoom/blob/main/cedarscript_runtime.py): `cedarscript_runtime.py`
- [SQL renderer](https://github.com/cedardb/sqldoom/blob/main/sql/renderer.sql): `sql/renderer.sql`

### Game clients

- [SQL adapter](https://github.com/cedardb/sqldoom/blob/main/doom_sql.py): `doom_sql.py`
- [Desktop client](https://github.com/cedardb/sqldoom/blob/main/doom_client.py): `doom_client.py`
- [Render worker](https://github.com/cedardb/sqldoom/blob/main/render_worker.py): `render_worker.py`
- [Audio devices](https://github.com/cedardb/sqldoom/blob/main/audio.py): `audio.py`
- [Diagnostics dock](https://github.com/cedardb/sqldoom/blob/main/dock.py): `dock.py`
- [Client configuration](https://github.com/cedardb/sqldoom/blob/main/doom_config.py): `doom_config.py`
- [Browser client](https://github.com/cedardb/sqldoom/blob/main/web/app.js): `web/app.js`
- [Browser PG client](https://github.com/cedardb/sqldoom/blob/main/web/pgwire.js): `web/pgwire.js`

### Multiplayer

- [Match server](https://github.com/cedardb/sqldoom/blob/main/doom_server.py): `doom_server.py`
- [WebSocket relay](https://github.com/cedardb/sqldoom/blob/main/doom_web.py): `doom_web.py`

### Other components

- **Player**

## Connections

- Player → Desktop client: provides input
- Desktop client → SQL adapter: calls (evidence: `doom_client.py`)
- Desktop client → Render worker: requests frames (evidence: `doom_client.py`)
- Desktop client → Audio devices: plays audio (evidence: `doom_client.py`)
- Desktop client → Diagnostics dock: shows diagnostics (evidence: `dock.py`)
- Desktop client → Client configuration: reads settings (evidence: `doom_client.py`)
- Render worker → SQL adapter: renders through (evidence: `render_worker.py`)
- SQL adapter → CedarDB state: queries state
- SQL adapter → Game runtime: runs game tics
- SQL adapter → SQL renderer: requests frames
- Game runtime → CedarDB state: updates state
- SQL renderer → CedarDB state: reads game state
- WAD importer → WAD SQL: uses SQL helpers (evidence: `wad_loader.py`)
- WAD importer → MIDI renderer: renders music (evidence: `wad_loader.py`)
- WAD importer → CedarDB state: loads game data
- Browser client → Browser PG client: uses protocol (evidence: `web/app.js`)
- Player → Browser client: provides input (evidence: `web/app.js`)
- Browser client → WebSocket relay: connects by WebSocket
- Browser client → CedarDB state: sends game input
- Match server → Game runtime: drives match (evidence: `doom_server.py`)
- Match server → CedarDB state: manages match state
- Audio devices → SQL adapter: fetches audio data (evidence: `audio.py`)
