# n0067h/astron architecture

> Architecture diagram of the GitHub repository n0067h/astron, 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/n0067h/astron
- Repository: https://github.com/n0067h/astron

## Overview

Astron is a space-themed programming language delivered as a command-line interpreter. A user supplies a program file and may select a launch; the CLI loads and merges imported files, then checks and executes the program, reporting load, type, or runtime errors. Its implementation separates tokenization, parsing into a shared AST, static checking, and interpretation. The excerpts establish the checker and interpreter calls from the CLI; lexer/parser call wiring is less directly visible, so those edges are marked unverified.

Main entry points: [`src/main.rs`](https://github.com/n0067h/astron/blob/master/src/main.rs) (CLI and loader), [`src/ast.rs`](https://github.com/n0067h/astron/blob/master/src/ast.rs) (Program AST), [`src/parser.rs`](https://github.com/n0067h/astron/blob/master/src/parser.rs) (Parser), [`src/lexer.rs`](https://github.com/n0067h/astron/blob/master/src/lexer.rs) (Tokenizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and loading"]
  node_cli["CLI and loader<br/>[main.rs]"]
end

subgraph group_frontend["Language frontend"]
  node_lexer["Tokenizer<br/>[lexer.rs]"]
  node_tokens["Token model<br/>[token.rs]"]
  node_parser["Parser<br/>[parser.rs]"]
  node_ast["Program AST<br/>[ast.rs]"]
end

subgraph group_analysis["Validation"]
  node_checker["Type checker<br/>[checker.rs]"]
end

subgraph group_runtime["Execution"]
  node_interpreter["Interpreter<br/>[interpreter.rs]"]
end

node_user(("Program author"))
node_terminal(("CLI output"))

node_user -->|"provides file"| node_cli
node_cli -.->|"tokenizes"| node_lexer
node_lexer -->|"creates tokens"| node_tokens
node_parser -->|"consumes tokens"| node_tokens
node_parser -->|"builds AST"| node_ast
node_cli -.->|"parses files"| node_parser
node_cli -->|"merges imports"| node_ast
node_cli -->|"checks program"| node_checker
node_checker -->|"validates"| node_ast
node_cli -->|"runs program"| node_interpreter
node_interpreter -->|"evaluates"| node_ast
node_cli -->|"reports results"| node_terminal

click node_cli "https://github.com/n0067h/astron/blob/master/src/main.rs"
click node_lexer "https://github.com/n0067h/astron/blob/master/src/lexer.rs"
click node_tokens "https://github.com/n0067h/astron/blob/master/src/token.rs"
click node_parser "https://github.com/n0067h/astron/blob/master/src/parser.rs"
click node_ast "https://github.com/n0067h/astron/blob/master/src/ast.rs"
click node_checker "https://github.com/n0067h/astron/blob/master/src/checker.rs"
click node_interpreter "https://github.com/n0067h/astron/blob/master/src/interpreter.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_cli toneBlue
class node_lexer,node_tokens,node_parser,node_ast toneAmber
class node_checker toneMint
class node_interpreter toneRose
class node_user,node_terminal toneIndigo
```

## Components

### CLI and loading

- [CLI and loader](https://github.com/n0067h/astron/blob/master/src/main.rs): `src/main.rs`

### Language frontend

- [Tokenizer](https://github.com/n0067h/astron/blob/master/src/lexer.rs): `src/lexer.rs`
- [Token model](https://github.com/n0067h/astron/blob/master/src/token.rs): `src/token.rs`
- [Parser](https://github.com/n0067h/astron/blob/master/src/parser.rs): `src/parser.rs`
- [Program AST](https://github.com/n0067h/astron/blob/master/src/ast.rs): `src/ast.rs`

### Validation

- [Type checker](https://github.com/n0067h/astron/blob/master/src/checker.rs): `src/checker.rs`

### Execution

- [Interpreter](https://github.com/n0067h/astron/blob/master/src/interpreter.rs): `src/interpreter.rs`

### Other components

- **Program author**
- **CLI output**

## Connections

- Program author → CLI and loader: provides file (evidence: `README.md`)
- CLI and loader → Tokenizer: tokenizes (evidence: `src/main.rs`)
- Tokenizer → Token model: creates tokens (evidence: `src/lexer.rs`)
- Parser → Token model: consumes tokens (evidence: `src/parser.rs`)
- Parser → Program AST: builds AST (evidence: `src/parser.rs`)
- CLI and loader → Parser: parses files (evidence: `src/main.rs`)
- CLI and loader → Program AST: merges imports (evidence: `src/main.rs`)
- CLI and loader → Type checker: checks program (evidence: `src/main.rs`)
- Type checker → Program AST: validates (evidence: `src/checker.rs`)
- CLI and loader → Interpreter: runs program (evidence: `src/main.rs`)
- Interpreter → Program AST: evaluates (evidence: `src/interpreter.rs`)
- CLI and loader → CLI output: reports results (evidence: `src/main.rs`)
