# thodark/astez architecture

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

- Interactive diagram: https://gitdiagram.com/thodark/astez
- Repository: https://github.com/thodark/astez

## Overview

Astez is a general-purpose language toolchain: users write `.az` programs and can run them on a register VM or build native AOT executables. The graph preserves the documented stages, runtime capabilities, and IDE support. Many implementation links are only implied by the README or repository structure; those are dashed and unverified rather than asserted as inspected calls.

Main entry points: [`crates/astez-cli/src/main.rs`](https://github.com/thodark/astez/blob/main/crates/astez-cli/src/main.rs) (vyloz CLI), [`crates/astez-vm/src/vm.rs`](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/vm.rs) (Register VM), [`crates/astez-vm/src/stdlib.rs`](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/stdlib.rs) (Core standard library), [`crates/astez-parser/src/loader.rs`](https://github.com/thodark/astez/blob/main/crates/astez-parser/src/loader.rs) (Parser and loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Language Front End"]
  node_lexer["Lexer and tokens<br/>[lib.rs]"]
  node_parser["Parser and loader<br/>[loader.rs]"]
  node_ast["Syntax tree<br/>[ast.rs]"]
  node_formatter["Source formatter<br/>[fmt.rs]"]
end

subgraph group_analysis["Analysis and Diagnostics"]
  node_typecheck["Type checker<br/>[checker.rs]"]
  node_diagnostics["Diagnostics and spans<br/>[source_map.rs]"]
end

subgraph group_execution["Execution and Runtime"]
  node_bytecompiler["Bytecode compiler<br/>[compiler.rs]"]
  node_bytecode["Bytecode chunks and ISA<br/>[chunk.rs]"]
  node_vm["Register VM<br/>[vm.rs]"]
  node_values["NaN-boxed values<br/>[value.rs]"]
  node_heap[("Heap, arenas, and GC<br/>[heap.rs]")]
  node_stdlib["Core standard library<br/>[stdlib.rs]"]
  node_stdextra["OS, HTTP, and JSON<br/>[std_extra.rs]"]
  node_concurrency["Threads and channels<br/>[concurrency.rs]"]
end

subgraph group_native["Native AOT"]
  node_nativeemit["C code generation<br/>[emit.rs]"]
  node_nativebuild["Native build orchestration<br/>[build.rs]"]
  node_cruntime["Generated C runtime<br/>[runtime_c.rs]"]
end

subgraph group_developer["Developer Tools"]
  node_cli["vyloz CLI<br/>[main.rs]"]
  node_lsp["Language server<br/>[lib.rs]"]
  node_vscode["VS Code extension<br/>[extension.js]"]
end

node_programmer(("Astez programmer"))
node_source["Astez source"]
node_nativebinary["Native executable"]
node_ccompiler["C compiler"]

node_programmer -.->|"invokes"| node_cli
node_programmer -.->|"writes"| node_source
node_source -->|"runs or builds"| node_cli
node_cli -.->|"starts processing"| node_lexer
node_lexer -.->|"supplies tokens"| node_parser
node_parser -.->|"produces tree"| node_ast
node_parser -.->|"checks program"| node_typecheck
node_typecheck -.->|"reports issues"| node_diagnostics
node_cli -.->|"compiles for VM"| node_bytecompiler
node_bytecompiler -->|"emits instructions"| node_bytecode
node_bytecode -.->|"executes"| node_vm
node_vm -->|"uses"| node_values
node_vm -->|"allocates and collects"| node_heap
node_vm -->|"dispatches builtins"| node_stdlib
node_stdlib -->|"accesses objects"| node_heap
node_stdlib -->|"uses extended builtins"| node_stdextra
node_stdlib -->|"uses channels"| node_concurrency
node_concurrency -->|"transfers values"| node_heap
node_cli -.->|"requests AOT"| node_nativeemit
node_nativeemit -->|"includes runtime"| node_cruntime
node_nativeemit -.->|"provides generated C"| node_nativebuild
node_nativebuild -->|"invokes compiler"| node_ccompiler
node_ccompiler -->|"produces executable"| node_nativebinary
node_cli -->|"formats source"| node_formatter
node_programmer -->|"requests IDE features"| node_lsp
node_vscode -.->|"connects to"| node_lsp

click node_cli "https://github.com/thodark/astez/blob/main/crates/astez-cli/src/main.rs"
click node_lexer "https://github.com/thodark/astez/blob/main/crates/astez-lexer/src/lib.rs"
click node_parser "https://github.com/thodark/astez/blob/main/crates/astez-parser/src/loader.rs"
click node_ast "https://github.com/thodark/astez/blob/main/crates/astez-ast/src/ast.rs"
click node_formatter "https://github.com/thodark/astez/blob/main/crates/astez-ast/src/fmt.rs"
click node_typecheck "https://github.com/thodark/astez/blob/main/crates/astez-types/src/checker.rs"
click node_diagnostics "https://github.com/thodark/astez/blob/main/crates/astez-diagnostics/src/source_map.rs"
click node_bytecompiler "https://github.com/thodark/astez/blob/main/crates/astez-bytecode/src/compiler.rs"
click node_bytecode "https://github.com/thodark/astez/blob/main/crates/astez-bytecode/src/chunk.rs"
click node_vm "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/vm.rs"
click node_values "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/value.rs"
click node_heap "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/heap.rs"
click node_stdlib "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/stdlib.rs"
click node_stdextra "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/std_extra.rs"
click node_concurrency "https://github.com/thodark/astez/blob/main/crates/astez-vm/src/concurrency.rs"
click node_nativeemit "https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/emit.rs"
click node_nativebuild "https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/build.rs"
click node_cruntime "https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/runtime_c.rs"
click node_lsp "https://github.com/thodark/astez/blob/main/crates/astez-lsp/src/lib.rs"
click node_vscode "https://github.com/thodark/astez/blob/main/editors/vscode-astez/extension.js"

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_lexer,node_parser,node_ast,node_formatter toneBlue
class node_typecheck,node_diagnostics toneAmber
class node_bytecompiler,node_bytecode,node_vm,node_values,node_heap,node_stdlib,node_stdextra,node_concurrency toneMint
class node_nativeemit,node_nativebuild,node_cruntime toneRose
class node_cli,node_lsp,node_vscode,node_programmer,node_source,node_nativebinary,node_ccompiler toneIndigo
```

## Components

### Language Front End

- [Lexer and tokens](https://github.com/thodark/astez/blob/main/crates/astez-lexer/src/lib.rs): `crates/astez-lexer/src/lib.rs`
- [Parser and loader](https://github.com/thodark/astez/blob/main/crates/astez-parser/src/loader.rs): `crates/astez-parser/src/loader.rs`
- [Syntax tree](https://github.com/thodark/astez/blob/main/crates/astez-ast/src/ast.rs): `crates/astez-ast/src/ast.rs`
- [Source formatter](https://github.com/thodark/astez/blob/main/crates/astez-ast/src/fmt.rs): `crates/astez-ast/src/fmt.rs`

### Analysis and Diagnostics

- [Type checker](https://github.com/thodark/astez/blob/main/crates/astez-types/src/checker.rs): `crates/astez-types/src/checker.rs`
- [Diagnostics and spans](https://github.com/thodark/astez/blob/main/crates/astez-diagnostics/src/source_map.rs): `crates/astez-diagnostics/src/source_map.rs`

### Execution and Runtime

- [Bytecode compiler](https://github.com/thodark/astez/blob/main/crates/astez-bytecode/src/compiler.rs): `crates/astez-bytecode/src/compiler.rs`
- [Bytecode chunks and ISA](https://github.com/thodark/astez/blob/main/crates/astez-bytecode/src/chunk.rs): `crates/astez-bytecode/src/chunk.rs`
- [Register VM](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/vm.rs): `crates/astez-vm/src/vm.rs`
- [NaN-boxed values](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/value.rs): `crates/astez-vm/src/value.rs`
- [Heap, arenas, and GC](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/heap.rs): `crates/astez-vm/src/heap.rs`
- [Core standard library](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/stdlib.rs): `crates/astez-vm/src/stdlib.rs`
- [OS, HTTP, and JSON](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/std_extra.rs): `crates/astez-vm/src/std_extra.rs`
- [Threads and channels](https://github.com/thodark/astez/blob/main/crates/astez-vm/src/concurrency.rs): `crates/astez-vm/src/concurrency.rs`

### Native AOT

- [C code generation](https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/emit.rs): `crates/astez-codegen/src/emit.rs`
- [Native build orchestration](https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/build.rs): `crates/astez-codegen/src/build.rs`
- [Generated C runtime](https://github.com/thodark/astez/blob/main/crates/astez-codegen/src/runtime_c.rs): `crates/astez-codegen/src/runtime_c.rs`

### Developer Tools

- [vyloz CLI](https://github.com/thodark/astez/blob/main/crates/astez-cli/src/main.rs): `crates/astez-cli/src/main.rs`
- [Language server](https://github.com/thodark/astez/blob/main/crates/astez-lsp/src/lib.rs): `crates/astez-lsp/src/lib.rs`
- [VS Code extension](https://github.com/thodark/astez/blob/main/editors/vscode-astez/extension.js): `editors/vscode-astez/extension.js`

### Other components

- **Astez programmer**
- **Astez source**
- **Native executable**
- **C compiler**

## Connections

- Astez programmer → vyloz CLI: invokes
- Astez programmer → Astez source: writes
- Astez source → vyloz CLI: runs or builds (evidence: `README.md`)
- vyloz CLI → Lexer and tokens: starts processing
- Lexer and tokens → Parser and loader: supplies tokens
- Parser and loader → Syntax tree: produces tree
- Parser and loader → Type checker: checks program
- Type checker → Diagnostics and spans: reports issues
- vyloz CLI → Bytecode compiler: compiles for VM
- Bytecode compiler → Bytecode chunks and ISA: emits instructions (evidence: `crates/astez-bytecode/src/compiler.rs`)
- Bytecode chunks and ISA → Register VM: executes
- Register VM → NaN-boxed values: uses (evidence: `crates/astez-vm/src/vm.rs`)
- Register VM → Heap, arenas, and GC: allocates and collects (evidence: `crates/astez-vm/src/vm.rs`)
- Register VM → Core standard library: dispatches builtins (evidence: `crates/astez-vm/src/vm.rs`)
- Core standard library → Heap, arenas, and GC: accesses objects (evidence: `crates/astez-vm/src/stdlib.rs`)
- Core standard library → OS, HTTP, and JSON: uses extended builtins (evidence: `crates/astez-vm/src/stdlib.rs`)
- Core standard library → Threads and channels: uses channels (evidence: `crates/astez-vm/src/stdlib.rs`)
- Threads and channels → Heap, arenas, and GC: transfers values (evidence: `crates/astez-vm/src/concurrency.rs`)
- vyloz CLI → C code generation: requests AOT
- C code generation → Generated C runtime: includes runtime (evidence: `crates/astez-codegen/src/emit.rs`)
- C code generation → Native build orchestration: provides generated C (evidence: `crates/astez-codegen/src/build.rs`)
- Native build orchestration → C compiler: invokes compiler (evidence: `crates/astez-codegen/src/build.rs`)
- C compiler → Native executable: produces executable (evidence: `README.md`)
- vyloz CLI → Source formatter: formats source (evidence: `README.md`)
- Astez programmer → Language server: requests IDE features (evidence: `README.md`)
- VS Code extension → Language server: connects to
