# calafex/hpw_rewrite architecture

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

- Interactive diagram: https://gitdiagram.com/calafex/hpw_rewrite
- Repository: https://github.com/calafex/hpw_rewrite

## Overview

Harry Potter Wand Rewrite is a Garry’s Mod wand-and-spell addon. The principal gameplay workflow is a player using the wand weapon to invoke a spell, with spell definitions producing in-game effects or entities. The repository also includes spell selection, wand skins, configuration and language/UI support, networking, and book-like entities. The README confirms spell and skin extensibility; because no source excerpts were provided, the graph shows only high-level relationships suggested by the product and tree, not verified internal calls.

Main entry points: [`lua/hpwrewrite/spellmanager.lua`](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/spellmanager.lua) (Spell Manager), [`lua/weapons/weapon_hpwr_stick.lua`](https://github.com/calafex/hpw_rewrite/blob/master/lua/weapons/weapon_hpwr_stick.lua) (Wand Weapon), [`lua/hpwrewrite/network.lua`](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/network.lua) (Networking), [`lua/hpwrewrite/skinmanager.lua`](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/skinmanager.lua) (Skin Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Wand Gameplay"]
  node_wand["Wand Weapon"]
  node_spellmanager["Spell Manager<br/>[spellmanager.lua]"]
  node_spelltree["Spell Tree<br/>[spelltree.lua]"]
  node_entities["Spell Entities"]
  node_effects["Visual Effects"]
end

subgraph group_content["Spell Content"]
  node_spellcontent["Spell Definitions"]
end

subgraph group_presentation["UI and Appearance"]
  node_skinmanager["Skin Manager<br/>[skinmanager.lua]"]
  node_skins["Wand Skins"]
  node_vgui["Game UI<br/>[vgui.lua]"]
  node_options["Options"]
end

subgraph group_services["Addon Services"]
  node_network["Networking<br/>[network.lua]"]
  node_netclient["Client Messages<br/>[client.lua]"]
  node_netserver["Server Messages<br/>[server.lua]"]
  node_datamanager["Data Manager<br/>[datamanager.lua]"]
  node_language["Translations"]
  node_bindings["Key Bindings<br/>[binds.lua]"]
end

node_player(("Player"))
node_playergame(("Garry’s Mod"))

node_player -->|"uses"| node_wand
node_wand -->|"casts through"| node_spellmanager
node_spellmanager -->|"dispatches spell"| node_spellcontent
node_spellmanager -->|"creates entities"| node_entities
node_spellmanager -->|"triggers effects"| node_effects
node_player -->|"selects spells"| node_spelltree
node_wand -->|"uses appearance"| node_skinmanager
node_skinmanager -->|"loads skins"| node_skins
node_playergame -->|"runs addon"| node_wand
node_network -->|"routes client"| node_netclient
node_network -->|"routes server"| node_netserver

click node_wand "https://github.com/calafex/hpw_rewrite/blob/master/lua/weapons/weapon_hpwr_stick.lua"
click node_spellmanager "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/spellmanager.lua"
click node_spelltree "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/spelltree.lua"
click node_spellcontent "https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/spells"
click node_entities "https://github.com/calafex/hpw_rewrite/tree/master/lua/entities"
click node_effects "https://github.com/calafex/hpw_rewrite/tree/master/lua/effects"
click node_skinmanager "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/skinmanager.lua"
click node_skins "https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/skins"
click node_vgui "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/vgui.lua"
click node_options "https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/options"
click node_network "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/network.lua"
click node_netclient "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/net/client.lua"
click node_netserver "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/net/server.lua"
click node_datamanager "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/datamanager.lua"
click node_language "https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/language"
click node_bindings "https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/binds.lua"

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_wand,node_spellmanager,node_spelltree,node_entities,node_effects toneBlue
class node_spellcontent toneAmber
class node_skinmanager,node_skins,node_vgui,node_options toneMint
class node_network,node_netclient,node_netserver,node_datamanager,node_language,node_bindings toneRose
class node_player,node_playergame toneIndigo
```

## Components

### Wand Gameplay

- [Wand Weapon](https://github.com/calafex/hpw_rewrite/blob/master/lua/weapons/weapon_hpwr_stick.lua): `lua/weapons/weapon_hpwr_stick.lua`
- [Spell Manager](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/spellmanager.lua): `lua/hpwrewrite/spellmanager.lua`
- [Spell Tree](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/spelltree.lua): `lua/hpwrewrite/spelltree.lua`
- [Spell Entities](https://github.com/calafex/hpw_rewrite/tree/master/lua/entities): `lua/entities`
- [Visual Effects](https://github.com/calafex/hpw_rewrite/tree/master/lua/effects): `lua/effects`

### Spell Content

- [Spell Definitions](https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/spells): `lua/hpwrewrite/spells`

### UI and Appearance

- [Skin Manager](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/skinmanager.lua): `lua/hpwrewrite/skinmanager.lua`
- [Wand Skins](https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/skins): `lua/hpwrewrite/skins`
- [Game UI](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/vgui.lua): `lua/hpwrewrite/vgui.lua`
- [Options](https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/options): `lua/hpwrewrite/options`

### Addon Services

- [Networking](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/network.lua): `lua/hpwrewrite/network.lua`
- [Client Messages](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/net/client.lua): `lua/hpwrewrite/net/client.lua`
- [Server Messages](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/net/server.lua): `lua/hpwrewrite/net/server.lua`
- [Data Manager](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/datamanager.lua): `lua/hpwrewrite/datamanager.lua`
- [Translations](https://github.com/calafex/hpw_rewrite/tree/master/lua/hpwrewrite/language): `lua/hpwrewrite/language`
- [Key Bindings](https://github.com/calafex/hpw_rewrite/blob/master/lua/hpwrewrite/binds.lua): `lua/hpwrewrite/binds.lua`

### Other components

- **Player**
- **Garry’s Mod**

## Connections

- Player → Wand Weapon: uses
- Wand Weapon → Spell Manager: casts through
- Spell Manager → Spell Definitions: dispatches spell
- Spell Manager → Spell Entities: creates entities
- Spell Manager → Visual Effects: triggers effects
- Player → Spell Tree: selects spells
- Wand Weapon → Skin Manager: uses appearance
- Skin Manager → Wand Skins: loads skins
- Garry’s Mod → Wand Weapon: runs addon
- Networking → Client Messages: routes client
- Networking → Server Messages: routes server
