# noaa-edab/rpath architecture

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

- Interactive diagram: https://gitdiagram.com/noaa-edab/rpath
- Repository: https://github.com/noaa-edab/rpath

## Overview

Rpath is an R/Rcpp food-web modeling package. The main workflow is to assemble an Ecopath mass-balance model, configure simulation parameters and forcing, run Ecosim dynamics, and inspect or export results. README also identifies sensitivity analysis, bioenergetics forcing, and adaptive annual feedback as product capabilities. R-layer links are limited where implementation excerpts were unavailable; the sampled C++ excerpts show the simulation and stanza-update internals.

Main entry points: [`src/ecosim.cpp`](https://github.com/noaa-edab/rpath/blob/main/src/ecosim.cpp) (Dynamics integrator), [`R/ecopath.R`](https://github.com/noaa-edab/rpath/blob/main/R/ecopath.R) (Ecopath model), [`R/ecosim.R`](https://github.com/noaa-edab/rpath/blob/main/R/ecosim.R) (Ecosim runner), [`src/RcppExports.cpp`](https://github.com/noaa-edab/rpath/blob/main/src/RcppExports.cpp) (Rcpp entry points)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model setup"]
  node_ecopath["Ecopath model<br/>[ecopath.R]"]
  node_params["Model parameters<br/>[param.R]"]
  node_adjustments["Annual adjustments<br/>[Adjustments.R]"]
end

subgraph group_simulation["Ecosim simulation"]
  node_ecosim["Ecosim runner<br/>[ecosim.R]"]
  node_multistep["Multistep runs<br/>[ecosim_multistep.R]"]
  node_cpp_api["Rcpp entry points<br/>[RcppExports.cpp]"]
  node_integrator["Dynamics integrator<br/>[ecosim.cpp]"]
  node_sim_constants["Simulation constants<br/>[ecosim.h]"]
  node_forcing["Forcing and fishing<br/>[ecosim.R]"]
  node_stanzas["Stanza updates<br/>[ecosim.cpp]"]
end

subgraph group_analysis["Analysis tools"]
  node_sensitivity["Sensitivity analysis<br/>[ecosense.R]"]
  node_extraction["Result extraction<br/>[Extract.R]"]
  node_plots["Model plots<br/>[ecosim_plot.R]"]
  node_ecopath_plots["Ecopath plots<br/>[ecopath_plot.R]"]
end

subgraph group_io["Data exchange"]
  node_xml_import["EwE XML import<br/>[xml_convert.r]"]
  node_writers["Model writers<br/>[write_functions.R]"]
  node_datasets[("Example ecosystems<br/>[data.R]")]
end

node_user(("Modeler"))

node_user -->|"builds model"| node_ecopath
node_user -->|"runs simulation"| node_ecosim
node_ecopath -.->|"configures"| node_params
node_ecosim -.->|"dispatches"| node_cpp_api
node_cpp_api -->|"calls rk4_run"| node_integrator
node_integrator -->|"uses constants"| node_sim_constants
node_integrator -->|"updates pools"| node_stanzas
node_user -->|"assesses sensitivity"| node_sensitivity
node_user -->|"sets feedback"| node_adjustments
node_user -->|"configures forcing"| node_forcing
node_user -.->|"imports EwE model"| node_xml_import
node_user -.->|"loads examples"| node_datasets
node_user -.->|"extracts results"| node_extraction
node_user -.->|"views results"| node_plots
node_user -.->|"views model"| node_ecopath_plots
node_user -.->|"exports model"| node_writers
node_user -.->|"runs scenarios"| node_multistep

click node_ecopath "https://github.com/noaa-edab/rpath/blob/main/R/ecopath.R"
click node_params "https://github.com/noaa-edab/rpath/blob/main/R/param.R"
click node_adjustments "https://github.com/noaa-edab/rpath/blob/main/R/Adjustments.R"
click node_ecosim "https://github.com/noaa-edab/rpath/blob/main/R/ecosim.R"
click node_multistep "https://github.com/noaa-edab/rpath/blob/main/R/ecosim_multistep.R"
click node_cpp_api "https://github.com/noaa-edab/rpath/blob/main/src/RcppExports.cpp"
click node_integrator "https://github.com/noaa-edab/rpath/blob/main/src/ecosim.cpp"
click node_sim_constants "https://github.com/noaa-edab/rpath/blob/main/src/ecosim.h"
click node_forcing "https://github.com/noaa-edab/rpath/blob/main/R/ecosim.R"
click node_stanzas "https://github.com/noaa-edab/rpath/blob/main/src/ecosim.cpp"
click node_sensitivity "https://github.com/noaa-edab/rpath/blob/main/R/ecosense.R"
click node_extraction "https://github.com/noaa-edab/rpath/blob/main/R/Extract.R"
click node_plots "https://github.com/noaa-edab/rpath/blob/main/R/ecosim_plot.R"
click node_ecopath_plots "https://github.com/noaa-edab/rpath/blob/main/R/ecopath_plot.R"
click node_xml_import "https://github.com/noaa-edab/rpath/blob/main/R/xml_convert.r"
click node_writers "https://github.com/noaa-edab/rpath/blob/main/R/write_functions.R"
click node_datasets "https://github.com/noaa-edab/rpath/blob/main/R/data.R"

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_ecopath,node_params,node_adjustments toneBlue
class node_ecosim,node_multistep,node_cpp_api,node_integrator,node_sim_constants,node_forcing,node_stanzas toneAmber
class node_sensitivity,node_extraction,node_plots,node_ecopath_plots toneMint
class node_xml_import,node_writers,node_datasets toneRose
class node_user toneIndigo
```

## Components

### Model setup

- [Ecopath model](https://github.com/noaa-edab/rpath/blob/main/R/ecopath.R): `R/ecopath.R`
- [Model parameters](https://github.com/noaa-edab/rpath/blob/main/R/param.R): `R/param.R`
- [Annual adjustments](https://github.com/noaa-edab/rpath/blob/main/R/Adjustments.R): `R/Adjustments.R`

### Ecosim simulation

- [Ecosim runner](https://github.com/noaa-edab/rpath/blob/main/R/ecosim.R): `R/ecosim.R`
- [Multistep runs](https://github.com/noaa-edab/rpath/blob/main/R/ecosim_multistep.R): `R/ecosim_multistep.R`
- [Rcpp entry points](https://github.com/noaa-edab/rpath/blob/main/src/RcppExports.cpp): `src/RcppExports.cpp`
- [Dynamics integrator](https://github.com/noaa-edab/rpath/blob/main/src/ecosim.cpp): `src/ecosim.cpp`
- [Simulation constants](https://github.com/noaa-edab/rpath/blob/main/src/ecosim.h): `src/ecosim.h`
- [Forcing and fishing](https://github.com/noaa-edab/rpath/blob/main/R/ecosim.R): `R/ecosim.R`
- [Stanza updates](https://github.com/noaa-edab/rpath/blob/main/src/ecosim.cpp): `src/ecosim.cpp`

### Analysis tools

- [Sensitivity analysis](https://github.com/noaa-edab/rpath/blob/main/R/ecosense.R): `R/ecosense.R`
- [Result extraction](https://github.com/noaa-edab/rpath/blob/main/R/Extract.R): `R/Extract.R`
- [Model plots](https://github.com/noaa-edab/rpath/blob/main/R/ecosim_plot.R): `R/ecosim_plot.R`
- [Ecopath plots](https://github.com/noaa-edab/rpath/blob/main/R/ecopath_plot.R): `R/ecopath_plot.R`

### Data exchange

- [EwE XML import](https://github.com/noaa-edab/rpath/blob/main/R/xml_convert.r): `R/xml_convert.r`
- [Model writers](https://github.com/noaa-edab/rpath/blob/main/R/write_functions.R): `R/write_functions.R`
- [Example ecosystems](https://github.com/noaa-edab/rpath/blob/main/R/data.R): `R/data.R`

### Other components

- **Modeler**

## Connections

- Modeler → Ecopath model: builds model (evidence: `README.md`)
- Modeler → Ecosim runner: runs simulation (evidence: `README.md`)
- Ecopath model → Model parameters: configures
- Ecosim runner → Rcpp entry points: dispatches
- Rcpp entry points → Dynamics integrator: calls rk4_run (evidence: `src/RcppExports.cpp`)
- Dynamics integrator → Simulation constants: uses constants (evidence: `src/ecosim.cpp`)
- Dynamics integrator → Stanza updates: updates pools (evidence: `src/ecosim.cpp`)
- Modeler → Sensitivity analysis: assesses sensitivity (evidence: `README.md`)
- Modeler → Annual adjustments: sets feedback (evidence: `README.md`)
- Modeler → Forcing and fishing: configures forcing (evidence: `README.md`)
- Modeler → EwE XML import: imports EwE model
- Modeler → Example ecosystems: loads examples
- Modeler → Result extraction: extracts results
- Modeler → Model plots: views results
- Modeler → Ecopath plots: views model
- Modeler → Model writers: exports model
- Modeler → Multistep runs: runs scenarios
