# rhenriquezitg/bodcalc architecture

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

- Interactive diagram: https://gitdiagram.com/rhenriquezitg/bodcalc
- Repository: https://github.com/rhenriquezitg/bodcalc

## Overview

The Shiny app guides users through population, deaths, health states and economic inputs, then calculates burden estimates, uncertainty intervals and results. The graph follows the documented module structure and methods; source excerpts were unavailable, so relationships are limited to those stated in the README.

Main entry points: [`R/mod_results.R`](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_results.R) (Results page), [`R/app_ui.R`](https://github.com/rhenriquezitg/bodcalc/blob/main/R/app_ui.R) (App UI), [`R/mod_age_sex_upload.R`](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_age_sex_upload.R) (Upload widget), [`app.R`](https://github.com/rhenriquezitg/bodcalc/blob/main/app.R) (App entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["User workflow"]
  node_app["App entry<br/>[app.R]"]
  node_ui["App UI<br/>[app_ui.R]"]
  node_server["App server<br/>[app_server.R]"]
  node_population["Population input<br/>[mod_population.R]"]
  node_deaths["Deaths input<br/>[mod_deaths.R]"]
  node_health["Health states"]
  node_economics_input["Economic inputs<br/>[mod_economics.R]"]
  node_upload["Upload widget"]
end

subgraph group_calculations["Burden calculations"]
  node_life_table["Reference life table<br/>[gbd_life_table.rds]"]
  node_life_table_calc["Life table logic<br/>[fct_life_table.R]"]
  node_yll["YLL calculation<br/>[fct_calc_yll.R]"]
  node_yld["YLD calculation<br/>[fct_calc_yld.R]"]
  node_daly["DALY calculation<br/>[fct_calc_daly.R]"]
  node_discount["Discount weighting"]
  node_monte_carlo["Monte Carlo<br/>[fct_monte_carlo.R]"]
  node_economic_burden["Economic burden"]
end

subgraph group_support["Calculation support"]
  node_validate["Input validation"]
  node_template["CSV templates<br/>[fct_csv_template.R]"]
  node_age_grid["Age grid<br/>[utils_age_grid.R]"]
  node_duration["Duration utility<br/>[utils_duration.R]"]
  node_currency["Currency utility<br/>[utils_currency.R]"]
end

subgraph group_results["Results and reporting"]
  node_results["Results page<br/>[mod_results.R]"]
  node_plots["Plot utilities<br/>[utils_plots.R]"]
  node_report["HTML report<br/>[report.Rmd]"]
end

node_user(("User"))

node_user -->|"runs"| node_app
node_app -->|"starts"| node_server
node_app -->|"presents"| node_ui
node_app -->|"loads"| node_life_table
node_ui -->|"offers step 1"| node_population
node_ui -->|"offers step 2"| node_deaths
node_ui -->|"offers step 3"| node_health
node_ui -->|"offers step 4"| node_economics_input
node_ui -->|"offers step 5"| node_results
node_population -->|"sets reference grid"| node_age_grid
node_population -->|"uses shared widget"| node_upload
node_deaths -->|"uses shared widget"| node_upload
node_health -->|"uses shared widget"| node_upload
node_upload -->|"validates inputs"| node_validate
node_upload -->|"offers download"| node_template
node_life_table_calc -->|"uses reference data"| node_life_table
node_yll -->|"uses life expectancy"| node_life_table_calc
node_results -->|"calculates YLL"| node_yll
node_results -->|"calculates YLD"| node_yld
node_results -->|"calculates DALYs"| node_daly
node_daly -->|"sums with YLD"| node_yll
node_daly -->|"sums with YLL"| node_yld
node_results -->|"applies options"| node_discount
node_results -->|"estimates uncertainty"| node_monte_carlo
node_results -->|"calculates costs"| node_economic_burden
node_results -->|"presents plots"| node_plots
node_results -->|"downloads report"| node_report
node_economic_burden -->|"uses DALYs"| node_daly
node_economics_input -->|"sets currency"| node_currency
node_health -.->|"provides duration"| node_duration

click node_app "https://github.com/rhenriquezitg/bodcalc/blob/main/app.R"
click node_ui "https://github.com/rhenriquezitg/bodcalc/blob/main/R/app_ui.R"
click node_server "https://github.com/rhenriquezitg/bodcalc/blob/main/R/app_server.R"
click node_population "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_population.R"
click node_deaths "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_deaths.R"
click node_health "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_health_states.R"
click node_economics_input "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_economics.R"
click node_upload "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_age_sex_upload.R"
click node_life_table "https://github.com/rhenriquezitg/bodcalc/blob/main/data/gbd_life_table.rds"
click node_life_table_calc "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_life_table.R"
click node_yll "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_yll.R"
click node_yld "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_yld.R"
click node_daly "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_daly.R"
click node_discount "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_discount_weight.R"
click node_monte_carlo "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_monte_carlo.R"
click node_validate "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_validate_inputs.R"
click node_template "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_csv_template.R"
click node_age_grid "https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_age_grid.R"
click node_duration "https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_duration.R"
click node_currency "https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_currency.R"
click node_economic_burden "https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_economic_burden.R"
click node_results "https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_results.R"
click node_plots "https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_plots.R"
click node_report "https://github.com/rhenriquezitg/bodcalc/blob/main/report/report.Rmd"

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_app,node_ui,node_server,node_population,node_deaths,node_health,node_economics_input,node_upload,node_user toneBlue
class node_life_table,node_life_table_calc,node_yll,node_yld,node_daly,node_discount,node_monte_carlo,node_economic_burden toneAmber
class node_validate,node_template,node_age_grid,node_duration,node_currency toneMint
class node_results,node_plots,node_report toneRose
```

## Components

### User workflow

- [App entry](https://github.com/rhenriquezitg/bodcalc/blob/main/app.R): `app.R`
- [App UI](https://github.com/rhenriquezitg/bodcalc/blob/main/R/app_ui.R): `R/app_ui.R`
- [App server](https://github.com/rhenriquezitg/bodcalc/blob/main/R/app_server.R): `R/app_server.R`
- [Population input](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_population.R): `R/mod_population.R`
- [Deaths input](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_deaths.R): `R/mod_deaths.R`
- [Health states](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_health_states.R): `R/mod_health_states.R`
- [Economic inputs](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_economics.R): `R/mod_economics.R`
- [Upload widget](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_age_sex_upload.R): `R/mod_age_sex_upload.R`

### Burden calculations

- [Reference life table](https://github.com/rhenriquezitg/bodcalc/blob/main/data/gbd_life_table.rds): `data/gbd_life_table.rds`
- [Life table logic](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_life_table.R): `R/fct_life_table.R`
- [YLL calculation](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_yll.R): `R/fct_calc_yll.R`
- [YLD calculation](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_yld.R): `R/fct_calc_yld.R`
- [DALY calculation](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_calc_daly.R): `R/fct_calc_daly.R`
- [Discount weighting](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_discount_weight.R): `R/fct_discount_weight.R`
- [Monte Carlo](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_monte_carlo.R): `R/fct_monte_carlo.R`
- [Economic burden](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_economic_burden.R): `R/fct_economic_burden.R`

### Calculation support

- [Input validation](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_validate_inputs.R): `R/fct_validate_inputs.R`
- [CSV templates](https://github.com/rhenriquezitg/bodcalc/blob/main/R/fct_csv_template.R): `R/fct_csv_template.R`
- [Age grid](https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_age_grid.R): `R/utils_age_grid.R`
- [Duration utility](https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_duration.R): `R/utils_duration.R`
- [Currency utility](https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_currency.R): `R/utils_currency.R`

### Results and reporting

- [Results page](https://github.com/rhenriquezitg/bodcalc/blob/main/R/mod_results.R): `R/mod_results.R`
- [Plot utilities](https://github.com/rhenriquezitg/bodcalc/blob/main/R/utils_plots.R): `R/utils_plots.R`
- [HTML report](https://github.com/rhenriquezitg/bodcalc/blob/main/report/report.Rmd): `report/report.Rmd`

### Other components

- **User**

## Connections

- User → App entry: runs (evidence: `README.md`)
- App entry → App server: starts (evidence: `README.md`)
- App entry → App UI: presents (evidence: `README.md`)
- App entry → Reference life table: loads (evidence: `README.md`)
- App UI → Population input: offers step 1 (evidence: `README.md`)
- App UI → Deaths input: offers step 2 (evidence: `README.md`)
- App UI → Health states: offers step 3 (evidence: `README.md`)
- App UI → Economic inputs: offers step 4 (evidence: `README.md`)
- App UI → Results page: offers step 5 (evidence: `README.md`)
- Population input → Age grid: sets reference grid (evidence: `README.md`)
- Population input → Upload widget: uses shared widget (evidence: `README.md`)
- Deaths input → Upload widget: uses shared widget (evidence: `README.md`)
- Health states → Upload widget: uses shared widget (evidence: `README.md`)
- Upload widget → Input validation: validates inputs (evidence: `README.md`)
- Upload widget → CSV templates: offers download (evidence: `README.md`)
- Life table logic → Reference life table: uses reference data (evidence: `README.md`)
- YLL calculation → Life table logic: uses life expectancy (evidence: `README.md`)
- Results page → YLL calculation: calculates YLL (evidence: `README.md`)
- Results page → YLD calculation: calculates YLD (evidence: `README.md`)
- Results page → DALY calculation: calculates DALYs (evidence: `README.md`)
- DALY calculation → YLL calculation: sums with YLD (evidence: `README.md`)
- DALY calculation → YLD calculation: sums with YLL (evidence: `README.md`)
- Results page → Discount weighting: applies options (evidence: `README.md`)
- Results page → Monte Carlo: estimates uncertainty (evidence: `README.md`)
- Results page → Economic burden: calculates costs (evidence: `README.md`)
- Results page → Plot utilities: presents plots (evidence: `README.md`)
- Results page → HTML report: downloads report (evidence: `README.md`)
- Economic burden → DALY calculation: uses DALYs (evidence: `README.md`)
- Economic inputs → Currency utility: sets currency (evidence: `README.md`)
- Health states → Duration utility: provides duration
