# nhuynh2/wildfire-env architecture

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

- Interactive diagram: https://gitdiagram.com/nhuynh2/wildfire-env
- Repository: https://github.com/nhuynh2/wildfire-env

## Overview

FirecastRL is a Gymnasium wildfire-suppression environment: an RL agent moves a helitack helicopter and drops suppressant while fire dynamics evolve, producing observations, rewards, and episode status. A separate browser viewer visualizes simulation state and supports interactive controls. The graph also preserves terrain and fuel modeling, observation/reward wrappers, and visualization subsystems. Some links use README descriptions or SOURCE INDEX references; unsampled implementation details are not asserted beyond that evidence.

Main entry points: [`firecastrl_env/envs/wildfire_env.py`](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/wildfire_env.py) (Gymnasium Environment), [`firecastrl_env/envs/fire_engine/fire_engine.py`](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/fire_engine/fire_engine.py) (Fire Spread Engine), [`web/src/models/simulation.ts`](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/simulation.ts) (Viewer Simulation), [`firecastrl_env/envs/environment/array_state.py`](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/array_state.py) (Array Fire State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_environment["RL Environment"]
  node_gymenv["Gymnasium Environment<br/>[wildfire_env.py]"]
  node_wrappers["Observation and Reward Wrappers"]
  node_config["Environment Configuration<br/>[config.py]"]
end

subgraph group_fire["Fire and Terrain"]
  node_state[("Array Fire State<br/>[array_state.py]")]
  node_cell["Cell Properties<br/>[cell.py]"]
  node_firetypes["Fire and Fuel Types<br/>[enums.py]"]
  node_terrain["Terrain and Landcover Loading<br/>[helper.py]"]
  node_vectors["Spatial Vectors<br/>[vector.py]"]
  node_wind["Wind Model<br/>[wind.py]"]
  node_zones["Vegetation Zones<br/>[zone.py]"]
  node_engine["Fire Spread Engine<br/>[fire_engine.py]"]
  node_spread["Spread Rate Physics"]
end

subgraph group_viewer["3D Viewer"]
  node_viewer_server["Viewer Server<br/>[server.py]"]
end

subgraph group_webmodel["Viewer Simulation"]
  node_simulation["Viewer Simulation<br/>[simulation.ts]"]
  node_webconfig["Viewer Configuration<br/>[config.ts]"]
  node_loaders["Terrain Data Loaders<br/>[data-loaders.ts]"]
  node_webcell["Viewer Cell Model<br/>[cell.ts]"]
  node_webzone["Viewer Zone Model<br/>[zone.ts]"]
  node_webengine["Viewer Fire Engine<br/>[fire-engine.ts]"]
  node_webspread["Viewer Spread Physics"]
  node_grid["Grid Utilities<br/>[grid-utils.ts]"]
end

subgraph group_webui["Viewer Interface"]
  node_stores[("Viewer State Stores<br/>[stores.ts]")]
  node_page["Simulation Page<br/>[SimulationPage.tsx]"]
  node_view3d["3D Scene<br/>[view-3d.tsx]"]
  node_interactions["Scene Interactions"]
end

node_agent(("RL Agent"))
node_browser(("Browser Viewer"))

node_agent -->|"chooses actions"| node_gymenv
node_gymenv -->|"returns observations"| node_agent
node_gymenv -->|"reads configuration"| node_config
node_gymenv -->|"maintains state"| node_state
node_gymenv -->|"loads terrain"| node_terrain
node_gymenv -->|"advances fire"| node_engine
node_gymenv -.->|"supports wrapping"| node_wrappers
node_state -->|"uses properties"| node_cell
node_state -->|"uses states"| node_firetypes
node_terrain -->|"populates terrain"| node_state
node_engine -->|"updates fire state"| node_state
node_engine -->|"calculates spread"| node_spread
node_engine -->|"reads wind"| node_wind
node_engine -->|"uses spatial math"| node_vectors
node_gymenv -->|"publishes viewer state"| node_viewer_server
node_viewer_server -->|"streams state"| node_browser
node_browser -->|"opens simulation"| node_simulation
node_simulation -->|"loads settings"| node_webconfig
node_simulation -->|"loads terrain data"| node_loaders
node_simulation -->|"builds zones"| node_webzone
node_simulation -->|"starts fire engine"| node_webengine
node_webengine -->|"updates cells"| node_webcell
node_webengine -->|"calculates spread"| node_webspread
node_webengine -->|"uses grid operations"| node_grid
node_page -->|"renders scene"| node_view3d
node_page -->|"reads viewer state"| node_stores
node_view3d -.->|"handles interaction"| node_interactions

click node_gymenv "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/wildfire_env.py"
click node_wrappers "https://github.com/nhuynh2/wildfire-env/tree/main/firecastrl_env/wrappers"
click node_config "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/config.py"
click node_state "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/array_state.py"
click node_cell "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/cell.py"
click node_firetypes "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/enums.py"
click node_terrain "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/helper.py"
click node_vectors "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/vector.py"
click node_wind "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/wind.py"
click node_zones "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/zone.py"
click node_engine "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/fire_engine/fire_engine.py"
click node_spread "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/fire_engine/fire_spread_rate.py"
click node_viewer_server "https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/viewer/server.py"
click node_simulation "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/simulation.ts"
click node_webconfig "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/config.ts"
click node_loaders "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/utils/data-loaders.ts"
click node_webcell "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/cell.ts"
click node_webzone "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/zone.ts"
click node_webengine "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/engine/fire-engine.ts"
click node_webspread "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/engine/get-fire-spread-rate.ts"
click node_grid "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/utils/grid-utils.ts"
click node_stores "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/stores.ts"
click node_page "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/pages/SimulationPage.tsx"
click node_view3d "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/components/view-3d/view-3d.tsx"
click node_interactions "https://github.com/nhuynh2/wildfire-env/blob/main/web/src/components/view-3d/interaction-handler.ts"

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_gymenv,node_wrappers,node_config,node_browser toneBlue
class node_state,node_cell,node_firetypes,node_terrain,node_vectors,node_wind,node_zones,node_engine,node_spread toneAmber
class node_viewer_server toneMint
class node_simulation,node_webconfig,node_loaders,node_webcell,node_webzone,node_webengine,node_webspread,node_grid toneRose
class node_stores,node_page,node_view3d,node_interactions,node_agent toneIndigo
```

## Components

### RL Environment

- [Gymnasium Environment](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/wildfire_env.py): `firecastrl_env/envs/wildfire_env.py`
- [Observation and Reward Wrappers](https://github.com/nhuynh2/wildfire-env/tree/main/firecastrl_env/wrappers): `firecastrl_env/wrappers`
- [Environment Configuration](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/config.py): `firecastrl_env/envs/config.py`

### Fire and Terrain

- [Array Fire State](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/array_state.py): `firecastrl_env/envs/environment/array_state.py`
- [Cell Properties](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/cell.py): `firecastrl_env/envs/environment/cell.py`
- [Fire and Fuel Types](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/enums.py): `firecastrl_env/envs/environment/enums.py`
- [Terrain and Landcover Loading](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/helper.py): `firecastrl_env/envs/environment/helper.py`
- [Spatial Vectors](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/vector.py): `firecastrl_env/envs/environment/vector.py`
- [Wind Model](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/wind.py): `firecastrl_env/envs/environment/wind.py`
- [Vegetation Zones](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/environment/zone.py): `firecastrl_env/envs/environment/zone.py`
- [Fire Spread Engine](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/fire_engine/fire_engine.py): `firecastrl_env/envs/fire_engine/fire_engine.py`
- [Spread Rate Physics](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/envs/fire_engine/fire_spread_rate.py): `firecastrl_env/envs/fire_engine/fire_spread_rate.py`

### 3D Viewer

- [Viewer Server](https://github.com/nhuynh2/wildfire-env/blob/main/firecastrl_env/viewer/server.py): `firecastrl_env/viewer/server.py`

### Viewer Simulation

- [Viewer Simulation](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/simulation.ts): `web/src/models/simulation.ts`
- [Viewer Configuration](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/config.ts): `web/src/config.ts`
- [Terrain Data Loaders](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/utils/data-loaders.ts): `web/src/models/utils/data-loaders.ts`
- [Viewer Cell Model](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/cell.ts): `web/src/models/cell.ts`
- [Viewer Zone Model](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/zone.ts): `web/src/models/zone.ts`
- [Viewer Fire Engine](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/engine/fire-engine.ts): `web/src/models/engine/fire-engine.ts`
- [Viewer Spread Physics](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/engine/get-fire-spread-rate.ts): `web/src/models/engine/get-fire-spread-rate.ts`
- [Grid Utilities](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/utils/grid-utils.ts): `web/src/models/utils/grid-utils.ts`

### Viewer Interface

- [Viewer State Stores](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/models/stores.ts): `web/src/models/stores.ts`
- [Simulation Page](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/pages/SimulationPage.tsx): `web/src/pages/SimulationPage.tsx`
- [3D Scene](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/components/view-3d/view-3d.tsx): `web/src/components/view-3d/view-3d.tsx`
- [Scene Interactions](https://github.com/nhuynh2/wildfire-env/blob/main/web/src/components/view-3d/interaction-handler.ts): `web/src/components/view-3d/interaction-handler.ts`

### Other components

- **RL Agent**
- **Browser Viewer**

## Connections

- RL Agent → Gymnasium Environment: chooses actions
- Gymnasium Environment → RL Agent: returns observations
- Gymnasium Environment → Environment Configuration: reads configuration (evidence: `firecastrl_env/envs/wildfire_env.py`)
- Gymnasium Environment → Array Fire State: maintains state (evidence: `firecastrl_env/envs/wildfire_env.py`)
- Gymnasium Environment → Terrain and Landcover Loading: loads terrain (evidence: `firecastrl_env/envs/wildfire_env.py`)
- Gymnasium Environment → Fire Spread Engine: advances fire (evidence: `firecastrl_env/envs/wildfire_env.py`)
- Gymnasium Environment → Observation and Reward Wrappers: supports wrapping
- Array Fire State → Cell Properties: uses properties (evidence: `firecastrl_env/envs/environment/array_state.py`)
- Array Fire State → Fire and Fuel Types: uses states (evidence: `firecastrl_env/envs/environment/array_state.py`)
- Terrain and Landcover Loading → Array Fire State: populates terrain (evidence: `firecastrl_env/envs/environment/helper.py`)
- Fire Spread Engine → Array Fire State: updates fire state (evidence: `firecastrl_env/envs/fire_engine/fire_engine.py`)
- Fire Spread Engine → Spread Rate Physics: calculates spread (evidence: `firecastrl_env/envs/fire_engine/fire_engine.py`)
- Fire Spread Engine → Wind Model: reads wind (evidence: `firecastrl_env/envs/fire_engine/fire_engine.py`)
- Fire Spread Engine → Spatial Vectors: uses spatial math
- Gymnasium Environment → Viewer Server: publishes viewer state
- Viewer Server → Browser Viewer: streams state
- Browser Viewer → Viewer Simulation: opens simulation
- Viewer Simulation → Viewer Configuration: loads settings (evidence: `web/src/models/simulation.ts`)
- Viewer Simulation → Terrain Data Loaders: loads terrain data (evidence: `web/src/models/simulation.ts`)
- Viewer Simulation → Viewer Zone Model: builds zones (evidence: `web/src/models/simulation.ts`)
- Viewer Simulation → Viewer Fire Engine: starts fire engine (evidence: `web/src/models/simulation.ts`)
- Viewer Fire Engine → Viewer Cell Model: updates cells (evidence: `web/src/models/engine/fire-engine.ts`)
- Viewer Fire Engine → Viewer Spread Physics: calculates spread (evidence: `web/src/models/engine/fire-engine.ts`)
- Viewer Fire Engine → Grid Utilities: uses grid operations (evidence: `web/src/models/engine/fire-engine.ts`)
- Simulation Page → 3D Scene: renders scene (evidence: `web/src/pages/SimulationPage.tsx`)
- Simulation Page → Viewer State Stores: reads viewer state (evidence: `web/src/pages/SimulationPage.tsx`)
- 3D Scene → Scene Interactions: handles interaction
