# yizhang-yiz/nmt architecture

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

- Interactive diagram: https://gitdiagram.com/yizhang-yiz/nmt
- Repository: https://github.com/yizhang-yiz/nmt

## Overview

nmt is a lightweight R interface for running NONMEM control streams and for constructing models in R before running them. The principal workflow is configure NONMEM, optionally build an nmodel, run it through nm, and examine the returned estimates and result paths. The README documents these capabilities, including diagnostic and user-defined tables and CMake/Ninja requirements. Source excerpts were unavailable, so relationships below are limited to documented behavior; implementation details of result parsing and toolchain configuration are not inferred.

Main entry points: [`R/nm.r`](https://github.com/yizhang-yiz/nmt/blob/master/R/nm.r) (Run model), [`R/nm_model.r`](https://github.com/yizhang-yiz/nmt/blob/master/R/nm_model.r) (Build nmodel), [`R/set_nm.r`](https://github.com/yizhang-yiz/nmt/blob/master/R/set_nm.r) (Configure NONMEM), [`R/set_cmake.r`](https://github.com/yizhang-yiz/nmt/blob/master/R/set_cmake.r) (CMake setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_setup_nm["Configure NONMEM<br/>[set_nm.r]"]
  node_cmake["CMake setup<br/>[set_cmake.r]"]
end

subgraph group_modeling["Model authoring"]
  node_model["Build nmodel<br/>[nm_model.r]"]
  node_print_model["Print nmodel<br/>[nm_model.r]"]
end

subgraph group_execution["NONMEM execution"]
  node_runner["Run model<br/>[nm.r]"]
  node_nonmem["NONMEM"]
end

subgraph group_results["Run results"]
  node_run_result["nmrun results<br/>[nm.r]"]
  node_file_helpers["File and table helpers<br/>[files.r]"]
end

node_user(("R user"))

node_user -->|"configures"| node_setup_nm
node_user -.->|"configures"| node_cmake
node_user -->|"constructs"| node_model
node_user -->|"runs"| node_runner
node_model -->|"provides model"| node_runner
node_runner -->|"builds and runs"| node_nonmem
node_runner -->|"returns"| node_run_result
node_model -->|"prints as"| node_print_model

click node_setup_nm "https://github.com/yizhang-yiz/nmt/blob/master/R/set_nm.r"
click node_cmake "https://github.com/yizhang-yiz/nmt/blob/master/R/set_cmake.r"
click node_model "https://github.com/yizhang-yiz/nmt/blob/master/R/nm_model.r"
click node_print_model "https://github.com/yizhang-yiz/nmt/blob/master/R/nm_model.r"
click node_runner "https://github.com/yizhang-yiz/nmt/blob/master/R/nm.r"
click node_run_result "https://github.com/yizhang-yiz/nmt/blob/master/R/nm.r"
click node_file_helpers "https://github.com/yizhang-yiz/nmt/blob/master/R/files.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_setup_nm,node_cmake,node_user toneBlue
class node_model,node_print_model toneAmber
class node_runner,node_nonmem toneMint
class node_run_result,node_file_helpers toneRose
```

## Components

### Configuration

- [Configure NONMEM](https://github.com/yizhang-yiz/nmt/blob/master/R/set_nm.r): `R/set_nm.r`
- [CMake setup](https://github.com/yizhang-yiz/nmt/blob/master/R/set_cmake.r): `R/set_cmake.r`

### Model authoring

- [Build nmodel](https://github.com/yizhang-yiz/nmt/blob/master/R/nm_model.r): `R/nm_model.r`
- [Print nmodel](https://github.com/yizhang-yiz/nmt/blob/master/R/nm_model.r): `R/nm_model.r`

### NONMEM execution

- [Run model](https://github.com/yizhang-yiz/nmt/blob/master/R/nm.r): `R/nm.r`
- **NONMEM**

### Run results

- [nmrun results](https://github.com/yizhang-yiz/nmt/blob/master/R/nm.r): `R/nm.r`
- [File and table helpers](https://github.com/yizhang-yiz/nmt/blob/master/R/files.r): `R/files.r`

### Other components

- **R user**

## Connections

- R user → Configure NONMEM: configures (evidence: `readme.org`)
- R user → CMake setup: configures
- R user → Build nmodel: constructs (evidence: `readme.org`)
- R user → Run model: runs (evidence: `readme.org`)
- Build nmodel → Run model: provides model (evidence: `readme.org`)
- Run model → NONMEM: builds and runs (evidence: `readme.org`)
- Run model → nmrun results: returns (evidence: `readme.org`)
- Build nmodel → Print nmodel: prints as (evidence: `readme.org`)
