# sw5e-foundry/sw5e-module architecture

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

- Interactive diagram: https://gitdiagram.com/sw5e-foundry/sw5e-module
- Repository: https://github.com/sw5e-foundry/sw5e-module

## Overview

SW5E is a Foundry VTT ruleset module for dnd5e. Its runtime code extends character and starship mechanics and provides starship-sheet context; separate utilities generate monster compendium actor data for two collections. The excerpts and source index establish selected module dependencies, but do not show the overall Foundry hook-registration path or all user-facing flows, so those links are omitted rather than inferred.

Main entry points: [`scripts/starship-data.mjs`](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-data.mjs) (Starship rules data), [`utils/snv-monsters/identity.mjs`](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/identity.mjs) (Identity resolution), [`utils/veshs-galactic-holodex/generate-generalized.mjs`](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/generate-generalized.mjs) (Actor generation), [`scripts/starship-routing-gate.mjs`](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-routing-gate.mjs) (Power routing gate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundry["Foundry ruleset"]
  node_module["SW5E module<br/>[module.mjs]"]
end

subgraph group_character["Character mechanics"]
  node_deployments["Character deployments"]
  node_proficiency["Proficiency rules<br/>[proficiency.mjs]"]
  node_maneuver["Maneuver item data<br/>[maneuver.mjs]"]
end

subgraph group_starship["Starship mechanics"]
  node_starshipdata["Starship rules data<br/>[starship-data.mjs]"]
  node_routing["Power routing gate"]
  node_sheetcontext["Starship sheet context"]
end

subgraph group_snv["SnV generation"]
  node_snvclass["Feature classification<br/>[classify.mjs]"]
  node_snvidentity["Identity resolution<br/>[identity.mjs]"]
  node_snvgenerate["Actor generation"]
  node_snvguard["Write safeguards<br/>[write-guard.mjs]"]
end

subgraph group_vgh["VGH generation"]
  node_vghparse["Stat-block parsing<br/>[stat-block.mjs]"]
  node_vghcast["Casting embedding<br/>[embed-casting.mjs]"]
  node_vghgenerate["Actor generation"]
  node_vghpopulate["Collection population<br/>[populate.mjs]"]
end

node_user(("Foundry user"))
node_dnd5e["dnd5e system"]

node_user -->|"uses"| node_module
node_module -->|"extends"| node_dnd5e
node_starshipdata -->|"reads"| node_deployments
node_starshipdata -->|"uses"| node_proficiency
node_routing -->|"reads"| node_deployments
node_routing -->|"reads"| node_starshipdata
node_sheetcontext -->|"reads"| node_starshipdata
node_sheetcontext -->|"uses"| node_proficiency
node_snvclass -->|"reads"| node_snvidentity
node_snvgenerate -->|"uses"| node_snvclass
node_snvgenerate -->|"resolves"| node_snvidentity
node_snvidentity -->|"checks"| node_snvguard
node_vghparse -->|"parses for"| node_vghgenerate
node_vghcast -->|"embeds into"| node_vghgenerate
node_vghpopulate -->|"generates with"| node_vghgenerate

click node_module "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/module.mjs"
click node_deployments "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/character-deployments.mjs"
click node_proficiency "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/patch/proficiency.mjs"
click node_maneuver "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/data/item/maneuver.mjs"
click node_starshipdata "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-data.mjs"
click node_routing "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-routing-gate.mjs"
click node_sheetcontext "https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/patch/starship-sheet-core-context.mjs"
click node_snvclass "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/classify.mjs"
click node_snvidentity "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/identity.mjs"
click node_snvgenerate "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/generate-generalized.mjs"
click node_snvguard "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/write-guard.mjs"
click node_vghparse "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/stat-block.mjs"
click node_vghcast "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/embed-casting.mjs"
click node_vghgenerate "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/generate-generalized.mjs"
click node_vghpopulate "https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/populate.mjs"

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_module,node_user toneBlue
class node_deployments,node_proficiency,node_maneuver toneAmber
class node_starshipdata,node_routing,node_sheetcontext toneMint
class node_snvclass,node_snvidentity,node_snvgenerate,node_snvguard toneRose
class node_vghparse,node_vghcast,node_vghgenerate,node_vghpopulate,node_dnd5e toneIndigo
```

## Components

### Foundry ruleset

- [SW5E module](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/module.mjs): `scripts/module.mjs`

### Character mechanics

- [Character deployments](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/character-deployments.mjs): `scripts/character-deployments.mjs`
- [Proficiency rules](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/patch/proficiency.mjs): `scripts/patch/proficiency.mjs`
- [Maneuver item data](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/data/item/maneuver.mjs): `scripts/data/item/maneuver.mjs`

### Starship mechanics

- [Starship rules data](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-data.mjs): `scripts/starship-data.mjs`
- [Power routing gate](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/starship-routing-gate.mjs): `scripts/starship-routing-gate.mjs`
- [Starship sheet context](https://github.com/sw5e-foundry/sw5e-module/blob/master/scripts/patch/starship-sheet-core-context.mjs): `scripts/patch/starship-sheet-core-context.mjs`

### SnV generation

- [Feature classification](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/classify.mjs): `utils/snv-monsters/classify.mjs`
- [Identity resolution](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/identity.mjs): `utils/snv-monsters/identity.mjs`
- [Actor generation](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/generate-generalized.mjs): `utils/snv-monsters/generate-generalized.mjs`
- [Write safeguards](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/snv-monsters/write-guard.mjs): `utils/snv-monsters/write-guard.mjs`

### VGH generation

- [Stat-block parsing](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/stat-block.mjs): `utils/veshs-galactic-holodex/stat-block.mjs`
- [Casting embedding](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/embed-casting.mjs): `utils/veshs-galactic-holodex/embed-casting.mjs`
- [Actor generation](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/generate-generalized.mjs): `utils/veshs-galactic-holodex/generate-generalized.mjs`
- [Collection population](https://github.com/sw5e-foundry/sw5e-module/blob/master/utils/veshs-galactic-holodex/populate.mjs): `utils/veshs-galactic-holodex/populate.mjs`

### Other components

- **Foundry user**
- **dnd5e system**

## Connections

- Foundry user → SW5E module: uses (evidence: `README.md`)
- SW5E module → dnd5e system: extends (evidence: `README.md`)
- Starship rules data → Character deployments: reads (evidence: `scripts/starship-data.mjs`)
- Starship rules data → Proficiency rules: uses (evidence: `scripts/starship-data.mjs`)
- Power routing gate → Character deployments: reads (evidence: `scripts/starship-routing-gate.mjs`)
- Power routing gate → Starship rules data: reads (evidence: `scripts/starship-routing-gate.mjs`)
- Starship sheet context → Starship rules data: reads (evidence: `scripts/patch/starship-sheet-core-context.mjs`)
- Starship sheet context → Proficiency rules: uses (evidence: `scripts/patch/starship-sheet-core-context.mjs`)
- Feature classification → Identity resolution: reads (evidence: `utils/snv-monsters/classify.mjs`)
- Actor generation → Feature classification: uses (evidence: `utils/snv-monsters/generate-generalized.mjs`)
- Actor generation → Identity resolution: resolves (evidence: `utils/snv-monsters/generate-generalized.mjs`)
- Identity resolution → Write safeguards: checks (evidence: `utils/snv-monsters/identity.mjs`)
- Stat-block parsing → Actor generation: parses for (evidence: `utils/veshs-galactic-holodex/generate-generalized.mjs`)
- Casting embedding → Actor generation: embeds into (evidence: `utils/veshs-galactic-holodex/generate-generalized.mjs`)
- Collection population → Actor generation: generates with (evidence: `utils/veshs-galactic-holodex/populate.mjs`)
