# grimgriz/dragonsleep-8bit architecture

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

- Interactive diagram: https://gitdiagram.com/grimgriz/dragonsleep-8bit
- Repository: https://github.com/grimgriz/dragonsleep-8bit

## Overview

DRAGONSLEEP is a browser-based, 8-bit turn-based RPG. The player starts in Silverton, explores connected towns, roads and dungeons, talks to characters and triggers story events, then fights encounters and earns rewards while progressing the party toward the lake and the post-lake expansion. The runtime separates field exploration, scripted events, combat and rules, with JSON-authored world and game data. README documents generated art, audio, and special full-resolution scenes. Some runtime wiring is inferred only from documented responsibilities; unsampled source limits the call relationships shown.

Main entry points: [`js/main.js`](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/main.js) (Browser boot), [`js/scenes.js`](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/scenes.js) (Scene stack), [`js/events.js`](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/events.js) (Story and events), [`js/world.js`](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/world.js) (Field exploration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_boot["Browser boot<br/>[main.js]"]
  node_core["Loop and input<br/>[core.js]"]
  node_scenes["Scene stack<br/>[scenes.js]"]
  node_world["Field exploration<br/>[world.js]"]
  node_ui["Menus and dialogue<br/>[ui.js]"]
end

subgraph group_domain["RPG systems"]
  node_events["Story and events<br/>[events.js]"]
  node_battle["Turn-based combat<br/>[battle.js]"]
  node_rules["Character rules<br/>[rules.js]"]
  node_deep["Behind fountains<br/>[deep.js]"]
end

subgraph group_content["Game content"]
  node_content["Authored JSON"]
  node_maps["World maps"]
  node_bundle["Runtime data bundle<br/>[data.js]"]
end

subgraph group_media["Presentation and scenes"]
  node_cradle["Cradle scene<br/>[cradle.js]"]
  node_smoke["Dream scene<br/>[smoke.js]"]
  node_art["Pixel art<br/>[art.js]"]
  node_sprites["Sprites<br/>[sprites.js]"]
  node_bestiary["Monster art<br/>[bestiary-art.js]"]
  node_font["Game font<br/>[font.js]"]
  node_audio["Chiptune audio<br/>[audio.js]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_boot
node_boot -->|"loads data"| node_bundle
node_boot -->|"starts loop"| node_core
node_boot -->|"pushes title"| node_scenes
node_player -->|"provides input"| node_core
node_content -->|"compiled as"| node_bundle
node_maps -->|"included in"| node_bundle
node_events -->|"starts fights"| node_battle
node_events -->|"creates heroes"| node_rules
node_deep -->|"uses event systems"| node_events
node_world -->|"reads map data"| node_maps
node_world -->|"triggers events"| node_events
node_scenes -->|"presents menus"| node_ui
node_world -->|"draws tiles"| node_art
node_art -->|"supports rendering"| node_sprites
node_art -->|"supports rendering"| node_bestiary
node_scenes -->|"renders text"| node_font
node_scenes -->|"plays audio"| node_audio
node_cradle -->|"plays scene sound"| node_audio
node_smoke -->|"plays scene sound"| node_audio

click node_boot "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/main.js"
click node_core "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/core.js"
click node_scenes "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/scenes.js"
click node_world "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/world.js"
click node_events "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/events.js"
click node_battle "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/battle.js"
click node_rules "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/rules.js"
click node_ui "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/ui.js"
click node_deep "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/deep.js"
click node_cradle "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/cradle.js"
click node_smoke "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/smoke.js"
click node_art "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/art.js"
click node_sprites "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/sprites.js"
click node_bestiary "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/bestiary-art.js"
click node_font "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/font.js"
click node_audio "https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/audio.js"
click node_content "https://github.com/grimgriz/dragonsleep-8bit/tree/main/content"
click node_maps "https://github.com/grimgriz/dragonsleep-8bit/tree/main/content/maps"
click node_bundle "https://github.com/grimgriz/dragonsleep-8bit/blob/main/data/data.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_boot,node_core,node_scenes,node_world,node_ui toneBlue
class node_events,node_battle,node_rules,node_deep toneAmber
class node_content,node_maps,node_bundle toneMint
class node_cradle,node_smoke,node_art,node_sprites,node_bestiary,node_font,node_audio toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Browser boot](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/main.js): `js/main.js`
- [Loop and input](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/core.js): `js/core.js`
- [Scene stack](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/scenes.js): `js/scenes.js`
- [Field exploration](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/world.js): `js/world.js`
- [Menus and dialogue](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/ui.js): `js/ui.js`

### RPG systems

- [Story and events](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/events.js): `js/events.js`
- [Turn-based combat](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/battle.js): `js/battle.js`
- [Character rules](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/rules.js): `js/rules.js`
- [Behind fountains](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/deep.js): `js/deep.js`

### Game content

- [Authored JSON](https://github.com/grimgriz/dragonsleep-8bit/tree/main/content): `content`
- [World maps](https://github.com/grimgriz/dragonsleep-8bit/tree/main/content/maps): `content/maps`
- [Runtime data bundle](https://github.com/grimgriz/dragonsleep-8bit/blob/main/data/data.js): `data/data.js`

### Presentation and scenes

- [Cradle scene](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/cradle.js): `js/cradle.js`
- [Dream scene](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/smoke.js): `js/smoke.js`
- [Pixel art](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/art.js): `js/art.js`
- [Sprites](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/sprites.js): `js/sprites.js`
- [Monster art](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/bestiary-art.js): `js/bestiary-art.js`
- [Game font](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/font.js): `js/font.js`
- [Chiptune audio](https://github.com/grimgriz/dragonsleep-8bit/blob/main/js/audio.js): `js/audio.js`

### Other components

- **Player**

## Connections

- Player → Browser boot: starts game
- Browser boot → Runtime data bundle: loads data
- Browser boot → Loop and input: starts loop
- Browser boot → Scene stack: pushes title
- Player → Loop and input: provides input
- Authored JSON → Runtime data bundle: compiled as
- World maps → Runtime data bundle: included in
- Story and events → Turn-based combat: starts fights
- Story and events → Character rules: creates heroes
- Behind fountains → Story and events: uses event systems
- Field exploration → World maps: reads map data
- Field exploration → Story and events: triggers events
- Scene stack → Menus and dialogue: presents menus
- Field exploration → Pixel art: draws tiles
- Pixel art → Sprites: supports rendering
- Pixel art → Monster art: supports rendering
- Scene stack → Game font: renders text
- Scene stack → Chiptune audio: plays audio
- Cradle scene → Chiptune audio: plays scene sound
- Dream scene → Chiptune audio: plays scene sound
