# treymouledoux/grid9 architecture

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

- Interactive diagram: https://gitdiagram.com/treymouledoux/grid9
- Repository: https://github.com/treymouledoux/grid9

## Overview

Grid9 is a Rust interpreter for an esoteric language whose state is a 3×3 binary grid. The primary workflow is to invoke the CLI with a script, load its optional TOML settings, preprocess and validate the source, then execute it and emit glyph-based output. The CLI also exposes glyph conversion, documentation, version/about, and cleanup commands. The README documents bundled examples and language documentation. Source excerpts establish preprocessing, configuration, storage, and glyph behavior; some CLI dispatch details are omitted, so those links are marked unverified.

Main entry points: [`src/main.rs`](https://github.com/treymouledoux/grid9/blob/main/src/main.rs) (CLI commands), [`src/file_man.rs`](https://github.com/treymouledoux/grid9/blob/main/src/file_man.rs) (Data manager), [`src/language/preprocessor.rs`](https://github.com/treymouledoux/grid9/blob/main/src/language/preprocessor.rs) (Preprocessor), [`src/language/interpreter.rs`](https://github.com/treymouledoux/grid9/blob/main/src/language/interpreter.rs) (Grid interpreter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_commands["CLI commands<br/>[main.rs]"]
end

subgraph group_language["Language runtime"]
  node_settings["Script settings<br/>[config.rs]"]
  node_preprocessor["Preprocessor<br/>[preprocessor.rs]"]
  node_interpreter["Grid interpreter<br/>[interpreter.rs]"]
  node_glyphs["Glyph codec<br/>[glyphs.rs]"]
end

subgraph group_data["User data"]
  node_file_manager["Data manager<br/>[file_man.rs]"]
  node_data_store[("User data")]
  node_cache[("Preprocessor cache")]
end

subgraph group_resources["Bundled resources"]
  node_documentation["Language documentation"]
  node_examples["Example scripts"]
end

node_user(("CLI user"))

node_user -->|"runs commands"| node_commands
node_commands -->|"loads settings"| node_settings
node_commands -->|"preprocesses source"| node_preprocessor
node_commands -.->|"runs processed code"| node_interpreter
node_commands -.->|"converts glyphs"| node_glyphs
node_interpreter -->|"decodes grid"| node_glyphs
node_preprocessor -->|"writes cached code"| node_cache
node_commands -->|"initializes data"| node_file_manager
node_file_manager -->|"creates and refreshes"| node_data_store
node_file_manager -->|"installs resources"| node_documentation
node_file_manager -->|"installs resources"| node_examples
node_commands -.->|"opens documentation"| node_documentation
node_commands -->|"selects examples"| node_examples

click node_commands "https://github.com/treymouledoux/grid9/blob/main/src/main.rs"
click node_settings "https://github.com/treymouledoux/grid9/blob/main/src/language/config.rs"
click node_preprocessor "https://github.com/treymouledoux/grid9/blob/main/src/language/preprocessor.rs"
click node_interpreter "https://github.com/treymouledoux/grid9/blob/main/src/language/interpreter.rs"
click node_glyphs "https://github.com/treymouledoux/grid9/blob/main/src/language/glyphs.rs"
click node_file_manager "https://github.com/treymouledoux/grid9/blob/main/src/file_man.rs"
click node_documentation "https://github.com/treymouledoux/grid9/tree/main/src/components/documentation"
click node_examples "https://github.com/treymouledoux/grid9/tree/main/src/components/examples"

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_commands,node_user toneBlue
class node_settings,node_preprocessor,node_interpreter,node_glyphs toneAmber
class node_file_manager,node_data_store,node_cache toneMint
class node_documentation,node_examples toneRose
```

## Components

### CLI

- [CLI commands](https://github.com/treymouledoux/grid9/blob/main/src/main.rs): `src/main.rs`

### Language runtime

- [Script settings](https://github.com/treymouledoux/grid9/blob/main/src/language/config.rs): `src/language/config.rs`
- [Preprocessor](https://github.com/treymouledoux/grid9/blob/main/src/language/preprocessor.rs): `src/language/preprocessor.rs`
- [Grid interpreter](https://github.com/treymouledoux/grid9/blob/main/src/language/interpreter.rs): `src/language/interpreter.rs`
- [Glyph codec](https://github.com/treymouledoux/grid9/blob/main/src/language/glyphs.rs): `src/language/glyphs.rs`

### User data

- [Data manager](https://github.com/treymouledoux/grid9/blob/main/src/file_man.rs): `src/file_man.rs`
- **User data**
- **Preprocessor cache**

### Bundled resources

- [Language documentation](https://github.com/treymouledoux/grid9/tree/main/src/components/documentation): `src/components/documentation`
- [Example scripts](https://github.com/treymouledoux/grid9/tree/main/src/components/examples): `src/components/examples`

### Other components

- **CLI user**

## Connections

- CLI user → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Script settings: loads settings (evidence: `src/main.rs`)
- CLI commands → Preprocessor: preprocesses source (evidence: `src/main.rs`)
- CLI commands → Grid interpreter: runs processed code
- CLI commands → Glyph codec: converts glyphs
- Grid interpreter → Glyph codec: decodes grid (evidence: `src/language/interpreter.rs`)
- Preprocessor → Preprocessor cache: writes cached code (evidence: `src/language/preprocessor.rs`)
- CLI commands → Data manager: initializes data (evidence: `src/main.rs`)
- Data manager → User data: creates and refreshes (evidence: `src/file_man.rs`)
- Data manager → Language documentation: installs resources (evidence: `src/file_man.rs`)
- Data manager → Example scripts: installs resources (evidence: `src/file_man.rs`)
- CLI commands → Language documentation: opens documentation (evidence: `README.md`)
- CLI commands → Example scripts: selects examples (evidence: `src/main.rs`)
