# johnimril/diablo_web architecture

> Architecture diagram of the GitHub repository johnimril/diablo_web, 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/johnimril/diablo_web
- Repository: https://github.com/johnimril/diablo_web

## Overview

Diablo Web is a React/TypeScript browser client for playing Diablo through an existing WebAssembly engine. The main workflow is choosing demo or retail game data, preparing browser save storage, starting the engine through a worker, and then handling input, rendering, and saves. The graph also preserves save management, MPQ compression, updates, error reporting, and experimental multiplayer. Some runtime and storage implementation files were not sampled, so their documented connections are cited to the README rather than inferred from module names.

Main entry points: [`src/App.tsx`](https://github.com/johnimril/diablo_web/blob/main/src/App.tsx) (Application shell), [`src/modules/engine/adapters/game.worker.ts`](https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/adapters/game.worker.ts) (Game worker), [`src/app/runtime/gameRuntime.ts`](https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/gameRuntime.ts) (Runtime lifecycle), [`src/modules/storage/adapters/saveManager.ts`](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/saveManager.ts) (Save operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Browser experience"]
  node_app["Application shell<br/>[App.tsx]"]
  node_start["Start screen<br/>[StartScreen.tsx]"]
  node_saveui["Save manager UI<br/>[SaveList.tsx]"]
  node_compressionui["MPQ compression UI<br/>[CompressMpq.tsx]"]
  node_loading["Loading display"]
end

subgraph group_runtime["Game runtime"]
  node_game["Runtime lifecycle<br/>[gameRuntime.ts]"]
  node_runtimeinput["Runtime input<br/>[runtimeInput.ts]"]
  node_runtime_state["Runtime state<br/>[runtimeState.ts]"]
  node_engine["Engine loader<br/>[engineLoader.ts]"]
  node_worker["Game worker<br/>[game.worker.ts]"]
  node_protocol["Worker protocol<br/>[protocol.ts]"]
  node_inputmapping["Input mapping<br/>[inputMapping.ts]"]
end

subgraph group_storage["Game data and saves"]
  node_storage[("IndexedDB filesystem<br/>[indexedDbFs.ts]")]
  node_ownership["Storage ownership"]
  node_savemanager["Save operations<br/>[saveManager.ts]"]
  node_savecodec["Save parsing<br/>[saveFile.ts]"]
  node_save_rules["Save rules<br/>[saveRules.ts]"]
  node_saveexplode["Save extraction<br/>[explode.ts]"]
  node_compress["MPQ compression<br/>[compress.ts]"]
  node_compressworker["Compression worker<br/>[mpqCmp.worker.ts]"]
end

subgraph group_platform["Browser services"]
  node_updates["Update coordination"]
  node_pwaupdates["PWA updates<br/>[pwaUpdates.ts]"]
  node_errorhandling["Error handling"]
  node_errorreport["Error reports<br/>[errorReport.ts]"]
end

subgraph group_network["Experimental multiplayer"]
  node_websocket["WebSocket client<br/>[webSocketClient.ts]"]
  node_webrtc["WebRTC client<br/>[webrtcClient.ts]"]
  node_packetcodec["Packet codec<br/>[packetCodec.ts]"]
end

node_player(("Player"))

node_player -->|"chooses game"| node_start
node_start -->|"starts session"| node_app
node_player -->|"drops game file"| node_app
node_app -->|"starts runtime"| node_game
node_app -->|"prepares storage"| node_ownership
node_game -.->|"prepares saves"| node_storage
node_game -.->|"loads engine"| node_engine
node_engine -->|"starts worker"| node_worker
node_engine -->|"uses messages"| node_protocol
node_worker -->|"validates messages"| node_protocol
node_worker -.->|"writes game files"| node_storage
node_game -.->|"routes input"| node_runtimeinput
node_runtimeinput -.->|"maps commands"| node_inputmapping
node_app -->|"shows progress"| node_loading
node_app -->|"manages saves"| node_saveui
node_saveui -.->|"uses save operations"| node_savemanager
node_savemanager -->|"reads and writes"| node_storage
node_savemanager -->|"parses player data"| node_savecodec
node_savecodec -->|"extracts save data"| node_saveexplode
node_savemanager -->|"applies save rules"| node_save_rules
node_player -->|"requests compression"| node_compressionui
node_compressionui -.->|"compresses archive"| node_compress
node_compress -.->|"uses worker"| node_compressworker
node_app -->|"tracks updates"| node_pwaupdates
node_pwaupdates -->|"coordinates updates"| node_updates
node_app -->|"handles errors"| node_errorhandling
node_errorhandling -->|"creates report"| node_errorreport
node_worker -->|"opens socket"| node_websocket
node_worker -.->|"bridges multiplayer"| node_webrtc
node_webrtc -->|"encodes packets"| node_packetcodec

click node_app "https://github.com/johnimril/diablo_web/blob/main/src/App.tsx"
click node_start "https://github.com/johnimril/diablo_web/blob/main/src/components/StartScreen/StartScreen.tsx"
click node_saveui "https://github.com/johnimril/diablo_web/blob/main/src/components/SaveList/SaveList.tsx"
click node_compressionui "https://github.com/johnimril/diablo_web/blob/main/src/app/ui/CompressMpq.tsx"
click node_loading "https://github.com/johnimril/diablo_web/blob/main/src/components/LoadingComponent/LoadingComponent.tsx"
click node_game "https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/gameRuntime.ts"
click node_runtimeinput "https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/runtimeInput.ts"
click node_runtime_state "https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/runtimeState.ts"
click node_engine "https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/adapters/engineLoader.ts"
click node_worker "https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/adapters/game.worker.ts"
click node_protocol "https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/core/protocol.ts"
click node_inputmapping "https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/core/inputMapping.ts"
click node_storage "https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/indexedDbFs.ts"
click node_ownership "https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/storageOwnership.ts"
click node_savemanager "https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/saveManager.ts"
click node_savecodec "https://github.com/johnimril/diablo_web/blob/main/src/shared/parsers/saveFile.ts"
click node_save_rules "https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/core/saveRules.ts"
click node_saveexplode "https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/core/explode.ts"
click node_compress "https://github.com/johnimril/diablo_web/blob/main/src/modules/mpqcmp/adapters/compress.ts"
click node_compressworker "https://github.com/johnimril/diablo_web/blob/main/src/modules/mpqcmp/adapters/mpqCmp.worker.ts"
click node_updates "https://github.com/johnimril/diablo_web/blob/main/src/app/updates/updateCoordinator.ts"
click node_pwaupdates "https://github.com/johnimril/diablo_web/blob/main/src/app/updates/pwaUpdates.ts"
click node_errorhandling "https://github.com/johnimril/diablo_web/blob/main/src/app/uiHooks/useErrorHandling.tsx"
click node_errorreport "https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/errorReport.ts"
click node_websocket "https://github.com/johnimril/diablo_web/blob/main/src/modules/network/adapters/webSocketClient.ts"
click node_webrtc "https://github.com/johnimril/diablo_web/blob/main/src/modules/network/adapters/webrtcClient.ts"
click node_packetcodec "https://github.com/johnimril/diablo_web/blob/main/src/modules/network/core/packetCodec.ts"

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_app,node_start,node_saveui,node_compressionui,node_loading toneBlue
class node_game,node_runtimeinput,node_runtime_state,node_engine,node_worker,node_protocol,node_inputmapping toneAmber
class node_storage,node_ownership,node_savemanager,node_savecodec,node_save_rules,node_saveexplode,node_compress,node_compressworker toneMint
class node_updates,node_pwaupdates,node_errorhandling,node_errorreport toneRose
class node_websocket,node_webrtc,node_packetcodec,node_player toneIndigo
```

## Components

### Browser experience

- [Application shell](https://github.com/johnimril/diablo_web/blob/main/src/App.tsx): `src/App.tsx`
- [Start screen](https://github.com/johnimril/diablo_web/blob/main/src/components/StartScreen/StartScreen.tsx): `src/components/StartScreen/StartScreen.tsx`
- [Save manager UI](https://github.com/johnimril/diablo_web/blob/main/src/components/SaveList/SaveList.tsx): `src/components/SaveList/SaveList.tsx`
- [MPQ compression UI](https://github.com/johnimril/diablo_web/blob/main/src/app/ui/CompressMpq.tsx): `src/app/ui/CompressMpq.tsx`
- [Loading display](https://github.com/johnimril/diablo_web/blob/main/src/components/LoadingComponent/LoadingComponent.tsx): `src/components/LoadingComponent/LoadingComponent.tsx`

### Game runtime

- [Runtime lifecycle](https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/gameRuntime.ts): `src/app/runtime/gameRuntime.ts`
- [Runtime input](https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/runtimeInput.ts): `src/app/runtime/runtimeInput.ts`
- [Runtime state](https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/runtimeState.ts): `src/app/runtime/runtimeState.ts`
- [Engine loader](https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/adapters/engineLoader.ts): `src/modules/engine/adapters/engineLoader.ts`
- [Game worker](https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/adapters/game.worker.ts): `src/modules/engine/adapters/game.worker.ts`
- [Worker protocol](https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/core/protocol.ts): `src/modules/engine/core/protocol.ts`
- [Input mapping](https://github.com/johnimril/diablo_web/blob/main/src/modules/engine/core/inputMapping.ts): `src/modules/engine/core/inputMapping.ts`

### Game data and saves

- [IndexedDB filesystem](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/indexedDbFs.ts): `src/modules/storage/adapters/indexedDbFs.ts`
- [Storage ownership](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/storageOwnership.ts): `src/modules/storage/adapters/storageOwnership.ts`
- [Save operations](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/adapters/saveManager.ts): `src/modules/storage/adapters/saveManager.ts`
- [Save parsing](https://github.com/johnimril/diablo_web/blob/main/src/shared/parsers/saveFile.ts): `src/shared/parsers/saveFile.ts`
- [Save rules](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/core/saveRules.ts): `src/modules/storage/core/saveRules.ts`
- [Save extraction](https://github.com/johnimril/diablo_web/blob/main/src/modules/storage/core/explode.ts): `src/modules/storage/core/explode.ts`
- [MPQ compression](https://github.com/johnimril/diablo_web/blob/main/src/modules/mpqcmp/adapters/compress.ts): `src/modules/mpqcmp/adapters/compress.ts`
- [Compression worker](https://github.com/johnimril/diablo_web/blob/main/src/modules/mpqcmp/adapters/mpqCmp.worker.ts): `src/modules/mpqcmp/adapters/mpqCmp.worker.ts`

### Browser services

- [Update coordination](https://github.com/johnimril/diablo_web/blob/main/src/app/updates/updateCoordinator.ts): `src/app/updates/updateCoordinator.ts`
- [PWA updates](https://github.com/johnimril/diablo_web/blob/main/src/app/updates/pwaUpdates.ts): `src/app/updates/pwaUpdates.ts`
- [Error handling](https://github.com/johnimril/diablo_web/blob/main/src/app/uiHooks/useErrorHandling.tsx): `src/app/uiHooks/useErrorHandling.tsx`
- [Error reports](https://github.com/johnimril/diablo_web/blob/main/src/app/runtime/errorReport.ts): `src/app/runtime/errorReport.ts`

### Experimental multiplayer

- [WebSocket client](https://github.com/johnimril/diablo_web/blob/main/src/modules/network/adapters/webSocketClient.ts): `src/modules/network/adapters/webSocketClient.ts`
- [WebRTC client](https://github.com/johnimril/diablo_web/blob/main/src/modules/network/adapters/webrtcClient.ts): `src/modules/network/adapters/webrtcClient.ts`
- [Packet codec](https://github.com/johnimril/diablo_web/blob/main/src/modules/network/core/packetCodec.ts): `src/modules/network/core/packetCodec.ts`

### Other components

- **Player**

## Connections

- Player → Start screen: chooses game (evidence: `README.md`)
- Start screen → Application shell: starts session (evidence: `src/components/StartScreen/StartScreen.tsx`)
- Player → Application shell: drops game file (evidence: `README.md`)
- Application shell → Runtime lifecycle: starts runtime (evidence: `src/App.tsx`)
- Application shell → Storage ownership: prepares storage
- Runtime lifecycle → IndexedDB filesystem: prepares saves
- Runtime lifecycle → Engine loader: loads engine
- Engine loader → Game worker: starts worker (evidence: `src/modules/engine/adapters/engineLoader.ts`)
- Engine loader → Worker protocol: uses messages (evidence: `src/modules/engine/adapters/engineLoader.ts`)
- Game worker → Worker protocol: validates messages (evidence: `src/modules/engine/adapters/game.worker.ts`)
- Game worker → IndexedDB filesystem: writes game files
- Runtime lifecycle → Runtime input: routes input
- Runtime input → Input mapping: maps commands
- Application shell → Loading display: shows progress (evidence: `src/App.tsx`)
- Application shell → Save manager UI: manages saves (evidence: `src/App.tsx`)
- Save manager UI → Save operations: uses save operations
- Save operations → IndexedDB filesystem: reads and writes (evidence: `src/modules/storage/adapters/saveManager.ts`)
- Save operations → Save parsing: parses player data (evidence: `src/modules/storage/adapters/saveManager.ts`)
- Save parsing → Save extraction: extracts save data (evidence: `src/shared/parsers/saveFile.ts`)
- Save operations → Save rules: applies save rules (evidence: `src/modules/storage/adapters/saveManager.ts`)
- Player → MPQ compression UI: requests compression (evidence: `README.md`)
- MPQ compression UI → MPQ compression: compresses archive
- MPQ compression → Compression worker: uses worker
- Application shell → PWA updates: tracks updates (evidence: `src/App.tsx`)
- PWA updates → Update coordination: coordinates updates (evidence: `src/app/updates/pwaUpdates.ts`)
- Application shell → Error handling: handles errors (evidence: `src/App.tsx`)
- Error handling → Error reports: creates report (evidence: `src/app/uiHooks/useErrorHandling.tsx`)
- Game worker → WebSocket client: opens socket (evidence: `src/modules/engine/adapters/game.worker.ts`)
- Game worker → WebRTC client: bridges multiplayer
- WebRTC client → Packet codec: encodes packets (evidence: `src/modules/network/adapters/webrtcClient.ts`)
