# ichih4yt3r/magesim-forever architecture

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

- Interactive diagram: https://gitdiagram.com/ichih4yt3r/magesim-forever
- Repository: https://github.com/ichih4yt3r/magesim-forever

## Overview

MageSim Forever is a browser-based World of Warcraft mage DPS simulator. Users configure a mage and encounter in the Vue frontend, run simulations through the WebAssembly backend, and inspect damage and timing results. The C++ runtime models the player, spells, buffs, targets, and timed events; bindings expose its simulation functionality to the frontend. The README documents the Vue/Vite and Emscripten/WebAssembly split. Frontend source was not sampled, so specific UI-to-worker and results-rendering connections are not asserted.

Main entry points: [`src/simulation.cpp`](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/simulation.cpp) (Event simulation), [`src/player.cpp`](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/player.cpp) (Mage player), [`src/bindings.h`](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/bindings.h) (JavaScript bindings), [`src/main.cpp`](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/main.cpp) (Native entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser frontend"]
  node_vue_app["Vue application<br/>[App.vue]"]
  node_ui_components["UI components"]
  node_simulation_ui["Simulation UI logic<br/>[simulation.js]"]
  node_worker["Simulation worker<br/>[sim_worker.js]"]
  node_wcl["Combat log integration<br/>[wcl.js]"]
end

subgraph group_bridge["WebAssembly interface"]
  node_wasm["WebAssembly module<br/>[magesim.js]"]
  node_bindings["JavaScript bindings<br/>[bindings.h]"]
end

subgraph group_runtime["Simulation runtime"]
  node_entry["Native entry point<br/>[main.cpp]"]
  node_simulation["Event simulation<br/>[simulation.cpp]"]
  node_state["Simulation state<br/>[state.cpp]"]
  node_results["Simulation results<br/>[common.h]"]
end

subgraph group_domain["Combat model"]
  node_config["Run configuration<br/>[config.h]"]
  node_player["Mage player<br/>[player.cpp]"]
  node_unit["Combat units<br/>[unit.cpp]"]
  node_spell["Spell definitions<br/>[spell.h]"]
  node_buff["Buff system<br/>[buff.cpp]"]
  node_target["Encounter targets<br/>[target.cpp]"]
  node_talents["Talents and glyphs<br/>[talents.h]"]
  node_companions["Summoned companions<br/>[mirror_image.cpp]"]
end

node_user(("Simulator user"))

node_user -->|"configures and runs"| node_vue_app
node_vue_app -->|"uses compiled backend"| node_wasm
node_wasm -.->|"exposes interface"| node_bindings
node_entry -->|"includes bindings"| node_bindings
node_entry -->|"uses simulation"| node_simulation
node_entry -->|"creates player"| node_player
node_entry -->|"configures run"| node_config
node_bindings -->|"references simulation"| node_simulation
node_bindings -->|"references player"| node_player
node_bindings -->|"references configuration"| node_config
node_simulation -->|"uses player"| node_player
node_simulation -->|"updates state"| node_state
node_simulation -->|"processes spells"| node_spell
node_simulation -->|"processes buffs"| node_buff
node_simulation -->|"uses targets"| node_target
node_simulation -.->|"returns results"| node_results
node_player -->|"extends unit behavior"| node_unit
node_player -->|"uses talents"| node_talents
node_player -->|"creates summons"| node_companions
node_unit -->|"uses spell definitions"| node_spell
node_unit -->|"manages buffs"| node_buff
node_state -->|"stores targets"| node_target
node_vue_app -.->|"renders components"| node_ui_components
node_simulation_ui -.->|"dispatches simulation"| node_worker
node_worker -.->|"runs backend"| node_wasm
node_wcl -.->|"imports combat data"| node_simulation_ui

click node_vue_app "https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/App.vue"
click node_ui_components "https://github.com/ichih4yt3r/magesim-forever/tree/main/assets/js/components"
click node_simulation_ui "https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/simulation.js"
click node_worker "https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/sim_worker.js"
click node_wcl "https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/wcl.js"
click node_wasm "https://github.com/ichih4yt3r/magesim-forever/blob/main/public/magesim.js"
click node_bindings "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/bindings.h"
click node_entry "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/main.cpp"
click node_simulation "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/simulation.cpp"
click node_state "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/state.cpp"
click node_config "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/config.h"
click node_player "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/player.cpp"
click node_unit "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/unit.cpp"
click node_spell "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/spell.h"
click node_buff "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/buff.cpp"
click node_target "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/target.cpp"
click node_talents "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/talents.h"
click node_companions "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/mirror_image.cpp"
click node_results "https://github.com/ichih4yt3r/magesim-forever/blob/main/src/common.h"

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_vue_app,node_ui_components,node_simulation_ui,node_worker,node_wcl,node_user toneBlue
class node_wasm,node_bindings toneAmber
class node_entry,node_simulation,node_state,node_results toneMint
class node_config,node_player,node_unit,node_spell,node_buff,node_target,node_talents,node_companions toneRose
```

## Components

### Browser frontend

- [Vue application](https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/App.vue): `assets/js/App.vue`
- [UI components](https://github.com/ichih4yt3r/magesim-forever/tree/main/assets/js/components): `assets/js/components`
- [Simulation UI logic](https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/simulation.js): `assets/js/simulation.js`
- [Simulation worker](https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/sim_worker.js): `assets/js/sim_worker.js`
- [Combat log integration](https://github.com/ichih4yt3r/magesim-forever/blob/main/assets/js/wcl.js): `assets/js/wcl.js`

### WebAssembly interface

- [WebAssembly module](https://github.com/ichih4yt3r/magesim-forever/blob/main/public/magesim.js): `public/magesim.js`
- [JavaScript bindings](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/bindings.h): `src/bindings.h`

### Simulation runtime

- [Native entry point](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/main.cpp): `src/main.cpp`
- [Event simulation](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/simulation.cpp): `src/simulation.cpp`
- [Simulation state](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/state.cpp): `src/state.cpp`
- [Simulation results](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/common.h): `src/common.h`

### Combat model

- [Run configuration](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/config.h): `src/config.h`
- [Mage player](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/player.cpp): `src/player.cpp`
- [Combat units](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/unit.cpp): `src/unit.cpp`
- [Spell definitions](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/spell.h): `src/spell.h`
- [Buff system](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/buff.cpp): `src/buff.cpp`
- [Encounter targets](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/target.cpp): `src/target.cpp`
- [Talents and glyphs](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/talents.h): `src/talents.h`
- [Summoned companions](https://github.com/ichih4yt3r/magesim-forever/blob/main/src/mirror_image.cpp): `src/mirror_image.cpp`

### Other components

- **Simulator user**

## Connections

- Simulator user → Vue application: configures and runs (evidence: `readme.md`)
- Vue application → WebAssembly module: uses compiled backend (evidence: `readme.md`)
- WebAssembly module → JavaScript bindings: exposes interface
- Native entry point → JavaScript bindings: includes bindings (evidence: `src/main.cpp`)
- Native entry point → Event simulation: uses simulation (evidence: `src/main.cpp`)
- Native entry point → Mage player: creates player (evidence: `src/main.cpp`)
- Native entry point → Run configuration: configures run (evidence: `src/main.cpp`)
- JavaScript bindings → Event simulation: references simulation (evidence: `src/bindings.h`)
- JavaScript bindings → Mage player: references player (evidence: `src/bindings.h`)
- JavaScript bindings → Run configuration: references configuration (evidence: `src/bindings.h`)
- Event simulation → Mage player: uses player (evidence: `src/simulation.cpp`)
- Event simulation → Simulation state: updates state (evidence: `src/simulation.cpp`)
- Event simulation → Spell definitions: processes spells (evidence: `src/simulation.cpp`)
- Event simulation → Buff system: processes buffs (evidence: `src/simulation.cpp`)
- Event simulation → Encounter targets: uses targets (evidence: `src/simulation.cpp`)
- Event simulation → Simulation results: returns results (evidence: `src/simulation.cpp`)
- Mage player → Combat units: extends unit behavior
- Mage player → Talents and glyphs: uses talents (evidence: `src/player.cpp`)
- Mage player → Summoned companions: creates summons (evidence: `src/player.cpp`)
- Combat units → Spell definitions: uses spell definitions (evidence: `src/unit.cpp`)
- Combat units → Buff system: manages buffs
- Simulation state → Encounter targets: stores targets
- Vue application → UI components: renders components
- Simulation UI logic → Simulation worker: dispatches simulation
- Simulation worker → WebAssembly module: runs backend
- Combat log integration → Simulation UI logic: imports combat data
