# novonordisk-opensource/zephyr architecture

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

- Interactive diagram: https://gitdiagram.com/novonordisk-opensource/zephyr
- Repository: https://github.com/novonordisk-opensource/zephyr

## Overview

##### Project Type and Purpose
- zephyr is an R package—a developer utility library—designed to be embedded into other R packages.
- Its core responsibility is to provide:
– A unified messaging/verbosity framework (`msg_*` functions) built on top of {cli}.
– Utilities to create, retrieve, and document package-specific options (`create_option`, `get_option`, `list_options`).
– A boilerplate generator (`use_zephyr()`) to set up option scaffolding in client packages.

##### Main Architectural Components
A. Core Library (R/)
– msg.R, checkmate.R, options.R, etc.
– Implements messaging API, option management, default configurations.
B. API Entry Points
– use_zephyr.R: scaffolding function to inject boilerplate into client packages.
– create_option.Rd, get_option.Rd (in man/) – user-facing documentation stubs.
C. Configuration & Defaults (inst/)
– setup-options.R: default option registration script.
– WORDLIST: internal resource for message word lists.
D. Documentation Site (pkgdown/)
– Static assets, favicon, config in _pkgdown.yml.
E. Testing Suite (tests/)
– unit tests (testthat), integration snapshots (_snaps).
– helper scripts under tests/testthat/scripts.
F. Continuous Integration ( .github/workflows )
– check_and_co.yaml: lint, test, coverage, CRAN checks.
G. Build & Package Metadata
– DESCRIPTION, NAMESPACE, LICENSE.md, NEWS.md, cran-comments.md.

##### Relationships & Data Flows
- Client Package Developer → calls use_zephyr() → Core Library → writes R/{pkg}-options.R + inst/setup-options.R
- Core Library functions (msg_success, etc.) → depend on {cli} and current verbosity option → render messages to console.
- create_option/get_option → interact with package’s options store (registered in .onLoad via inst/setup-options.R).
- pkgdown generates website from man/, vignettes, README.Rmd using _pkgdown.yml.
- tests invoke Core Library functions and options to validate behavior.
- CI triggers tests, coverage, linting whenever code is pushed.

##### Architectural Patterns & Principles
– Modular layering:
- Core API layer (msg_*, create_option, get_option).
- Infrastructure layer (on-load option registration, cli rendering).
- Scaffolding/code generation (use_zephyr).
– Convention-over-configuration: sensible defaults, centralized option store.
– Separation of concerns: messaging vs. option management vs. scaffolding vs. docs vs. testing.

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Client Package"
    Client["Client Package"]:::external
  end

  subgraph "Scaffolding & API Entry Points"
    UseZ["use_zephyr.R"]:::corecode
    RdCreate["create_option.Rd"]:::docs
    RdGet["get_option.Rd"]:::docs
    RdList["list_options.Rd"]:::docs
    RdUse["use_zephyr.Rd"]:::docs
  end

  subgraph "Core Library (R/)"
    MsgR["msg.R"]:::corecode
    OptsR["options.R"]:::corecode
    CheckR["checkmate.R"]:::corecode
    UtilsR["utils.R"]:::corecode
    Verb["verbosity_level.R"]:::corecode
    Import["import-standalone-s3-register.R"]:::corecode
    ZephPkg["zephyr-package.R"]:::corecode
    Zzz["zzz.R"]:::corecode
  end

  subgraph "Option Store (inst/)"
    Setup["setup-options.R"]:::generated
    Word["WORDLIST"]:::generated
  end

  subgraph "Documentation Site (pkgdown/)"
    PkgdownCfg["_pkgdown.yml"]:::docs
    Favicon["favicon"]:::docs
    Manifest["site.webmanifest"]:::docs
  end

  subgraph "Testing Suite (tests/)"
    TMsg["test-msg.R"]:::tests
    TOpt["test-options.R"]:::tests
    TUzeph["test-use_zephyr.R"]:::tests
    TCheck["test-checkmate.R"]:::tests
    TUti["test-utils.R"]:::tests
    TVerb["test-verbosity_level.R"]:::tests
    TInt["test-integration.R"]:::tests
    THlp["helper.R"]:::tests
    Script["scripts/greet.R"]:::tests
    Snaps["_snaps"]:::tests
  end

  subgraph "CI/CD (.github/)"
    CIrun["check_and_co.yaml"]:::ci
  end

  subgraph "External Dependencies"
    CLI["{cli}"]:::external
    Testthat["{testthat}"]:::external
    PkgdownExt["{pkgdown}"]:::external
    CRAN["CRAN"]:::external
  end

  Client -->|"calls"| UseZ
  UseZ -->|"generates boilerplate"| MsgR
  UseZ -->|"generates boilerplate"| OptsR
  UseZ -->|"generates defaults"| Setup

  MsgR -->|"depends on"| CLI
  OptsR -->|"registers via"| Setup
  Setup -->|"registers on load"| Zzz

  RdCreate & RdGet & RdList & RdUse -->|"sources for"| PkgdownCfg

  TMsg -->|"tests"| MsgR
  TOpt -->|"tests"| OptsR
  TUzeph -->|"tests"| UseZ
  TCheck -->|"tests"| CheckR
  TUti -->|"tests"| UtilsR
  TVerb -->|"tests"| Verb
  TInt -->|"integration tests"| MsgR
  TInt -->|"integration tests"| OptsR
  THlp -->|"helper for tests"| TMsg
  Script -->|"helper script"| TInt
  Snaps -->|"snapshot storage"| TInt

  CIrun -->|"runs tests"| TMsg
  CIrun -->|"runs tests"| TOpt
  CIrun -->|"runs docs build"| PkgdownCfg
  CIrun -->|"publishes to"| CRAN

  classDef corecode fill:#E3F2FD,stroke:#2196F3,stroke-width:2px
  classDef generated fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px
  classDef docs fill:#FFFDE7,stroke:#FBC02D,stroke-width:2px
  classDef tests fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
  classDef ci fill:#F3E5F5,stroke:#9C27B0,stroke-width:2px
  classDef external fill:#ECEFF1,stroke:#90A4AE,stroke-width:2px

  click MsgR "https://github.com/novonordisk-opensource/zephyr/blob/main/R/msg.R"
  click OptsR "https://github.com/novonordisk-opensource/zephyr/blob/main/R/options.R"
  click CheckR "https://github.com/novonordisk-opensource/zephyr/blob/main/R/checkmate.R"
  click UtilsR "https://github.com/novonordisk-opensource/zephyr/blob/main/R/utils.R"
  click Verb "https://github.com/novonordisk-opensource/zephyr/blob/main/R/verbosity_level.R"
  click Import "https://github.com/novonordisk-opensource/zephyr/blob/main/R/import-standalone-s3-register.R"
  click ZephPkg "https://github.com/novonordisk-opensource/zephyr/blob/main/R/zephyr-package.R"
  click Zzz "https://github.com/novonordisk-opensource/zephyr/blob/main/R/zzz.R"

  click UseZ "https://github.com/novonordisk-opensource/zephyr/blob/main/R/use_zephyr.R"
  click RdCreate "https://github.com/novonordisk-opensource/zephyr/blob/main/man/create_option.Rd"
  click RdGet "https://github.com/novonordisk-opensource/zephyr/blob/main/man/get_option.Rd"
  click RdList "https://github.com/novonordisk-opensource/zephyr/blob/main/man/list_options.Rd"
  click RdUse "https://github.com/novonordisk-opensource/zephyr/blob/main/man/use_zephyr.Rd"

  click Setup "https://github.com/novonordisk-opensource/zephyr/blob/main/inst/setup-options.R"
  click Word "https://github.com/novonordisk-opensource/zephyr/tree/main/inst/WORDLIST"

  click PkgdownCfg "https://github.com/novonordisk-opensource/zephyr/blob/main/_pkgdown.yml"
  click Favicon "https://github.com/novonordisk-opensource/zephyr/tree/main/pkgdown/favicon"
  click Manifest "https://github.com/novonordisk-opensource/zephyr/blob/main/pkgdown/favicon/site.webmanifest"

  click TMsg "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-msg.R"
  click TOpt "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-options.R"
  click TUzeph "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-use_zephyr.R"
  click TCheck "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-checkmate.R"
  click TUti "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-utils.R"
  click TVerb "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-verbosity_level.R"
  click TInt "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/test-integration.R"
  click THlp "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/helper.R"
  click Script "https://github.com/novonordisk-opensource/zephyr/blob/main/tests/testthat/scripts/greet.R"
  click Snaps "https://github.com/novonordisk-opensource/zephyr/tree/main/tests/testthat/_snaps"

  click CIrun "https://github.com/novonordisk-opensource/zephyr/blob/main/.github/workflows/check_and_co.yaml"
```
