# muaraai/mora architecture

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

- Interactive diagram: https://gitdiagram.com/muaraai/mora
- Repository: https://github.com/muaraai/mora

## Overview

Mora is an AI-oriented programming language and toolchain. A user invokes its CLI on `.mr` source; the shared front end tokenizes, parses, resolves imports, and checks types/shapes before execution or compilation. The main runtime branches are the interpreter, bytecode VM, and native C99 AOT path. Tensor/autograd, GGUF, agent and standard-library capabilities are represented alongside editor-facing LSP and formatting. Some subsystem edges rely on README descriptions because their implementation files were not excerpted; unsampled details are not inferred.

Main entry points: [`src/cli.rs`](https://github.com/muaraai/mora/blob/main/src/cli.rs) (Mora CLI), [`src/interpreter.rs`](https://github.com/muaraai/mora/blob/main/src/interpreter.rs) (Tree-Walking Interpreter), [`src/ir.rs`](https://github.com/muaraai/mora/blob/main/src/ir.rs) (Mora IR), [`src/lsp.rs`](https://github.com/muaraai/mora/blob/main/src/lsp.rs) (Language Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Language Front End"]
  node_lexer["Lexer<br/>[lexer.rs]"]
  node_parser["Parser and AST<br/>[parser.rs]"]
  node_modules["Import Resolver<br/>[module_loader.rs]"]
  node_checker["Type and Shape Checker<br/>[checker.rs]"]
  node_diagnostics["Diagnostics<br/>[diagnostic.rs]"]
end

subgraph group_runtime["Execution Runtime"]
  node_interpreter["Tree-Walking Interpreter<br/>[interpreter.rs]"]
  node_stdlib["Agent and I/O Runtime<br/>[runtime.rs]"]
  node_python["Python Bridge<br/>[py_bridge.rs]"]
  node_gguf["GGUF Weights and Checkpoints<br/>[gguf.rs]"]
  node_bundler["Standalone Bundler<br/>[bundler.rs]"]
end

subgraph group_compute["Tensor and Compilation"]
  node_tensor["Tensor and Transformer Ops<br/>[tensor.rs]"]
  node_autograd["Reverse-Mode Autograd<br/>[autograd.rs]"]
  node_ir["Mora IR<br/>[ir.rs]"]
  node_arena["Arena Memory Planner<br/>[arena_planner.rs]"]
  node_vm["Bytecode VM<br/>[vm.rs]"]
  node_native["Native C99 Generator<br/>[codegen_native.rs]"]
end

subgraph group_tooling["Developer Tooling"]
  node_cli["Mora CLI<br/>[cli.rs]"]
  node_lsp["Language Server<br/>[lsp.rs]"]
  node_formatter["Source Formatter<br/>[fmt.rs]"]
end

node_user(("Language User"))

node_user -->|"invokes"| node_cli
node_cli -->|"starts front end"| node_lexer
node_lexer -->|"tokenizes for"| node_parser
node_parser -->|"provides imports"| node_modules
node_cli -->|"resolves imports"| node_modules
node_cli -->|"checks program"| node_checker
node_checker -->|"reports errors"| node_diagnostics
node_cli -->|"runs source"| node_interpreter
node_interpreter -->|"dispatches runtime calls"| node_stdlib
node_interpreter -->|"bridges Python calls"| node_python
node_interpreter -->|"uses GGUF operations"| node_gguf
node_interpreter -->|"evaluates tensor ops"| node_tensor
node_interpreter -->|"dispatches autograd"| node_autograd
node_tensor -->|"stores gradient references"| node_autograd
node_gguf -->|"loads tensor data"| node_tensor
node_cli -->|"lowers compute code"| node_ir
node_ir -->|"plans tensor memory"| node_arena
node_ir -->|"executes as bytecode"| node_vm
node_cli -->|"selects VM mode"| node_vm
node_cli -->|"selects native mode"| node_native
node_native -->|"emits from IR"| node_ir
node_cli -->|"builds standalone binary"| node_bundler
node_cli -->|"serves language tooling"| node_lsp
node_cli -->|"formats source"| node_formatter
node_lsp -->|"checks editor text"| node_checker
node_lsp -->|"resolves editor imports"| node_modules
node_formatter -->|"parses for formatting"| node_parser

click node_cli "https://github.com/muaraai/mora/blob/main/src/cli.rs"
click node_lexer "https://github.com/muaraai/mora/blob/main/src/lexer.rs"
click node_parser "https://github.com/muaraai/mora/blob/main/src/parser.rs"
click node_modules "https://github.com/muaraai/mora/blob/main/src/module_loader.rs"
click node_checker "https://github.com/muaraai/mora/blob/main/src/checker.rs"
click node_diagnostics "https://github.com/muaraai/mora/blob/main/src/diagnostic.rs"
click node_interpreter "https://github.com/muaraai/mora/blob/main/src/interpreter.rs"
click node_stdlib "https://github.com/muaraai/mora/blob/main/src/runtime.rs"
click node_python "https://github.com/muaraai/mora/blob/main/src/py_bridge.rs"
click node_gguf "https://github.com/muaraai/mora/blob/main/src/gguf.rs"
click node_tensor "https://github.com/muaraai/mora/blob/main/src/tensor.rs"
click node_autograd "https://github.com/muaraai/mora/blob/main/src/autograd.rs"
click node_ir "https://github.com/muaraai/mora/blob/main/src/ir.rs"
click node_arena "https://github.com/muaraai/mora/blob/main/src/arena_planner.rs"
click node_vm "https://github.com/muaraai/mora/blob/main/src/vm.rs"
click node_native "https://github.com/muaraai/mora/blob/main/src/codegen_native.rs"
click node_bundler "https://github.com/muaraai/mora/blob/main/src/bundler.rs"
click node_lsp "https://github.com/muaraai/mora/blob/main/src/lsp.rs"
click node_formatter "https://github.com/muaraai/mora/blob/main/src/fmt.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_lexer,node_parser,node_modules,node_checker,node_diagnostics,node_user toneBlue
class node_interpreter,node_stdlib,node_python,node_gguf,node_bundler toneAmber
class node_tensor,node_autograd,node_ir,node_arena,node_vm,node_native toneMint
class node_cli,node_lsp,node_formatter toneRose
```

## Components

### Language Front End

- [Lexer](https://github.com/muaraai/mora/blob/main/src/lexer.rs): `src/lexer.rs`
- [Parser and AST](https://github.com/muaraai/mora/blob/main/src/parser.rs): `src/parser.rs`
- [Import Resolver](https://github.com/muaraai/mora/blob/main/src/module_loader.rs): `src/module_loader.rs`
- [Type and Shape Checker](https://github.com/muaraai/mora/blob/main/src/checker.rs): `src/checker.rs`
- [Diagnostics](https://github.com/muaraai/mora/blob/main/src/diagnostic.rs): `src/diagnostic.rs`

### Execution Runtime

- [Tree-Walking Interpreter](https://github.com/muaraai/mora/blob/main/src/interpreter.rs): `src/interpreter.rs`
- [Agent and I/O Runtime](https://github.com/muaraai/mora/blob/main/src/runtime.rs): `src/runtime.rs`
- [Python Bridge](https://github.com/muaraai/mora/blob/main/src/py_bridge.rs): `src/py_bridge.rs`
- [GGUF Weights and Checkpoints](https://github.com/muaraai/mora/blob/main/src/gguf.rs): `src/gguf.rs`
- [Standalone Bundler](https://github.com/muaraai/mora/blob/main/src/bundler.rs): `src/bundler.rs`

### Tensor and Compilation

- [Tensor and Transformer Ops](https://github.com/muaraai/mora/blob/main/src/tensor.rs): `src/tensor.rs`
- [Reverse-Mode Autograd](https://github.com/muaraai/mora/blob/main/src/autograd.rs): `src/autograd.rs`
- [Mora IR](https://github.com/muaraai/mora/blob/main/src/ir.rs): `src/ir.rs`
- [Arena Memory Planner](https://github.com/muaraai/mora/blob/main/src/arena_planner.rs): `src/arena_planner.rs`
- [Bytecode VM](https://github.com/muaraai/mora/blob/main/src/vm.rs): `src/vm.rs`
- [Native C99 Generator](https://github.com/muaraai/mora/blob/main/src/codegen_native.rs): `src/codegen_native.rs`

### Developer Tooling

- [Mora CLI](https://github.com/muaraai/mora/blob/main/src/cli.rs): `src/cli.rs`
- [Language Server](https://github.com/muaraai/mora/blob/main/src/lsp.rs): `src/lsp.rs`
- [Source Formatter](https://github.com/muaraai/mora/blob/main/src/fmt.rs): `src/fmt.rs`

### Other components

- **Language User**

## Connections

- Language User → Mora CLI: invokes (evidence: `README.md`)
- Mora CLI → Lexer: starts front end (evidence: `src/cli.rs`)
- Lexer → Parser and AST: tokenizes for (evidence: `src/parser.rs`)
- Parser and AST → Import Resolver: provides imports (evidence: `src/module_loader.rs`)
- Mora CLI → Import Resolver: resolves imports (evidence: `README.md`)
- Mora CLI → Type and Shape Checker: checks program (evidence: `src/cli.rs`)
- Type and Shape Checker → Diagnostics: reports errors (evidence: `src/checker.rs`)
- Mora CLI → Tree-Walking Interpreter: runs source (evidence: `README.md`)
- Tree-Walking Interpreter → Agent and I/O Runtime: dispatches runtime calls (evidence: `src/interpreter.rs`)
- Tree-Walking Interpreter → Python Bridge: bridges Python calls (evidence: `src/interpreter.rs`)
- Tree-Walking Interpreter → GGUF Weights and Checkpoints: uses GGUF operations (evidence: `src/interpreter.rs`)
- Tree-Walking Interpreter → Tensor and Transformer Ops: evaluates tensor ops (evidence: `src/interpreter.rs`)
- Tree-Walking Interpreter → Reverse-Mode Autograd: dispatches autograd (evidence: `src/interpreter.rs`)
- Tensor and Transformer Ops → Reverse-Mode Autograd: stores gradient references (evidence: `src/tensor.rs`)
- GGUF Weights and Checkpoints → Tensor and Transformer Ops: loads tensor data (evidence: `src/gguf.rs`)
- Mora CLI → Mora IR: lowers compute code (evidence: `README.md`)
- Mora IR → Arena Memory Planner: plans tensor memory (evidence: `src/arena_planner.rs`)
- Mora IR → Bytecode VM: executes as bytecode (evidence: `README.md`)
- Mora CLI → Bytecode VM: selects VM mode (evidence: `README.md`)
- Mora CLI → Native C99 Generator: selects native mode (evidence: `README.md`)
- Native C99 Generator → Mora IR: emits from IR (evidence: `src/codegen_native.rs`)
- Mora CLI → Standalone Bundler: builds standalone binary (evidence: `README.md`)
- Mora CLI → Language Server: serves language tooling (evidence: `src/cli.rs`)
- Mora CLI → Source Formatter: formats source (evidence: `src/cli.rs`)
- Language Server → Type and Shape Checker: checks editor text (evidence: `src/lsp.rs`)
- Language Server → Import Resolver: resolves editor imports (evidence: `src/lsp.rs`)
- Source Formatter → Parser and AST: parses for formatting (evidence: `src/fmt.rs`)
