# chlik/gameboy-online architecture

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

- Interactive diagram: https://gitdiagram.com/chlik/gameboy-online
- Repository: https://github.com/chlik/gameboy-online

## Overview

GameBoy Online is a browser-based Game Boy Color emulator. The main workflow is loading a ROM into the browser interface, creating and starting the emulation core, and presenting its output through the emulator UI. The README documents canvas graphics and JavaScript audio; the tree also shows interface, save-management, and audio-support modules. The sampled excerpts establish the PHP page/framework relationship and the I/O-to-core startup and persistence behavior; unsampled audio and UI wiring is shown only as unverified where relevant.

Main entry points: [`index.php`](https://github.com/chlik/gameboy-online/blob/master/index.php) (Emulator page), [`js/GameBoyIO.js`](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js) (Emulator I/O), [`js/GameBoyCore.js`](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyCore.js) (Console emulation), [`js/other/XAudioServer.js`](https://github.com/chlik/gameboy-online/blob/master/js/other/XAudioServer.js) (Audio output)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_page["Emulator page<br/>[index.php]"]
  node_framework["Page framework<br/>[framework.php]"]
end

subgraph group_emulation["Emulation"]
  node_io["Emulator I/O<br/>[GameBoyIO.js]"]
  node_core["Console emulation<br/>[GameBoyCore.js]"]
  node_state["Save and state handling<br/>[GameBoyIO.js]"]
  node_storage[("Browser storage")]
end

subgraph group_interface["User interface"]
  node_controls["Input controls<br/>[GameBoyIO.js]"]
  node_gui["Window and menu UI<br/>[gui.js]"]
  node_windows["Window stacking<br/>[windowStack.js]"]
  node_terminal["Emulator messages<br/>[terminal.js]"]
end

subgraph group_media["Media support"]
  node_audio["Audio output<br/>[XAudioServer.js]"]
  node_resampler["Audio resampling<br/>[resampler.js]"]
  node_audio_worker["Audio stream worker"]
  node_resizer["Image resizing<br/>[resize.js]"]
end

node_user(("Player"))
node_rom["Game ROM"]

node_user -->|"opens"| node_page
node_page -->|"extends"| node_framework
node_page -->|"loads script"| node_io
node_user -->|"provides"| node_rom
node_io -->|"starts"| node_core
node_rom -.->|"loads"| node_io
node_user -.->|"operates"| node_controls
node_controls -->|"sends input"| node_core
node_io -->|"manages"| node_state
node_state -->|"reads and writes"| node_storage
node_page -.->|"renders UI for"| node_gui
node_gui -.->|"uses"| node_windows
node_page -.->|"renders terminal for"| node_terminal
node_core -.->|"produces audio for"| node_audio
node_audio -.->|"resamples with"| node_resampler
node_audio -.->|"streams through"| node_audio_worker
node_core -.->|"may resize output with"| node_resizer

click node_page "https://github.com/chlik/gameboy-online/blob/master/index.php"
click node_framework "https://github.com/chlik/gameboy-online/blob/master/res/framework.php"
click node_io "https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js"
click node_core "https://github.com/chlik/gameboy-online/blob/master/js/GameBoyCore.js"
click node_state "https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js"
click node_controls "https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js"
click node_gui "https://github.com/chlik/gameboy-online/blob/master/js/other/gui.js"
click node_windows "https://github.com/chlik/gameboy-online/blob/master/js/other/windowStack.js"
click node_terminal "https://github.com/chlik/gameboy-online/blob/master/js/other/terminal.js"
click node_audio "https://github.com/chlik/gameboy-online/blob/master/js/other/XAudioServer.js"
click node_resampler "https://github.com/chlik/gameboy-online/blob/master/js/other/resampler.js"
click node_audio_worker "https://github.com/chlik/gameboy-online/blob/master/js/other/XAudioServerMediaStreamWorker.js"
click node_resizer "https://github.com/chlik/gameboy-online/blob/master/js/other/resize.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_page,node_framework toneBlue
class node_io,node_core,node_state,node_storage toneAmber
class node_controls,node_gui,node_windows,node_terminal toneMint
class node_audio,node_resampler,node_audio_worker,node_resizer toneRose
class node_user,node_rom toneIndigo
```

## Components

### Web application

- [Emulator page](https://github.com/chlik/gameboy-online/blob/master/index.php): `index.php`
- [Page framework](https://github.com/chlik/gameboy-online/blob/master/res/framework.php): `res/framework.php`

### Emulation

- [Emulator I/O](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js): `js/GameBoyIO.js`
- [Console emulation](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyCore.js): `js/GameBoyCore.js`
- [Save and state handling](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js): `js/GameBoyIO.js`
- **Browser storage**

### User interface

- [Input controls](https://github.com/chlik/gameboy-online/blob/master/js/GameBoyIO.js): `js/GameBoyIO.js`
- [Window and menu UI](https://github.com/chlik/gameboy-online/blob/master/js/other/gui.js): `js/other/gui.js`
- [Window stacking](https://github.com/chlik/gameboy-online/blob/master/js/other/windowStack.js): `js/other/windowStack.js`
- [Emulator messages](https://github.com/chlik/gameboy-online/blob/master/js/other/terminal.js): `js/other/terminal.js`

### Media support

- [Audio output](https://github.com/chlik/gameboy-online/blob/master/js/other/XAudioServer.js): `js/other/XAudioServer.js`
- [Audio resampling](https://github.com/chlik/gameboy-online/blob/master/js/other/resampler.js): `js/other/resampler.js`
- [Audio stream worker](https://github.com/chlik/gameboy-online/blob/master/js/other/XAudioServerMediaStreamWorker.js): `js/other/XAudioServerMediaStreamWorker.js`
- [Image resizing](https://github.com/chlik/gameboy-online/blob/master/js/other/resize.js): `js/other/resize.js`

### Other components

- **Player**
- **Game ROM**

## Connections

- Player → Emulator page: opens
- Emulator page → Page framework: extends (evidence: `index.php`)
- Emulator page → Emulator I/O: loads script (evidence: `index.php`)
- Player → Game ROM: provides
- Emulator I/O → Console emulation: starts (evidence: `js/GameBoyIO.js`)
- Game ROM → Emulator I/O: loads
- Player → Input controls: operates
- Input controls → Console emulation: sends input (evidence: `js/GameBoyIO.js`)
- Emulator I/O → Save and state handling: manages (evidence: `js/GameBoyIO.js`)
- Save and state handling → Browser storage: reads and writes (evidence: `js/GameBoyIO.js`)
- Emulator page → Window and menu UI: renders UI for
- Window and menu UI → Window stacking: uses
- Emulator page → Emulator messages: renders terminal for
- Console emulation → Audio output: produces audio for
- Audio output → Audio resampling: resamples with
- Audio output → Audio stream worker: streams through
- Console emulation → Image resizing: may resize output with
