# star-ga/mind architecture

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

- Interactive diagram: https://gitdiagram.com/star-ga/mind
- Repository: https://github.com/star-ga/mind

## Overview

MIND is a deterministic programming language and compiler for tensor-oriented intelligent systems. Its main workflow is source input through parsing, type and shape analysis, verified IR, and backend output for execution or artifacts; optional autodiff augments that path. The repository also documents project build/run commands, source formatting and checks, and distributed pipeline abstractions. The README documents native-ELF self-hosting, but the relevant example sources are not present in this tree. Some subsystem links reflect documented behavior rather than inspected implementation details.

Main entry points: [`src/pipeline.rs`](https://github.com/star-ga/mind/blob/main/src/pipeline.rs) (Compile Pipeline), [`src/bin/mindc.rs`](https://github.com/star-ga/mind/blob/main/src/bin/mindc.rs) (Compiler CLI), [`src/project/mod.rs`](https://github.com/star-ga/mind/blob/main/src/project/mod.rs) (Project Builder), [`src/main.rs`](https://github.com/star-ga/mind/blob/main/src/main.rs) (Mind CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Language Front End"]
  node_parser["Parser<br/>[mod.rs]"]
  node_ast["AST<br/>[mod.rs]"]
  node_typecheck["Type Checker<br/>[mod.rs]"]
end

subgraph group_compiler["Compilation and Artifacts"]
  node_pipeline["Compile Pipeline<br/>[pipeline.rs]"]
  node_ir["Verified IR<br/>[mod.rs]"]
  node_optimizer["IR Optimizers<br/>[mod.rs]"]
  node_mlir["MLIR Backend<br/>[lowering.rs]"]
  node_native["Native Execution<br/>[cpu.rs]"]
  node_project["Project Builder<br/>[mod.rs]"]
  node_cache[("Build Cache<br/>[mod.rs]")]
  node_compact["Compact IR<br/>[mod.rs]"]
end

subgraph group_runtime["Execution and Tools"]
  node_mindc["Compiler CLI<br/>[mindc.rs]"]
  node_mind["Mind CLI<br/>[main.rs]"]
  node_eval["Evaluator<br/>[mod.rs]"]
  node_fmt["Formatter<br/>[mod.rs]"]
  node_check["Source Check<br/>[mod.rs]"]
end

subgraph group_tensor["Tensor and Distribution"]
  node_shapes["Shape Inference<br/>[engine.rs]"]
  node_autodiff["Autodiff<br/>[engine.rs]"]
  node_distributed["Distributed Ops<br/>[mod.rs]"]
end

subgraph group_interfaces["Interoperability"]
  node_ffi["C Interface<br/>[mod.rs]"]
  node_python["Python Bindings<br/>[python.rs]"]
end

node_user(("Engineer"))
node_result["Program or Artifact"]

node_user -->|"submits source"| node_mindc
node_user -->|"runs commands"| node_mind
node_mindc -->|"compiles source"| node_pipeline
node_mind -->|"parses eval input"| node_parser
node_mind -->|"evaluates program"| node_eval
node_mindc -->|"builds projects"| node_project
node_mindc -->|"formats source"| node_fmt
node_mindc -->|"checks source"| node_check
node_parser -->|"produces AST"| node_ast
node_typecheck -->|"checks tensor shapes"| node_shapes
node_pipeline -->|"parses source"| node_parser
node_pipeline -->|"checks types"| node_typecheck
node_pipeline -->|"lowers and verifies"| node_ir
node_pipeline -->|"canonicalizes IR"| node_optimizer
node_pipeline -.->|"builds gradients"| node_autodiff
node_pipeline -->|"lowers to MLIR"| node_mlir
node_mlir -->|"emits backend output"| node_result
node_pipeline -->|"serializes IR"| node_compact
node_project -->|"reads and writes"| node_cache
node_project -->|"compiles modules"| node_pipeline
node_project -->|"writes build artifact"| node_result
node_mind -.->|"executes program"| node_native
node_distributed -->|"defines pipeline stages"| node_result
node_ffi -->|"exposes C interface"| node_result
node_python -.->|"exposes Python bindings"| node_result

click node_mindc "https://github.com/star-ga/mind/blob/main/src/bin/mindc.rs"
click node_mind "https://github.com/star-ga/mind/blob/main/src/main.rs"
click node_parser "https://github.com/star-ga/mind/blob/main/src/parser/mod.rs"
click node_ast "https://github.com/star-ga/mind/blob/main/src/ast/mod.rs"
click node_typecheck "https://github.com/star-ga/mind/blob/main/src/type_checker/mod.rs"
click node_shapes "https://github.com/star-ga/mind/blob/main/src/shapes/engine.rs"
click node_pipeline "https://github.com/star-ga/mind/blob/main/src/pipeline.rs"
click node_ir "https://github.com/star-ga/mind/blob/main/src/ir/mod.rs"
click node_optimizer "https://github.com/star-ga/mind/blob/main/src/opt/mod.rs"
click node_autodiff "https://github.com/star-ga/mind/blob/main/src/autodiff/engine.rs"
click node_mlir "https://github.com/star-ga/mind/blob/main/src/mlir/lowering.rs"
click node_native "https://github.com/star-ga/mind/blob/main/src/exec/cpu.rs"
click node_project "https://github.com/star-ga/mind/blob/main/src/project/mod.rs"
click node_cache "https://github.com/star-ga/mind/blob/main/src/cache/mod.rs"
click node_compact "https://github.com/star-ga/mind/blob/main/src/ir/compact/v3/mod.rs"
click node_eval "https://github.com/star-ga/mind/blob/main/src/eval/mod.rs"
click node_fmt "https://github.com/star-ga/mind/blob/main/src/fmt/mod.rs"
click node_check "https://github.com/star-ga/mind/blob/main/src/check/mod.rs"
click node_distributed "https://github.com/star-ga/mind/blob/main/src/distributed/mod.rs"
click node_ffi "https://github.com/star-ga/mind/blob/main/src/ffi/mod.rs"
click node_python "https://github.com/star-ga/mind/blob/main/src/python.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_parser,node_ast,node_typecheck toneBlue
class node_pipeline,node_ir,node_optimizer,node_mlir,node_native,node_project,node_cache,node_compact toneAmber
class node_mindc,node_mind,node_eval,node_fmt,node_check toneMint
class node_shapes,node_autodiff,node_distributed toneRose
class node_ffi,node_python,node_user,node_result toneIndigo
```

## Components

### Language Front End

- [Parser](https://github.com/star-ga/mind/blob/main/src/parser/mod.rs): `src/parser/mod.rs`
- [AST](https://github.com/star-ga/mind/blob/main/src/ast/mod.rs): `src/ast/mod.rs`
- [Type Checker](https://github.com/star-ga/mind/blob/main/src/type_checker/mod.rs): `src/type_checker/mod.rs`

### Compilation and Artifacts

- [Compile Pipeline](https://github.com/star-ga/mind/blob/main/src/pipeline.rs): `src/pipeline.rs`
- [Verified IR](https://github.com/star-ga/mind/blob/main/src/ir/mod.rs): `src/ir/mod.rs`
- [IR Optimizers](https://github.com/star-ga/mind/blob/main/src/opt/mod.rs): `src/opt/mod.rs`
- [MLIR Backend](https://github.com/star-ga/mind/blob/main/src/mlir/lowering.rs): `src/mlir/lowering.rs`
- [Native Execution](https://github.com/star-ga/mind/blob/main/src/exec/cpu.rs): `src/exec/cpu.rs`
- [Project Builder](https://github.com/star-ga/mind/blob/main/src/project/mod.rs): `src/project/mod.rs`
- [Build Cache](https://github.com/star-ga/mind/blob/main/src/cache/mod.rs): `src/cache/mod.rs`
- [Compact IR](https://github.com/star-ga/mind/blob/main/src/ir/compact/v3/mod.rs): `src/ir/compact/v3/mod.rs`

### Execution and Tools

- [Compiler CLI](https://github.com/star-ga/mind/blob/main/src/bin/mindc.rs): `src/bin/mindc.rs`
- [Mind CLI](https://github.com/star-ga/mind/blob/main/src/main.rs): `src/main.rs`
- [Evaluator](https://github.com/star-ga/mind/blob/main/src/eval/mod.rs): `src/eval/mod.rs`
- [Formatter](https://github.com/star-ga/mind/blob/main/src/fmt/mod.rs): `src/fmt/mod.rs`
- [Source Check](https://github.com/star-ga/mind/blob/main/src/check/mod.rs): `src/check/mod.rs`

### Tensor and Distribution

- [Shape Inference](https://github.com/star-ga/mind/blob/main/src/shapes/engine.rs): `src/shapes/engine.rs`
- [Autodiff](https://github.com/star-ga/mind/blob/main/src/autodiff/engine.rs): `src/autodiff/engine.rs`
- [Distributed Ops](https://github.com/star-ga/mind/blob/main/src/distributed/mod.rs): `src/distributed/mod.rs`

### Interoperability

- [C Interface](https://github.com/star-ga/mind/blob/main/src/ffi/mod.rs): `src/ffi/mod.rs`
- [Python Bindings](https://github.com/star-ga/mind/blob/main/src/python.rs): `src/python.rs`

### Other components

- **Engineer**
- **Program or Artifact**

## Connections

- Engineer → Compiler CLI: submits source
- Engineer → Mind CLI: runs commands
- Compiler CLI → Compile Pipeline: compiles source
- Mind CLI → Parser: parses eval input
- Mind CLI → Evaluator: evaluates program
- Compiler CLI → Project Builder: builds projects
- Compiler CLI → Formatter: formats source
- Compiler CLI → Source Check: checks source
- Parser → AST: produces AST
- Type Checker → Shape Inference: checks tensor shapes
- Compile Pipeline → Parser: parses source
- Compile Pipeline → Type Checker: checks types
- Compile Pipeline → Verified IR: lowers and verifies
- Compile Pipeline → IR Optimizers: canonicalizes IR
- Compile Pipeline → Autodiff: builds gradients
- Compile Pipeline → MLIR Backend: lowers to MLIR
- MLIR Backend → Program or Artifact: emits backend output
- Compile Pipeline → Compact IR: serializes IR
- Project Builder → Build Cache: reads and writes
- Project Builder → Compile Pipeline: compiles modules
- Project Builder → Program or Artifact: writes build artifact
- Mind CLI → Native Execution: executes program
- Distributed Ops → Program or Artifact: defines pipeline stages
- C Interface → Program or Artifact: exposes C interface
- Python Bindings → Program or Artifact: exposes Python bindings
