# joshuamarie/box architecture

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

- Interactive diagram: https://gitdiagram.com/joshuamarie/box
- Repository: https://github.com/joshuamarie/box

## Overview

box is an R package for composing reusable, nested R modules and importing modules or packages with explicit, scope-limited bindings. The main workflow is a user’s `box::use` declaration, followed by loading a module or package and making its namespace and selected exports available locally. The README documents those capabilities, while the supplied source excerpts cover only native `$` lookup and symbol registration; internal R-layer connections are therefore omitted where their calls were not shown.

Main entry points: [`R/use.r`](https://github.com/joshuamarie/box/blob/main/R/use.r) (Use declaration), [`R/file.r`](https://github.com/joshuamarie/box/blob/main/R/file.r) (Module files), [`R/env.r`](https://github.com/joshuamarie/box/blob/main/R/env.r) (Module environments), [`src/lookup.c`](https://github.com/joshuamarie/box/blob/main/src/lookup.c) (Strict `$` lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Import interface"]
  node_use["Use declaration<br/>[use.r]"]
  node_spec["Import specification<br/>[spec.r]"]
end

subgraph group_modules["Module system"]
  node_module_files["Module files<br/>[file.r]"]
  node_module_paths["Module search paths<br/>[paths.r]"]
  node_module_env["Module environments<br/>[env.r]"]
  node_exports["Export rules<br/>[export.r]"]
  node_package_loader["Package loading<br/>[loaded.r]"]
end

subgraph group_bindings["Scoped bindings"]
  node_scope["Local import scope<br/>[use.r]"]
  node_name_mapping["Name mapping<br/>[map.r]"]
end

subgraph group_runtime["Runtime support"]
  node_strict_lookup["Strict &#96;$&#96; lookup<br/>[lookup.c]"]
  node_native_registration["Native registration<br/>[exports.c]"]
  node_help["Module help<br/>[help.r]"]
  node_hooks["Module hooks<br/>[hooks.r]"]
  node_reload["Module reload<br/>[unload.r]"]
end

node_user(("R developer"))

node_user -->|"declares imports"| node_use
node_use -->|"loads modules"| node_module_files
node_use -->|"loads packages"| node_package_loader
node_use -->|"limits effects"| node_scope
node_use -.->|"parses declaration"| node_spec
node_module_files -.->|"resolves modules"| node_module_paths
node_module_files -.->|"evaluates code"| node_module_env
node_module_env -.->|"exposes names"| node_exports
node_use -.->|"maps imports"| node_name_mapping
node_module_env -.->|"supports &#96;$&#96; access"| node_strict_lookup
node_native_registration -.->|"registers symbol"| node_strict_lookup

click node_use "https://github.com/joshuamarie/box/blob/main/R/use.r"
click node_spec "https://github.com/joshuamarie/box/blob/main/R/spec.r"
click node_module_files "https://github.com/joshuamarie/box/blob/main/R/file.r"
click node_module_paths "https://github.com/joshuamarie/box/blob/main/R/paths.r"
click node_module_env "https://github.com/joshuamarie/box/blob/main/R/env.r"
click node_exports "https://github.com/joshuamarie/box/blob/main/R/export.r"
click node_package_loader "https://github.com/joshuamarie/box/blob/main/R/loaded.r"
click node_scope "https://github.com/joshuamarie/box/blob/main/R/use.r"
click node_name_mapping "https://github.com/joshuamarie/box/blob/main/R/map.r"
click node_strict_lookup "https://github.com/joshuamarie/box/blob/main/src/lookup.c"
click node_native_registration "https://github.com/joshuamarie/box/blob/main/src/exports.c"
click node_help "https://github.com/joshuamarie/box/blob/main/R/help.r"
click node_hooks "https://github.com/joshuamarie/box/blob/main/R/hooks.r"
click node_reload "https://github.com/joshuamarie/box/blob/main/R/unload.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_use,node_spec toneBlue
class node_module_files,node_module_paths,node_module_env,node_exports,node_package_loader toneAmber
class node_scope,node_name_mapping toneMint
class node_strict_lookup,node_native_registration,node_help,node_hooks,node_reload toneRose
class node_user toneIndigo
```

## Components

### Import interface

- [Use declaration](https://github.com/joshuamarie/box/blob/main/R/use.r): `R/use.r`
- [Import specification](https://github.com/joshuamarie/box/blob/main/R/spec.r): `R/spec.r`

### Module system

- [Module files](https://github.com/joshuamarie/box/blob/main/R/file.r): `R/file.r`
- [Module search paths](https://github.com/joshuamarie/box/blob/main/R/paths.r): `R/paths.r`
- [Module environments](https://github.com/joshuamarie/box/blob/main/R/env.r): `R/env.r`
- [Export rules](https://github.com/joshuamarie/box/blob/main/R/export.r): `R/export.r`
- [Package loading](https://github.com/joshuamarie/box/blob/main/R/loaded.r): `R/loaded.r`

### Scoped bindings

- [Local import scope](https://github.com/joshuamarie/box/blob/main/R/use.r): `R/use.r`
- [Name mapping](https://github.com/joshuamarie/box/blob/main/R/map.r): `R/map.r`

### Runtime support

- [Strict `$` lookup](https://github.com/joshuamarie/box/blob/main/src/lookup.c): `src/lookup.c`
- [Native registration](https://github.com/joshuamarie/box/blob/main/src/exports.c): `src/exports.c`
- [Module help](https://github.com/joshuamarie/box/blob/main/R/help.r): `R/help.r`
- [Module hooks](https://github.com/joshuamarie/box/blob/main/R/hooks.r): `R/hooks.r`
- [Module reload](https://github.com/joshuamarie/box/blob/main/R/unload.r): `R/unload.r`

### Other components

- **R developer**

## Connections

- R developer → Use declaration: declares imports (evidence: `README.md`)
- Use declaration → Module files: loads modules (evidence: `README.md`)
- Use declaration → Package loading: loads packages (evidence: `README.md`)
- Use declaration → Local import scope: limits effects (evidence: `README.md`)
- Use declaration → Import specification: parses declaration
- Module files → Module search paths: resolves modules
- Module files → Module environments: evaluates code
- Module environments → Export rules: exposes names
- Use declaration → Name mapping: maps imports
- Module environments → Strict `$` lookup: supports `$` access
- Native registration → Strict `$` lookup: registers symbol
