# vivo75/bash-digest architecture

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

- Interactive diagram: https://gitdiagram.com/vivo75/bash-digest
- Repository: https://github.com/vivo75/bash-digest

## Overview

bash-digest is a static analyzer for Gentoo ebuild/eclass Bash and Portage configuration. Its principal workflow discovers input files, parses them with GNU Bash without executing them, then extracts environment assignments and external executable names into one deterministic JSON digest. Optional expansion resolves supported variable and arithmetic expressions. The graph preserves the documented crate responsibilities and expansion submodules; some orchestration calls are established by the README rather than complete source excerpts.

Main entry points: [`src/main.rs`](https://github.com/vivo75/bash-digest/blob/main/src/main.rs) (CLI orchestration), [`crates/expand/src/lib.rs`](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/lib.rs) (Variable expansion), [`crates/expand/src/param.rs`](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/param.rs) (Parameter operations), [`crates/scanner/src/lib.rs`](https://github.com/vivo75/bash-digest/blob/main/crates/scanner/src/lib.rs) (Input discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Analysis workflow"]
  node_main["CLI orchestration<br/>[main.rs]"]
  node_scanner["Input discovery<br/>[lib.rs]"]
  node_inputs["Overlay and Portage files"]
  node_digest["Aggregated JSON"]
end

subgraph group_parsing["Bash parsing"]
  node_parser["Bash parser binding<br/>[lib.rs]"]
end

subgraph group_extraction["Extraction and expansion"]
  node_env["Environment extraction<br/>[lib.rs]"]
  node_exec["Executable extraction<br/>[lib.rs]"]
  node_expander["Variable expansion<br/>[lib.rs]"]
  node_param["Parameter operations<br/>[param.rs]"]
  node_arith["Arithmetic evaluation<br/>[arith.rs]"]
  node_glob["Glob matching<br/>[glob.rs]"]
end

subgraph group_contract["Shared data"]
  node_ast["Owned AST and records<br/>[lib.rs]"]
end

node_user(("CLI user"))

node_user -->|"provides options"| node_main
node_main -->|"discovers files"| node_scanner
node_scanner -->|"reads paths"| node_inputs
node_main -->|"parses files"| node_parser
node_parser -->|"returns AST"| node_ast
node_main -->|"extracts variables"| node_env
node_main -->|"extracts executables"| node_exec
node_env -.->|"expands values"| node_expander
node_exec -.->|"expands names"| node_expander
node_expander -->|"resolves parameters"| node_param
node_expander -->|"evaluates arithmetic"| node_arith
node_param -->|"evaluates arithmetic"| node_arith
node_param -->|"matches patterns"| node_glob
node_main -->|"writes JSON"| node_digest

click node_main "https://github.com/vivo75/bash-digest/blob/main/src/main.rs"
click node_scanner "https://github.com/vivo75/bash-digest/blob/main/crates/scanner/src/lib.rs"
click node_parser "https://github.com/vivo75/bash-digest/blob/main/crates/bash-ffi/src/lib.rs"
click node_ast "https://github.com/vivo75/bash-digest/blob/main/crates/ast-core/src/lib.rs"
click node_env "https://github.com/vivo75/bash-digest/blob/main/crates/extract-env/src/lib.rs"
click node_exec "https://github.com/vivo75/bash-digest/blob/main/crates/extract-exec/src/lib.rs"
click node_expander "https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/lib.rs"
click node_param "https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/param.rs"
click node_arith "https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/arith.rs"
click node_glob "https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/glob.rs"

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_main,node_scanner,node_inputs,node_digest,node_user toneBlue
class node_parser toneAmber
class node_env,node_exec,node_expander,node_param,node_arith,node_glob toneMint
class node_ast toneRose
```

## Components

### Analysis workflow

- [CLI orchestration](https://github.com/vivo75/bash-digest/blob/main/src/main.rs): `src/main.rs`
- [Input discovery](https://github.com/vivo75/bash-digest/blob/main/crates/scanner/src/lib.rs): `crates/scanner/src/lib.rs`
- **Overlay and Portage files**
- **Aggregated JSON**

### Bash parsing

- [Bash parser binding](https://github.com/vivo75/bash-digest/blob/main/crates/bash-ffi/src/lib.rs): `crates/bash-ffi/src/lib.rs`

### Extraction and expansion

- [Environment extraction](https://github.com/vivo75/bash-digest/blob/main/crates/extract-env/src/lib.rs): `crates/extract-env/src/lib.rs`
- [Executable extraction](https://github.com/vivo75/bash-digest/blob/main/crates/extract-exec/src/lib.rs): `crates/extract-exec/src/lib.rs`
- [Variable expansion](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/lib.rs): `crates/expand/src/lib.rs`
- [Parameter operations](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/param.rs): `crates/expand/src/param.rs`
- [Arithmetic evaluation](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/arith.rs): `crates/expand/src/arith.rs`
- [Glob matching](https://github.com/vivo75/bash-digest/blob/main/crates/expand/src/glob.rs): `crates/expand/src/glob.rs`

### Shared data

- [Owned AST and records](https://github.com/vivo75/bash-digest/blob/main/crates/ast-core/src/lib.rs): `crates/ast-core/src/lib.rs`

### Other components

- **CLI user**

## Connections

- CLI user → CLI orchestration: provides options (evidence: `README.md`)
- CLI orchestration → Input discovery: discovers files (evidence: `src/main.rs`)
- Input discovery → Overlay and Portage files: reads paths (evidence: `crates/scanner/src/lib.rs`)
- CLI orchestration → Bash parser binding: parses files (evidence: `README.md`)
- Bash parser binding → Owned AST and records: returns AST (evidence: `crates/bash-ffi/src/lib.rs`)
- CLI orchestration → Environment extraction: extracts variables (evidence: `README.md`)
- CLI orchestration → Executable extraction: extracts executables (evidence: `README.md`)
- Environment extraction → Variable expansion: expands values
- Executable extraction → Variable expansion: expands names
- Variable expansion → Parameter operations: resolves parameters (evidence: `crates/expand/src/lib.rs`)
- Variable expansion → Arithmetic evaluation: evaluates arithmetic (evidence: `crates/expand/src/lib.rs`)
- Parameter operations → Arithmetic evaluation: evaluates arithmetic (evidence: `crates/expand/src/param.rs`)
- Parameter operations → Glob matching: matches patterns (evidence: `crates/expand/src/param.rs`)
- CLI orchestration → Aggregated JSON: writes JSON (evidence: `README.md`)
