# missingdll/foundry-calc architecture

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

- Interactive diagram: https://gitdiagram.com/missingdll/foundry-calc
- Repository: https://github.com/missingdll/foundry-calc

## Overview

Foundry Calculator is a browser production-planning SPA. Users choose recipes and production goals, configure machines and bonuses, then receive machine/material requirements and interactive flow diagrams; settings persist in the browser, and plans can be shared or transferred. The graph also preserves the documented power and savegame UI areas, versioned game data, and the repository’s extractor/save-reader utilities. README statements support the main calculation workflow; sampled source is incomplete, so unsampled subsystem links are omitted.

Main entry points: [`app/state.js`](https://github.com/missingdll/foundry-calc/blob/main/app/state.js) (Plan state), [`app/calculation.js`](https://github.com/missingdll/foundry-calc/blob/main/app/calculation.js) (Production calculator), [`extract_game_data.py`](https://github.com/missingdll/foundry-calc/blob/main/extract_game_data.py) (Game data extractor), [`app/ui-recipes.js`](https://github.com/missingdll/foundry-calc/blob/main/app/ui-recipes.js) (Recipe browser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Production planning"]
  node_recipe_ui["Recipe browser<br/>[ui-recipes.js]"]
  node_calculation["Production calculator<br/>[calculation.js]"]
  node_results["Result tables<br/>[calculation.js]"]
  node_visualization["Flow visualizations<br/>[visualization.js]"]
end

subgraph group_interface["Interface and state"]
  node_plan_state[("Plan state<br/>[state.js]")]
  node_settings_ui["Settings controls<br/>[ui-settings.js]"]
  node_navigation["Navigation and sharing<br/>[ui-nav.js]"]
  node_theme["Theme system<br/>[theme.js]"]
  node_power_ui["Power interface<br/>[ui-power.js]"]
  node_savegame_ui["Savegame interface<br/>[ui-savegame.js]"]
end

subgraph group_data["Game data"]
  node_version_registry["Version registry"]
  node_game_data["Versioned game data<br/>[game-data.js]"]
  node_recipes["Versioned recipes<br/>[recipes.js]"]
  node_icons["Icon maps<br/>[icons.js]"]
end

subgraph group_tools["Data utilities"]
  node_extractor["Game data extractor"]
  node_save_reader["Savegame reader<br/>[read_savegame.py]"]
end

node_user(("Planner user"))

node_user -->|"selects recipes"| node_recipe_ui
node_user -->|"sets goals"| node_settings_ui
node_recipe_ui -->|"updates selection"| node_plan_state
node_settings_ui -->|"updates settings"| node_plan_state
node_plan_state -->|"triggers recalculation"| node_calculation
node_calculation -->|"renders requirements"| node_results
node_calculation -->|"builds flow graph"| node_visualization
node_user -->|"exports or imports plans"| node_navigation
node_plan_state -->|"persists plan"| node_navigation
node_user -->|"chooses theme"| node_theme
node_theme -->|"updates Sankey colors"| node_visualization
node_extractor -->|"generates data"| node_game_data
node_extractor -->|"generates recipes"| node_recipes
node_save_reader -->|"uses template data"| node_extractor

click node_recipe_ui "https://github.com/missingdll/foundry-calc/blob/main/app/ui-recipes.js"
click node_plan_state "https://github.com/missingdll/foundry-calc/blob/main/app/state.js"
click node_settings_ui "https://github.com/missingdll/foundry-calc/blob/main/app/ui-settings.js"
click node_calculation "https://github.com/missingdll/foundry-calc/blob/main/app/calculation.js"
click node_results "https://github.com/missingdll/foundry-calc/blob/main/app/calculation.js"
click node_visualization "https://github.com/missingdll/foundry-calc/blob/main/app/visualization.js"
click node_navigation "https://github.com/missingdll/foundry-calc/blob/main/app/ui-nav.js"
click node_theme "https://github.com/missingdll/foundry-calc/blob/main/app/theme.js"
click node_power_ui "https://github.com/missingdll/foundry-calc/blob/main/app/ui-power.js"
click node_savegame_ui "https://github.com/missingdll/foundry-calc/blob/main/app/ui-savegame.js"
click node_version_registry "https://github.com/missingdll/foundry-calc/blob/main/data/version-registry.js"
click node_game_data "https://github.com/missingdll/foundry-calc/blob/main/data/versions/v0.6.0.26518/game-data.js"
click node_recipes "https://github.com/missingdll/foundry-calc/blob/main/data/versions/v0.6.0.26518/recipes.js"
click node_icons "https://github.com/missingdll/foundry-calc/blob/main/data/icons.js"
click node_extractor "https://github.com/missingdll/foundry-calc/blob/main/extract_game_data.py"
click node_save_reader "https://github.com/missingdll/foundry-calc/blob/main/read_savegame.py"

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_recipe_ui,node_calculation,node_results,node_visualization,node_user toneBlue
class node_plan_state,node_settings_ui,node_navigation,node_theme,node_power_ui,node_savegame_ui toneAmber
class node_version_registry,node_game_data,node_recipes,node_icons toneMint
class node_extractor,node_save_reader toneRose
```

## Components

### Production planning

- [Recipe browser](https://github.com/missingdll/foundry-calc/blob/main/app/ui-recipes.js): `app/ui-recipes.js`
- [Production calculator](https://github.com/missingdll/foundry-calc/blob/main/app/calculation.js): `app/calculation.js`
- [Result tables](https://github.com/missingdll/foundry-calc/blob/main/app/calculation.js): `app/calculation.js`
- [Flow visualizations](https://github.com/missingdll/foundry-calc/blob/main/app/visualization.js): `app/visualization.js`

### Interface and state

- [Plan state](https://github.com/missingdll/foundry-calc/blob/main/app/state.js): `app/state.js`
- [Settings controls](https://github.com/missingdll/foundry-calc/blob/main/app/ui-settings.js): `app/ui-settings.js`
- [Navigation and sharing](https://github.com/missingdll/foundry-calc/blob/main/app/ui-nav.js): `app/ui-nav.js`
- [Theme system](https://github.com/missingdll/foundry-calc/blob/main/app/theme.js): `app/theme.js`
- [Power interface](https://github.com/missingdll/foundry-calc/blob/main/app/ui-power.js): `app/ui-power.js`
- [Savegame interface](https://github.com/missingdll/foundry-calc/blob/main/app/ui-savegame.js): `app/ui-savegame.js`

### Game data

- [Version registry](https://github.com/missingdll/foundry-calc/blob/main/data/version-registry.js): `data/version-registry.js`
- [Versioned game data](https://github.com/missingdll/foundry-calc/blob/main/data/versions/v0.6.0.26518/game-data.js): `data/versions/v0.6.0.26518/game-data.js`
- [Versioned recipes](https://github.com/missingdll/foundry-calc/blob/main/data/versions/v0.6.0.26518/recipes.js): `data/versions/v0.6.0.26518/recipes.js`
- [Icon maps](https://github.com/missingdll/foundry-calc/blob/main/data/icons.js): `data/icons.js`

### Data utilities

- [Game data extractor](https://github.com/missingdll/foundry-calc/blob/main/extract_game_data.py): `extract_game_data.py`
- [Savegame reader](https://github.com/missingdll/foundry-calc/blob/main/read_savegame.py): `read_savegame.py`

### Other components

- **Planner user**

## Connections

- Planner user → Recipe browser: selects recipes (evidence: `README.md`)
- Planner user → Settings controls: sets goals (evidence: `README.md`)
- Recipe browser → Plan state: updates selection (evidence: `README.md`)
- Settings controls → Plan state: updates settings (evidence: `README.md`)
- Plan state → Production calculator: triggers recalculation (evidence: `README.md`)
- Production calculator → Result tables: renders requirements (evidence: `README.md`)
- Production calculator → Flow visualizations: builds flow graph (evidence: `README.md`)
- Planner user → Navigation and sharing: exports or imports plans (evidence: `README.md`)
- Plan state → Navigation and sharing: persists plan (evidence: `README.md`)
- Planner user → Theme system: chooses theme (evidence: `README.md`)
- Theme system → Flow visualizations: updates Sankey colors (evidence: `README.md`)
- Game data extractor → Versioned game data: generates data (evidence: `extract_game_data.py`)
- Game data extractor → Versioned recipes: generates recipes (evidence: `extract_game_data.py`)
- Savegame reader → Game data extractor: uses template data (evidence: `read_savegame.py`)
