# joncodeofficial/gta-vice-city-wasm architecture

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

- Interactive diagram: https://gitdiagram.com/joncodeofficial/gta-vice-city-wasm
- Repository: https://github.com/joncodeofficial/gta-vice-city-wasm

## Overview

This is a local-first browser port of GTA: Vice City. The user imports an owned game archive; a worker extracts it to OPFS, after which a service worker serves game files locally and the user can launch the WebAssembly game. The graph also preserves the documented offline capability and the engine’s runtime, graphics, audio, input, filesystem, and optional cheats layers. Some generated engine modules are only partially sampled, so their internal call relationships are omitted; module loading is shown where public/index.js explicitly establishes it.

Main entry points: [`public/index.js`](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/index.js) (Module Loader), [`public/game.js`](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/game.js) (Game Page), [`src/main.js`](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/src/main.js) (Import UI), [`public/modules/fs.js`](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/fs.js) (Virtual Filesystem)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_import["Import and Storage"]
  node_setup["Import UI<br/>[main.js]"]
  node_extract["Archive Extractor<br/>[extract-worker.js]"]
  node_opfs[("OPFS Game Files")]
end

subgraph group_play["Launch and Controls"]
  node_page["Game Page<br/>[game.js]"]
  node_gamepad["Gamepad Emulator<br/>[GamepadEmulator.js]"]
end

subgraph group_engine["WASM Engine"]
  node_dispatcher["Module Loader<br/>[index.js]"]
  node_runtime["WASM Runtime<br/>[runtime.js]"]
  node_package["Asset Package Map<br/>[en.js]"]
  node_loader["Engine Loader<br/>[loader.js]"]
  node_engineentry["Engine Entry<br/>[main.js]"]
  node_filesystem["Virtual Filesystem<br/>[fs.js]"]
  node_idbfs["Save Storage Bridge<br/>[idbfs.js]"]
  node_audio["Audio Backend<br/>[audio.js]"]
  node_graphics["Graphics Backend<br/>[graphics.js]"]
  node_events["Input Events<br/>[events.js]"]
  node_fetch["File Fetch<br/>[fetch.js]"]
  node_syscalls["System Calls<br/>[syscalls.js]"]
  node_asm["Emscripten Hooks<br/>[en.js]"]
  node_cheats["Cheats<br/>[cheats.js]"]
end

subgraph group_support["Browser Services"]
  node_serviceworker["File Service Worker<br/>[sw.js]"]
end

node_player(("Player"))

node_player -->|"selects archive"| node_setup
node_setup -->|"starts extraction"| node_extract
node_extract -->|"writes files"| node_opfs
node_setup -->|"checks readiness"| node_opfs
node_player -->|"starts game"| node_page
node_opfs -->|"serves game files"| node_serviceworker
node_page -->|"uses controls"| node_gamepad
node_page -->|"loads game modules"| node_dispatcher
node_dispatcher -->|"loads first"| node_runtime
node_dispatcher -->|"loads assets map"| node_package
node_dispatcher -->|"loads module"| node_loader
node_dispatcher -->|"loads module"| node_filesystem
node_dispatcher -->|"loads module"| node_audio
node_dispatcher -->|"loads module"| node_graphics
node_dispatcher -->|"loads module"| node_events
node_dispatcher -->|"loads module"| node_fetch
node_dispatcher -->|"loads hooks"| node_asm
node_dispatcher -->|"loads entry"| node_engineentry
node_dispatcher -.->|"loads optionally"| node_cheats
node_page -->|"runs WASM"| node_runtime
node_filesystem -.->|"uses save bridge"| node_idbfs
node_filesystem -.->|"serves system calls"| node_syscalls

click node_setup "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/src/main.js"
click node_extract "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/extract-worker.js"
click node_serviceworker "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/sw.js"
click node_page "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/game.js"
click node_gamepad "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/GamepadEmulator.js"
click node_dispatcher "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/index.js"
click node_runtime "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/runtime.js"
click node_package "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/packages/en.js"
click node_loader "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/loader.js"
click node_engineentry "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/main.js"
click node_filesystem "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/fs.js"
click node_idbfs "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/idbfs.js"
click node_audio "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/audio.js"
click node_graphics "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/graphics.js"
click node_events "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/events.js"
click node_fetch "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/fetch.js"
click node_syscalls "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/syscalls.js"
click node_asm "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/asm_consts/en.js"
click node_cheats "https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/cheats.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_setup,node_extract,node_opfs toneBlue
class node_page,node_gamepad toneAmber
class node_dispatcher,node_runtime,node_package,node_loader,node_engineentry,node_filesystem,node_idbfs,node_audio,node_graphics,node_events,node_fetch,node_syscalls,node_asm,node_cheats toneMint
class node_serviceworker toneRose
class node_player toneIndigo
```

## Components

### Import and Storage

- [Import UI](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/src/main.js): `src/main.js`
- [Archive Extractor](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/extract-worker.js): `public/extract-worker.js`
- **OPFS Game Files**

### Launch and Controls

- [Game Page](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/game.js): `public/game.js`
- [Gamepad Emulator](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/GamepadEmulator.js): `public/GamepadEmulator.js`

### WASM Engine

- [Module Loader](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/index.js): `public/index.js`
- [WASM Runtime](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/runtime.js): `public/modules/runtime.js`
- [Asset Package Map](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/packages/en.js): `public/modules/packages/en.js`
- [Engine Loader](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/loader.js): `public/modules/loader.js`
- [Engine Entry](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/main.js): `public/modules/main.js`
- [Virtual Filesystem](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/fs.js): `public/modules/fs.js`
- [Save Storage Bridge](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/idbfs.js): `public/idbfs.js`
- [Audio Backend](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/audio.js): `public/modules/audio.js`
- [Graphics Backend](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/graphics.js): `public/modules/graphics.js`
- [Input Events](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/events.js): `public/modules/events.js`
- [File Fetch](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/fetch.js): `public/modules/fetch.js`
- [System Calls](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/syscalls.js): `public/modules/syscalls.js`
- [Emscripten Hooks](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/asm_consts/en.js): `public/modules/asm_consts/en.js`
- [Cheats](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/modules/cheats.js): `public/modules/cheats.js`

### Browser Services

- [File Service Worker](https://github.com/joncodeofficial/gta-vice-city-wasm/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Player**

## Connections

- Player → Import UI: selects archive (evidence: `README.md`)
- Import UI → Archive Extractor: starts extraction (evidence: `README.md`)
- Archive Extractor → OPFS Game Files: writes files (evidence: `public/extract-worker.js`)
- Import UI → OPFS Game Files: checks readiness (evidence: `src/main.js`)
- Player → Game Page: starts game (evidence: `README.md`)
- OPFS Game Files → File Service Worker: serves game files (evidence: `README.md`)
- Game Page → Gamepad Emulator: uses controls (evidence: `public/game.js`)
- Game Page → Module Loader: loads game modules (evidence: `README.md`)
- Module Loader → WASM Runtime: loads first (evidence: `public/index.js`)
- Module Loader → Asset Package Map: loads assets map (evidence: `public/index.js`)
- Module Loader → Engine Loader: loads module (evidence: `public/index.js`)
- Module Loader → Virtual Filesystem: loads module (evidence: `public/index.js`)
- Module Loader → Audio Backend: loads module (evidence: `public/index.js`)
- Module Loader → Graphics Backend: loads module (evidence: `public/index.js`)
- Module Loader → Input Events: loads module (evidence: `public/index.js`)
- Module Loader → File Fetch: loads module (evidence: `public/index.js`)
- Module Loader → Emscripten Hooks: loads hooks (evidence: `public/index.js`)
- Module Loader → Engine Entry: loads entry (evidence: `public/index.js`)
- Module Loader → Cheats: loads optionally (evidence: `public/index.js`)
- Game Page → WASM Runtime: runs WASM (evidence: `README.md`)
- Virtual Filesystem → Save Storage Bridge: uses save bridge
- Virtual Filesystem → System Calls: serves system calls
