# firelab/wfips architecture

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

- Interactive diagram: https://gitdiagram.com/firelab/wfips
- Repository: https://github.com/firelab/wfips

## Overview

WFIPS is a C++ wildfire planning and simulation codebase with three major layers: a geospatial/visual analysis front end, a simulation and resource-modeling core, and embedded fire-behavior / weather-model libraries.

1. Overall shape  
The repository is not a single app; it is a multi-target workspace built with CMake. The main functional areas are `irs/` (core WFIPS logic and GUI), `fig/` (fire investment geometry/raster support), `common/` (shared utilities), `flammap/` (integrated FlamMap fire behavior code), `nfdrs/` (fire danger rating calculations), and `sqlite/` (vendored SQLite).

2. Core WFIPS simulation engine  
`irs/src` is the heart of the system. It contains the WFIPS domain model, scenario runner, result objects, and the main simulation pipeline. Key roles here are `RunScenario`, `Results`, `wfips_result`, `irs_result`, `irs_export_result`, `wfips_data`, and `wfips.cpp`. This layer is responsible for turning planning inputs into computed outcomes.

3. Resource, dispatch, and containment modeling  
A large part of `irs/src` models wildfire response resources and suppression behavior. Classes such as `Airtanker`, `Helicopter`, `Smokejumper`, `Crew`, `Engine`, `WaterTender`, `Helitack`, `LocalDispatcher`, `GACCDispatcher`, `NatDispatcher`, `Contain`, `ContainSim`, `ContainForce`, and `ContainResource` show that the simulation includes dispatch logic, resource arrival/production rates, and fire containment progression.

4. Wildfire planning / investment domain objects  
WFIPS-specific concepts are represented by classes like `FWA`, `Fire`, `Escape`, `FPU`, `DispLoc`, `DispatchBase`, `DispLogic`, `CRescType`, `RescWorkYear`, and `ProdRates`. These encode planning structures such as fire planning units, dispatch locations, and resource capability/cost assumptions.

5. Data ingestion and persistence  
The workflow appears to load planning data into a SQLite-backed model. `wfips_data_load`, `data_load`, `wfips_sqlite`, and `wfips_data_test` indicate structured import and validation of scenario data. The vendored SQLite library and the presence of `wfips_sqlite.h/.cpp` suggest local file-based persistence rather than a remote database service.

6. Geospatial and raster analysis layer  
`fig/src` provides the geometry-heavy side of the application: `fig`, `fig_load`, `fig2scenario`, `raster_access`, and `frisk`. This layer likely translates spatial datasets into scenario inputs, accesses raster layers, and supports analysis areas or treatment polygons. The top-level `doc/` files such as `analysisarea.md`, `dispatchlocations.md`, and `fueltreatment.md` reinforce that GIS layers are first-class inputs.

7. User interface boundary  
The interactive UI lives in `irs/src/gui` and is built with Qt, with additional QGIS integration implied by the build modules. The GUI includes main-window orchestration, dialogs for adding layers, editing dispatch/resource data, identifying features, exporting results, and map tools for selection and inspection. This UI layer sits on top of the core engine and geospatial model; it does not appear to implement the simulation itself.

8. Fire behavior and environment libraries  
The repository embeds two major model families: `flammap/` and `nfdrs/`. FlamMap is included as a substantial, platform-specific codebase for fire behavior / spread calculations, with separate Windows and Linux sources. `nfdrs/` contains the National Fire Danger Rating System implementation. These libraries are supporting computational engines consumed by the WFIPS core rather than user-facing components.

9. Shared utilities and math/time support  
`common/src` contains reusable helpers such as conversions, random-number utilities, time utilities, tree structures, masking, and sunrise/sunset calculations. These are low-level dependencies used across the simulation and analysis code, especially where time, geometry, or stochastic behavior needs to be consistent across modules.

10. Build and platform boundaries  
The build is CMake-driven, with custom `FindQGIS`, `FindGEOS`, `FindSPATIALITE`, and `FindSqlite3` modules showing external dependency integration. The `flammap` subtree has both Windows and Linux variants, which is a clear architectural boundary for platform-specific legacy code. The presence of vendored `sqlite/` and older `flammap` sources suggests the repo packages its computational dependencies directly rather than relying entirely on system installs.

11. Testing structure  
`autotest/` contains C++ unit/integration tests for the core IRS/WFIPS logic and related components. There are tests for containment, result handling, tree structures, load paths, and conversion logic, indicating that most verification is focused on the simulation engine and data model rather than the UI.

12. Documentation and scenario semantics  
The `doc/` directory is not just project prose; it documents the domain objects and outputs the system expects, including agencies, management objectives, large fires, prepositioning, dispatch locations, and simulation parameters. For an architecture diagram, this is useful because it confirms the conceptual pipeline: spatial and agency inputs feed scenario construction, which feeds simulation, which produces results for analysis and export.

In short, the architectural boundary is: spatial/planning data and GIS layers enter through the GUI and data loaders, are normalized into WFIPS domain objects, passed into the simulation/containment engine, enriched by FlamMap/NFDRS computations, and then returned as result/export objects for analysis and visualization.

Main entry points: [`irs/src/gui/wfipsmainwindow.cpp`](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsmainwindow.cpp) (Main window), [`irs/src/wfips.cpp`](https://github.com/firelab/wfips/blob/master/irs/src/wfips.cpp) (WFIPS engine), [`irs/src/RunScenario.cpp`](https://github.com/firelab/wfips/blob/master/irs/src/RunScenario.cpp) (Scenario run), [`irs/src/wfips_data.cpp`](https://github.com/firelab/wfips/blob/master/irs/src/wfips_data.cpp) (WFIPS data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_core["WFIPS core"]
  node_irs_wfips["WFIPS engine<br/>simulation core<br/>[wfips.cpp]"]
  node_irs_runscenario["Scenario run<br/>execution pipeline<br/>[RunScenario.cpp]"]
  node_irs_results["Results<br/>result model<br/>[Results.cpp]"]
  node_irs_wfips_result["WFIPS result<br/>domain result<br/>[wfips_result.cpp]"]
  node_irs_data["WFIPS data<br/>scenario data<br/>[wfips_data.cpp]"]
  node_irs_data_load["Data load<br/>ingest layer<br/>[data_load.cpp]"]
  node_irs_persistence[("SQLite bridge<br/>persistence<br/>[wfips_sqlite.cpp]")]
  node_irs_dispatch["Dispatch logic<br/>resource dispatch<br/>[DispLogic.cpp]"]
  node_irs_contain["Containment<br/>suppression model<br/>[ContainSim.cpp]"]
  node_irs_resources["Resources<br/>resource model<br/>[Rescbase.cpp]"]
end

subgraph group_g_geo["Geospatial ingest"]
  node_fig_ingest["FIG load<br/>spatial ingest<br/>[fig_load.cpp]"]
  node_fig_scenario["FIG to scenario<br/>scenario builder<br/>[fig2scenario.cpp]"]
  node_fig_raster["Raster access<br/>raster I/O<br/>[raster_access.cpp]"]
end

subgraph group_g_ui["GUI"]
  node_gui_main["Main window<br/>Qt shell"]
  node_gui_layers["Layer dialog<br/>map data UI"]
  node_gui_dispatch["Dispatch editor<br/>resource UI"]
  node_gui_identify["Identify tool<br/>map tool"]
  node_gui_export["Export dialog<br/>results UI"]
end

subgraph group_g_models["Embedded models"]
  node_flammap_model["FlamMap<br/>fire behavior<br/>[FlamMap.cpp]"]
  node_nfdrs_model["NFDRS<br/>fire danger<br/>[nfdr32.cpp]"]
end

subgraph group_g_shared["Shared/platform"]
  node_common_utils["Common utils<br/>shared helpers<br/>[omffr_conv.cpp]"]
  node_sqlite_lib[("SQLite<br/>vendored db<br/>[sqlite3.c]")]
  node_docs["Docs<br/>[index.md]"]
end

node_gui_main -->|"runs"| node_irs_wfips
node_gui_main -->|"manages"| node_gui_layers
node_gui_main -->|"edits"| node_gui_dispatch
node_gui_main -->|"inspects"| node_gui_identify
node_gui_main -->|"exports"| node_gui_export
node_fig_ingest -->|"reads"| node_fig_raster
node_fig_ingest -->|"builds"| node_fig_scenario
node_fig_scenario -->|"feeds"| node_irs_data
node_irs_data_load -->|"loads"| node_irs_data
node_irs_data -->|"configures"| node_irs_runscenario
node_irs_runscenario -->|"uses"| node_irs_dispatch
node_irs_runscenario -->|"simulates"| node_irs_contain
node_irs_dispatch -->|"allocates"| node_irs_resources
node_irs_contain -->|"consumes"| node_irs_resources
node_irs_wfips -->|"produces"| node_irs_results
node_irs_results -->|"specializes"| node_irs_wfips_result
node_irs_persistence -->|"stores"| node_sqlite_lib
node_irs_data_load -->|"persists"| node_irs_persistence
node_irs_wfips -->|"calls"| node_flammap_model
node_irs_wfips -->|"calls"| node_nfdrs_model
node_common_utils -->|"supports"| node_irs_runscenario
node_common_utils -->|"supports"| node_fig_ingest
node_docs -->|"describes"| node_irs_data
node_docs -->|"describes"| node_irs_results

click node_irs_wfips "https://github.com/firelab/wfips/blob/master/irs/src/wfips.cpp"
click node_irs_runscenario "https://github.com/firelab/wfips/blob/master/irs/src/RunScenario.cpp"
click node_irs_results "https://github.com/firelab/wfips/blob/master/irs/src/Results.cpp"
click node_irs_wfips_result "https://github.com/firelab/wfips/blob/master/irs/src/wfips_result.cpp"
click node_irs_data "https://github.com/firelab/wfips/blob/master/irs/src/wfips_data.cpp"
click node_irs_data_load "https://github.com/firelab/wfips/blob/master/irs/src/data_load.cpp"
click node_irs_persistence "https://github.com/firelab/wfips/blob/master/irs/src/wfips_sqlite.cpp"
click node_irs_dispatch "https://github.com/firelab/wfips/blob/master/irs/src/DispLogic.cpp"
click node_irs_contain "https://github.com/firelab/wfips/blob/master/irs/src/ContainSim.cpp"
click node_irs_resources "https://github.com/firelab/wfips/blob/master/irs/src/Rescbase.cpp"
click node_fig_ingest "https://github.com/firelab/wfips/blob/master/fig/src/fig_load.cpp"
click node_fig_scenario "https://github.com/firelab/wfips/blob/master/fig/src/fig2scenario.cpp"
click node_fig_raster "https://github.com/firelab/wfips/blob/master/fig/src/raster_access.cpp"
click node_gui_main "https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsmainwindow.cpp"
click node_gui_layers "https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsaddlayerdialog.cpp"
click node_gui_dispatch "https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsdispatcheditdialog.cpp"
click node_gui_identify "https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsidentifymaptool.cpp"
click node_gui_export "https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsexportdialog.cpp"
click node_flammap_model "https://github.com/firelab/wfips/blob/master/flammap/linux/FlamMap.cpp"
click node_nfdrs_model "https://github.com/firelab/wfips/blob/master/nfdrs/nfdr32.cpp"
click node_common_utils "https://github.com/firelab/wfips/blob/master/common/src/omffr_conv.cpp"
click node_sqlite_lib "https://github.com/firelab/wfips/blob/master/sqlite/sqlite3.c"
click node_docs "https://github.com/firelab/wfips/blob/master/doc/index.md"

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_irs_wfips,node_irs_runscenario,node_irs_results,node_irs_wfips_result,node_irs_data,node_irs_data_load,node_irs_persistence,node_irs_dispatch,node_irs_contain,node_irs_resources toneBlue
class node_fig_ingest,node_fig_scenario,node_fig_raster toneAmber
class node_gui_main,node_gui_layers,node_gui_dispatch,node_gui_identify,node_gui_export toneMint
class node_flammap_model,node_nfdrs_model toneRose
class node_common_utils,node_sqlite_lib,node_docs toneIndigo
```

## Components

### WFIPS core

Scenario, resource, containment, and persistence logic in the main simulation engine.

- [WFIPS engine](https://github.com/firelab/wfips/blob/master/irs/src/wfips.cpp): simulation core · Top-level WFIPS orchestration and domain entry point. · `irs/src/wfips.cpp`
- [Scenario run](https://github.com/firelab/wfips/blob/master/irs/src/RunScenario.cpp): execution pipeline · Builds and executes planning scenarios. · `irs/src/RunScenario.cpp`
- [Results](https://github.com/firelab/wfips/blob/master/irs/src/Results.cpp): result model · Simulation outputs and result aggregation. · `irs/src/Results.cpp`
- [WFIPS result](https://github.com/firelab/wfips/blob/master/irs/src/wfips_result.cpp): domain result · WFIPS-specific result representation. · `irs/src/wfips_result.cpp`
- [WFIPS data](https://github.com/firelab/wfips/blob/master/irs/src/wfips_data.cpp): scenario data · Normalized planning inputs and domain data objects. · `irs/src/wfips_data.cpp`
- [Data load](https://github.com/firelab/wfips/blob/master/irs/src/data_load.cpp): ingest layer · Scenario and model data loading routines. · `irs/src/data_load.cpp`
- [SQLite bridge](https://github.com/firelab/wfips/blob/master/irs/src/wfips_sqlite.cpp): persistence · Local SQLite-backed persistence and scenario storage. · `irs/src/wfips_sqlite.cpp`
- [Dispatch logic](https://github.com/firelab/wfips/blob/master/irs/src/DispLogic.cpp): resource dispatch · Dispatch-base and dispatcher coordination for response resources. · `irs/src/DispLogic.cpp`
- [Containment](https://github.com/firelab/wfips/blob/master/irs/src/ContainSim.cpp): suppression model · Containment simulation and fire progression modeling. · `irs/src/ContainSim.cpp`
- [Resources](https://github.com/firelab/wfips/blob/master/irs/src/Rescbase.cpp): resource model · Aircraft, crews, engines, and work-year/resource capability models. · `irs/src/Rescbase.cpp`

### Geospatial ingest

Geometry, raster access, and scenario-building boundary.

- [FIG load](https://github.com/firelab/wfips/blob/master/fig/src/fig_load.cpp): spatial ingest · Geometry and raster loading for analysis inputs. · `fig/src/fig_load.cpp`
- [FIG to scenario](https://github.com/firelab/wfips/blob/master/fig/src/fig2scenario.cpp): scenario builder · Converts spatial inputs into WFIPS scenarios. · `fig/src/fig2scenario.cpp`
- [Raster access](https://github.com/firelab/wfips/blob/master/fig/src/raster_access.cpp): raster I/O · Raster and spatial layer access helpers. · `fig/src/raster_access.cpp`

### GUI

Qt/QGIS-facing interactive boundary for map and data workflows.

- [Main window](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsmainwindow.cpp): Qt shell · Primary GUI shell and map-oriented application orchestration. · `irs/src/gui/wfipsmainwindow.cpp`
- [Layer dialog](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsaddlayerdialog.cpp): map data UI · Adds and manages GIS layers and inputs. · `irs/src/gui/wfipsaddlayerdialog.cpp`
- [Dispatch editor](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsdispatcheditdialog.cpp): resource UI · Edits dispatch, resource, and planning parameters. · `irs/src/gui/wfipsdispatcheditdialog.cpp`
- [Identify tool](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsidentifymaptool.cpp): map tool · Feature identification and inspection on the map canvas. · `irs/src/gui/wfipsidentifymaptool.cpp`
- [Export dialog](https://github.com/firelab/wfips/blob/master/irs/src/gui/wfipsexportdialog.cpp): results UI · Exports simulation outputs for analysis and reporting. · `irs/src/gui/wfipsexportdialog.cpp`

### Embedded models

Fire-behavior and fire-danger libraries bundled into the workspace.

- [FlamMap](https://github.com/firelab/wfips/blob/master/flammap/linux/FlamMap.cpp): fire behavior · Embedded spread and fire-behavior computation library. · `flammap/linux/FlamMap.cpp`
- [NFDRS](https://github.com/firelab/wfips/blob/master/nfdrs/nfdr32.cpp): fire danger · National Fire Danger Rating System calculations. · `nfdrs/nfdr32.cpp`

### Shared/platform

Reusable utilities, vendored database, build integration, and docs/tests.

- [Common utils](https://github.com/firelab/wfips/blob/master/common/src/omffr_conv.cpp): shared helpers · Conversions, randomness, time, masking, and tree utilities. · `common/src/omffr_conv.cpp`
- [SQLite](https://github.com/firelab/wfips/blob/master/sqlite/sqlite3.c): vendored db · Bundled SQLite engine used for local persistence. · `sqlite/sqlite3.c`
- [Docs](https://github.com/firelab/wfips/blob/master/doc/index.md): domain docs · Domain semantics and scenario/result documentation. · `doc/index.md`

## Connections

- Main window → WFIPS engine: runs · GUI drives the core WFIPS engine.
- Main window → Layer dialog: manages · Main window opens layer/input dialogs.
- Main window → Dispatch editor: edits · Main window exposes dispatch/resource editing.
- Main window → Identify tool: inspects · Main window uses map identify tools.
- Main window → Export dialog: exports · Main window triggers result export.
- FIG load → Raster access: reads · Spatial ingestion depends on raster access.
- FIG load → FIG to scenario: builds · Geometry inputs are transformed into scenarios.
- FIG to scenario → WFIPS data: feeds · Spatial analysis contributes normalized scenario data.
- Data load → WFIPS data: loads · Loader materializes WFIPS domain objects.
- WFIPS data → Scenario run: configures · Domain data parameterize scenario execution.
- Scenario run → Dispatch logic: uses · Scenario execution invokes dispatch logic.
- Scenario run → Containment: simulates · Scenario execution advances containment outcomes.
- Dispatch logic → Resources: allocates · Dispatch selects and schedules response resources.
- Containment → Resources: consumes · Containment simulation uses resource capabilities.
- WFIPS engine → Results: produces · Core engine aggregates simulation results.
- Results → WFIPS result: specializes · WFIPS result is a domain-specific result form.
- SQLite bridge → SQLite: stores · WFIPS persistence is backed by SQLite.
- Data load → SQLite bridge: persists · Loaded scenario data can be written/read locally.
- WFIPS engine → FlamMap: calls · WFIPS core uses fire-behavior computations.
- WFIPS engine → NFDRS: calls · WFIPS core uses fire-danger calculations.
- Common utils → Scenario run: supports · Shared utilities underpin execution and modeling.
- Common utils → FIG load: supports · Common helpers support spatial processing.
- Docs → WFIPS data: describes · Documentation defines planning inputs and semantics.
- Docs → Results: describes · Documentation defines result concepts.
