# caiiiycuk/js-dos architecture

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

- Interactive diagram: https://gitdiagram.com/caiiiycuk/js-dos
- Repository: https://github.com/caiiiycuk/js-dos

## Overview

js-dos is a browser-facing DOS/Windows emulator player. Its main workflow initializes a player, loads a program bundle or configuration, presents a pre-run interface, and runs the emulator with rendering, audio, and input controls. The repository also documents persistence, multiplayer/IPX networking, turbo controls, and editor/settings capabilities. Some subsystem links below are based on README statements or SOURCE INDEX references; unsampled implementations are represented cautiously.

Main entry points: [`src/window/dos/dos-runtime.tsx`](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/dos-runtime.tsx) (Emulator runtime), [`src/main.tsx`](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/main.tsx) (Player entry), [`src/store.ts`](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store.ts) (Application state), [`src/player-api-load.ts`](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/player-api-load.ts) (Bundle loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_player["Player workflow"]
  node_entry["Player entry<br/>[main.tsx]"]
  node_loader["Bundle loader<br/>[player-api-load.ts]"]
  node_prerun["Pre-run screen<br/>[prerun-window.tsx]"]
  node_api["Player API<br/>[player-api.ts]"]
end

subgraph group_runtime["Emulation runtime"]
  node_emulator["Emulator runtime<br/>[dos-runtime.tsx]"]
  node_renderer["Graphics renderer<br/>[webgl.ts]"]
  node_audio["Audio output<br/>[audio-node.ts]"]
  node_control_layer["Touch controls<br/>[layers-control.ts]"]
  node_layer_dom["Control layer DOM<br/>[layers.ts]"]
end

subgraph group_state["State and integrations"]
  node_store["Application state<br/>[store.ts]"]
  node_dos_state["DOS state<br/>[dos.ts]"]
  node_ui_state["UI state<br/>[ui.ts]"]
  node_storage_state["Storage progress<br/>[storage.ts]"]
  node_opfs[("OPFS persistence<br/>[opfs.ts]")]
  node_bundle_storage["Bundle storage<br/>[bundle-storage.ts]"]
  node_local_storage[("Local preferences<br/>[lstorage.ts]")]
  node_network["WebRTC networking<br/>[webrtcnet.ts]"]
end

subgraph group_interface["Interface and controls"]
  node_ui["Player interface<br/>[ui.tsx]"]
  node_sidebar["Sidebar actions<br/>[sidebar.tsx]"]
  node_editor["Bundle editor"]
  node_turbo["Turbo controls<br/>[trubo-frame.tsx]"]
end

node_user(("Player user"))
node_emulators["Emulators package"]
node_browser["Browser APIs"]

node_user -->|"starts player"| node_entry
node_entry -->|"creates state"| node_store
node_entry -->|"loads bundle"| node_loader
node_entry -->|"renders interface"| node_ui
node_entry -->|"updates usage"| node_opfs
node_loader -->|"loads bytes"| node_bundle_storage
node_prerun -->|"loads bundle"| node_loader
node_prerun -->|"saves changes"| node_api
node_ui -->|"shows screen"| node_prerun
node_ui -->|"renders sidebar"| node_sidebar
node_loader -->|"updates state"| node_dos_state
node_emulator -->|"uses emulator"| node_emulators
node_emulator -->|"renders frames"| node_renderer
node_emulator -->|"outputs audio"| node_audio
node_emulator -->|"mounts controls"| node_control_layer
node_control_layer -->|"builds overlays"| node_layer_dom
node_store -->|"combines state"| node_dos_state
node_store -->|"combines state"| node_ui_state
node_store -->|"combines state"| node_storage_state
node_dos_state -->|"persists settings"| node_local_storage
node_ui_state -->|"persists preferences"| node_local_storage
node_bundle_storage -->|"caches bundles"| node_opfs
node_bundle_storage -->|"reports progress"| node_storage_state
node_sidebar -->|"uses persistence"| node_opfs
node_store -->|"integrates networking"| node_network
node_user -.->|"edits bundle"| node_editor
node_user -.->|"adjusts speed"| node_turbo
node_emulator -.->|"runs in browser"| node_browser

click node_entry "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/main.tsx"
click node_loader "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/player-api-load.ts"
click node_prerun "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/prerun-window.tsx"
click node_emulator "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/dos-runtime.tsx"
click node_renderer "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/render/webgl.ts"
click node_audio "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/sound/audio-node.ts"
click node_control_layer "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/layers/controls/layers-control.ts"
click node_layer_dom "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/layers/dom/layers.ts"
click node_store "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store.ts"
click node_dos_state "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/dos.ts"
click node_ui_state "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/ui.ts"
click node_storage_state "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/storage.ts"
click node_opfs "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/opfs.ts"
click node_bundle_storage "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/bundle-storage.ts"
click node_local_storage "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/lstorage.ts"
click node_network "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/webrtcnet/webrtcnet.ts"
click node_api "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/player-api.ts"
click node_ui "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/ui.tsx"
click node_sidebar "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/sidebar/sidebar.tsx"
click node_editor "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/frame/editor/editor-fs-frame.tsx"
click node_turbo "https://github.com/caiiiycuk/js-dos/blob/8.xx/src/frame/trubo-frame.tsx"

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_entry,node_loader,node_prerun,node_api,node_user,node_browser toneBlue
class node_emulator,node_renderer,node_audio,node_control_layer,node_layer_dom toneAmber
class node_store,node_dos_state,node_ui_state,node_storage_state,node_opfs,node_bundle_storage,node_local_storage,node_network toneMint
class node_ui,node_sidebar,node_editor,node_turbo toneRose
class node_emulators toneIndigo
```

## Components

### Player workflow

- [Player entry](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/main.tsx): `src/main.tsx`
- [Bundle loader](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/player-api-load.ts): `src/player-api-load.ts`
- [Pre-run screen](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/prerun-window.tsx): `src/window/prerun-window.tsx`
- [Player API](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/player-api.ts): `src/player-api.ts`

### Emulation runtime

- [Emulator runtime](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/dos-runtime.tsx): `src/window/dos/dos-runtime.tsx`
- [Graphics renderer](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/render/webgl.ts): `src/window/dos/render/webgl.ts`
- [Audio output](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/window/dos/sound/audio-node.ts): `src/window/dos/sound/audio-node.ts`
- [Touch controls](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/layers/controls/layers-control.ts): `src/layers/controls/layers-control.ts`
- [Control layer DOM](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/layers/dom/layers.ts): `src/layers/dom/layers.ts`

### State and integrations

- [Application state](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store.ts): `src/store.ts`
- [DOS state](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/dos.ts): `src/store/dos.ts`
- [UI state](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/ui.ts): `src/store/ui.ts`
- [Storage progress](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/store/storage.ts): `src/store/storage.ts`
- [OPFS persistence](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/opfs.ts): `src/host/opfs.ts`
- [Bundle storage](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/bundle-storage.ts): `src/host/bundle-storage.ts`
- [Local preferences](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/host/lstorage.ts): `src/host/lstorage.ts`
- [WebRTC networking](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/webrtcnet/webrtcnet.ts): `src/webrtcnet/webrtcnet.ts`

### Interface and controls

- [Player interface](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/ui.tsx): `src/ui.tsx`
- [Sidebar actions](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/sidebar/sidebar.tsx): `src/sidebar/sidebar.tsx`
- [Bundle editor](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/frame/editor/editor-fs-frame.tsx): `src/frame/editor/editor-fs-frame.tsx`
- [Turbo controls](https://github.com/caiiiycuk/js-dos/blob/8.xx/src/frame/trubo-frame.tsx): `src/frame/trubo-frame.tsx`

### Other components

- **Player user**
- **Emulators package**
- **Browser APIs**

## Connections

- Player user → Player entry: starts player
- Player entry → Application state: creates state (evidence: `src/main.tsx`)
- Player entry → Bundle loader: loads bundle (evidence: `src/main.tsx`)
- Player entry → Player interface: renders interface (evidence: `src/main.tsx`)
- Player entry → OPFS persistence: updates usage (evidence: `src/main.tsx`)
- Bundle loader → Bundle storage: loads bytes (evidence: `src/player-api-load.ts`)
- Pre-run screen → Bundle loader: loads bundle (evidence: `src/window/prerun-window.tsx`)
- Pre-run screen → Player API: saves changes (evidence: `src/window/prerun-window.tsx`)
- Player interface → Pre-run screen: shows screen (evidence: `src/ui.tsx`)
- Player interface → Sidebar actions: renders sidebar (evidence: `src/ui.tsx`)
- Bundle loader → DOS state: updates state (evidence: `src/player-api-load.ts`)
- Emulator runtime → Emulators package: uses emulator (evidence: `src/window/dos/dos-runtime.tsx`)
- Emulator runtime → Graphics renderer: renders frames (evidence: `src/window/dos/dos-runtime.tsx`)
- Emulator runtime → Audio output: outputs audio (evidence: `src/window/dos/dos-runtime.tsx`)
- Emulator runtime → Touch controls: mounts controls (evidence: `src/window/dos/dos-runtime.tsx`)
- Touch controls → Control layer DOM: builds overlays (evidence: `src/layers/controls/layers-control.ts`)
- Application state → DOS state: combines state (evidence: `src/store.ts`)
- Application state → UI state: combines state (evidence: `src/store.ts`)
- Application state → Storage progress: combines state (evidence: `src/store.ts`)
- DOS state → Local preferences: persists settings (evidence: `src/store/dos.ts`)
- UI state → Local preferences: persists preferences (evidence: `src/store/ui.ts`)
- Bundle storage → OPFS persistence: caches bundles (evidence: `src/host/bundle-storage.ts`)
- Bundle storage → Storage progress: reports progress (evidence: `src/host/bundle-storage.ts`)
- Sidebar actions → OPFS persistence: uses persistence
- Application state → WebRTC networking: integrates networking (evidence: `src/store.ts`)
- Player user → Bundle editor: edits bundle
- Player user → Turbo controls: adjusts speed
- Emulator runtime → Browser APIs: runs in browser
