# moo-man/wfrp4e-foundryvtt architecture

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

- Interactive diagram: https://gitdiagram.com/moo-man/wfrp4e-foundryvtt
- Repository: https://github.com/moo-man/wfrp4e-foundryvtt

## Overview

This repository is a Foundry VTT system for playing Warhammer Fantasy Roleplay, with support for both 4th and 5th Edition. A player or GM works through character sheets and dialogs to generate characters, manage actors and items, make tests, and resolve opposed results in chat. The graph also includes documented features such as advancement, inventory, automated effects, and trading. Some capabilities are documented but their implementation was not sampled; those branches are shown without speculative wiring.

Main entry points: [`src/documents/actor.js`](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/documents/actor.js) (Actor documents), [`src/hooks/entryContext.js`](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/hooks/entryContext.js) (Chat actions), [`src/model/actor/standard.js`](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/actor/standard.js) (Actor models), [`src/apps/edition-manager.js`](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/edition-manager.js) (Edition selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_system["System setup"]
  node_bootstrap["System bootstrap<br/>[wfrp4e.js]"]
  node_edition["Edition selection<br/>[edition-manager.js]"]
  node_utility["System utilities<br/>[utility-wfrp4e.js]"]
end

subgraph group_actors["Actors and items"]
  node_actor_docs["Actor documents<br/>[actor.js]"]
  node_item_docs["Item documents<br/>[item.js]"]
  node_actor_models["Actor models<br/>[standard.js]"]
  node_weapon_model["Weapon model<br/>[weapon.js]"]
  node_actor_sheets["Actor sheets<br/>[base.js]"]
  node_item_sheets["Item sheets<br/>[base.js]"]
end

subgraph group_tests["Tests and chat"]
  node_roll_dialogs["Roll dialogs<br/>[roll-dialog.js]"]
  node_roll_tests["Roll evaluation<br/>[test-wfrp4e.js]"]
  node_cast_test["Casting tests<br/>[cast-test.js]"]
  node_channel_test["Channelling tests<br/>[channel-test.js]"]
  node_opposed["Opposed resolution<br/>[opposed-handler.js]"]
  node_opposed_message["Opposed chat message<br/>[oppose-handler.js]"]
  node_chat_context["Chat actions<br/>[entryContext.js]"]
end

subgraph group_tools["Player tools"]
  node_chargen["Character generation<br/>[char-gen.js]"]
  node_stat_parser["Stat block parser<br/>[stat-parser.js]"]
  node_market["Market and payments<br/>[market-wfrp4e.js]"]
end

subgraph group_rules["Rules and trade"]
  node_advancement["Advancement rules<br/>[advancement.js]"]
  node_effects["Active effects<br/>[effect-wfrp4e.js]"]
  node_trade["Trade manager<br/>[trade-manager.js]"]
end

node_foundry(("Foundry users"))
node_trade_modules[("Trade data modules")]

node_bootstrap -->|"registers"| node_actor_docs
node_bootstrap -->|"registers"| node_actor_sheets
node_foundry -.->|"starts"| node_chargen
node_chargen -.->|"creates character"| node_actor_models
node_foundry -.->|"uses"| node_actor_sheets
node_actor_sheets -->|"opens"| node_market
node_item_sheets -.->|"edits"| node_item_docs
node_actor_docs -->|"imports"| node_item_docs
node_actor_docs -->|"uses"| node_utility
node_actor_docs -->|"uses"| node_effects
node_actor_docs -->|"selects rules"| node_edition
node_weapon_model -->|"references"| node_actor_models
node_actor_models -->|"uses"| node_advancement
node_actor_models -->|"uses"| node_utility
node_foundry -.->|"starts test"| node_roll_dialogs
node_edition -->|"selects dialog"| node_roll_dialogs
node_roll_dialogs -.->|"evaluates test"| node_roll_tests
node_cast_test -->|"uses"| node_roll_tests
node_channel_test -->|"uses"| node_roll_tests
node_chat_context -->|"opens"| node_stat_parser
node_chat_context -->|"imports"| node_cast_test
node_chat_context -->|"uses"| node_opposed
node_chat_context -->|"imports"| node_opposed_message
node_opposed_message -->|"creates handler"| node_opposed
node_opposed -->|"selects rules"| node_edition
node_market -->|"imports"| node_utility
node_trade -->|"requires data"| node_trade_modules

click node_bootstrap "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/wfrp4e.js"
click node_actor_docs "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/documents/actor.js"
click node_item_docs "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/documents/item.js"
click node_actor_models "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/actor/standard.js"
click node_weapon_model "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/item/weapon.js"
click node_actor_sheets "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/sheets/actor/base.js"
click node_item_sheets "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/sheets/item/base.js"
click node_chargen "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/chargen/char-gen.js"
click node_stat_parser "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/stat-parser.js"
click node_market "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/market-wfrp4e.js"
click node_edition "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/edition-manager.js"
click node_roll_dialogs "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/roll-dialog/roll-dialog.js"
click node_roll_tests "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/test-wfrp4e.js"
click node_cast_test "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/cast-test.js"
click node_channel_test "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/channel-test.js"
click node_opposed "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/opposed-handler.js"
click node_opposed_message "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/message/oppose-handler.js"
click node_chat_context "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/hooks/entryContext.js"
click node_advancement "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/advancement.js"
click node_effects "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/effect-wfrp4e.js"
click node_trade "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/trade/trade-manager.js"
click node_utility "https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/utility-wfrp4e.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_bootstrap,node_edition,node_utility,node_foundry toneBlue
class node_actor_docs,node_item_docs,node_actor_models,node_weapon_model,node_actor_sheets,node_item_sheets,node_trade_modules toneAmber
class node_roll_dialogs,node_roll_tests,node_cast_test,node_channel_test,node_opposed,node_opposed_message,node_chat_context toneMint
class node_chargen,node_stat_parser,node_market toneRose
class node_advancement,node_effects,node_trade toneIndigo
```

## Components

### System setup

- [System bootstrap](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/wfrp4e.js): `src/wfrp4e.js`
- [Edition selection](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/edition-manager.js): `src/apps/edition-manager.js`
- [System utilities](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/utility-wfrp4e.js): `src/system/utility-wfrp4e.js`

### Actors and items

- [Actor documents](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/documents/actor.js): `src/documents/actor.js`
- [Item documents](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/documents/item.js): `src/documents/item.js`
- [Actor models](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/actor/standard.js): `src/model/actor/standard.js`
- [Weapon model](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/item/weapon.js): `src/model/item/weapon.js`
- [Actor sheets](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/sheets/actor/base.js): `src/sheets/actor/base.js`
- [Item sheets](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/sheets/item/base.js): `src/sheets/item/base.js`

### Tests and chat

- [Roll dialogs](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/roll-dialog/roll-dialog.js): `src/apps/roll-dialog/roll-dialog.js`
- [Roll evaluation](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/test-wfrp4e.js): `src/system/rolls/test-wfrp4e.js`
- [Casting tests](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/cast-test.js): `src/system/rolls/cast-test.js`
- [Channelling tests](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/rolls/channel-test.js): `src/system/rolls/channel-test.js`
- [Opposed resolution](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/opposed-handler.js): `src/system/opposed-handler.js`
- [Opposed chat message](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/model/message/oppose-handler.js): `src/model/message/oppose-handler.js`
- [Chat actions](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/hooks/entryContext.js): `src/hooks/entryContext.js`

### Player tools

- [Character generation](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/chargen/char-gen.js): `src/apps/chargen/char-gen.js`
- [Stat block parser](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/stat-parser.js): `src/apps/stat-parser.js`
- [Market and payments](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/apps/market-wfrp4e.js): `src/apps/market-wfrp4e.js`

### Rules and trade

- [Advancement rules](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/advancement.js): `src/system/advancement.js`
- [Active effects](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/effect-wfrp4e.js): `src/system/effect-wfrp4e.js`
- [Trade manager](https://github.com/moo-man/wfrp4e-foundryvtt/blob/master/src/system/trade/trade-manager.js): `src/system/trade/trade-manager.js`

### Other components

- **Foundry users**
- **Trade data modules**

## Connections

- System bootstrap → Actor documents: registers (evidence: `src/wfrp4e.js`)
- System bootstrap → Actor sheets: registers (evidence: `src/wfrp4e.js`)
- Foundry users → Character generation: starts
- Character generation → Actor models: creates character
- Foundry users → Actor sheets: uses
- Actor sheets → Market and payments: opens (evidence: `src/sheets/actor/base.js`)
- Item sheets → Item documents: edits
- Actor documents → Item documents: imports (evidence: `src/documents/actor.js`)
- Actor documents → System utilities: uses (evidence: `src/documents/actor.js`)
- Actor documents → Active effects: uses (evidence: `src/documents/actor.js`)
- Actor documents → Edition selection: selects rules (evidence: `src/documents/actor.js`)
- Weapon model → Actor models: references (evidence: `src/model/item/weapon.js`)
- Actor models → Advancement rules: uses (evidence: `src/model/actor/standard.js`)
- Actor models → System utilities: uses (evidence: `src/model/actor/standard.js`)
- Foundry users → Roll dialogs: starts test
- Edition selection → Roll dialogs: selects dialog (evidence: `src/apps/edition-manager.js`)
- Roll dialogs → Roll evaluation: evaluates test
- Casting tests → Roll evaluation: uses (evidence: `src/system/rolls/cast-test.js`)
- Channelling tests → Roll evaluation: uses (evidence: `src/system/rolls/channel-test.js`)
- Chat actions → Stat block parser: opens (evidence: `src/hooks/entryContext.js`)
- Chat actions → Casting tests: imports (evidence: `src/hooks/entryContext.js`)
- Chat actions → Opposed resolution: uses (evidence: `src/hooks/entryContext.js`)
- Chat actions → Opposed chat message: imports (evidence: `src/hooks/entryContext.js`)
- Opposed chat message → Opposed resolution: creates handler (evidence: `src/model/message/oppose-handler.js`)
- Opposed resolution → Edition selection: selects rules (evidence: `src/system/opposed-handler.js`)
- Market and payments → System utilities: imports (evidence: `src/apps/market-wfrp4e.js`)
- Trade manager → Trade data modules: requires data (evidence: `src/system/trade/trade-manager.js`)
