# iyilang/iyi architecture

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

- Interactive diagram: https://gitdiagram.com/iyilang/iyi
- Repository: https://github.com/iyilang/iyi

## Overview

iyi is a Crystal-compatible programming language and compiler, with declaration-based module compilation as its defining workflow: users invoke the compiler, which compiles modules against imported declarations and can reuse module artifacts containing declarations and machine code. The README also documents LLVM native output, Crystal compatibility, concurrency, dependencies, and an LSP/editor experience. Compiler implementation details were not excerpted, so stage-level links beyond those documented are omitted; dashed links mark plausible but unverified integration points.

Main entry points: [`src/compiler/command`](https://github.com/iyilang/iyi/tree/master/src/compiler/command) (Compiler CLI), [`src/compiler/semantic`](https://github.com/iyilang/iyi/tree/master/src/compiler/semantic) (Semantic analysis), [`src/compiler/backend/llvm`](https://github.com/iyilang/iyi/tree/master/src/compiler/backend/llvm) (LLVM backend), [`src/compiler/artifact`](https://github.com/iyilang/iyi/tree/master/src/compiler/artifact) (Module artifacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler"]
  node_cli["Compiler CLI"]
  node_syntax["Syntax front end"]
  node_semantic["Semantic analysis"]
  node_normalize["IR normalization"]
  node_ir["Intermediate representation"]
  node_optimization["IR optimization"]
  node_llvm["LLVM backend"]
  node_native["Native backend"]
end

subgraph group_modules["Modules and tools"]
  node_artifacts["Module artifacts"]
  node_module_loader["Module loader"]
  node_dependencies["Dependency management"]
end

subgraph group_runtime["Runtime and libraries"]
  node_runtime["Language runtime"]
  node_concurrency["Concurrency"]
  node_stdlib["Standard library"]
  node_wasm_host["Wasm host bindings<br/>[iyi.mjs]"]
end

subgraph group_experience["Developer experience"]
  node_lsp["Language server"]
  node_vscode["VS Code client<br/>[extension.js]"]
end

node_developer(("Developer"))
node_llvm_external["LLVM"]
node_crystal_external["Crystal ecosystem"]
node_editor_user(("Editor user"))

node_developer -->|"invokes"| node_cli
node_cli -->|"emits or uses"| node_artifacts
node_artifacts -->|"supplies declarations"| node_module_loader
node_cli -->|"compiles via"| node_llvm
node_llvm -->|"generates code with"| node_llvm_external
node_cli -->|"supports Crystal"| node_crystal_external
node_editor_user -->|"edits code"| node_vscode
node_vscode -->|"starts"| node_lsp
node_cli -->|"resolves and pins"| node_dependencies
node_cli -->|"compiles support for"| node_concurrency
node_cli -.->|"targets freestanding wasm"| node_wasm_host
node_semantic -.->|"checks declarations from"| node_artifacts
node_syntax -.->|"feeds analysis"| node_semantic
node_semantic -.->|"lowers program"| node_normalize
node_normalize -.->|"produces IR"| node_ir
node_ir -.->|"is optimized by"| node_optimization
node_optimization -.->|"feeds backend"| node_llvm
node_runtime -.->|"supports library"| node_stdlib

click node_cli "https://github.com/iyilang/iyi/tree/master/src/compiler/command"
click node_syntax "https://github.com/iyilang/iyi/tree/master/src/compiler/syntax"
click node_semantic "https://github.com/iyilang/iyi/tree/master/src/compiler/semantic"
click node_normalize "https://github.com/iyilang/iyi/tree/master/src/compiler/crystal"
click node_ir "https://github.com/iyilang/iyi/tree/master/src/compiler/ir"
click node_optimization "https://github.com/iyilang/iyi/tree/master/src/compiler/ir/opt"
click node_llvm "https://github.com/iyilang/iyi/tree/master/src/compiler/backend/llvm"
click node_native "https://github.com/iyilang/iyi/tree/master/src/compiler/native"
click node_artifacts "https://github.com/iyilang/iyi/tree/master/src/compiler/artifact"
click node_module_loader "https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/loader"
click node_dependencies "https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/mod"
click node_lsp "https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/lsp"
click node_vscode "https://github.com/iyilang/iyi/blob/master/editors/vscode/extension.js"
click node_runtime "https://github.com/iyilang/iyi/tree/master/src/crystal"
click node_concurrency "https://github.com/iyilang/iyi/tree/master/src/fiber"
click node_stdlib "https://github.com/iyilang/iyi/tree/master/src"
click node_wasm_host "https://github.com/iyilang/iyi/blob/master/src/iyi/wasm/iyi.mjs"

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,node_syntax,node_semantic,node_normalize,node_ir,node_optimization,node_llvm,node_native,node_editor_user toneBlue
class node_artifacts,node_module_loader,node_dependencies toneAmber
class node_runtime,node_concurrency,node_stdlib,node_wasm_host toneMint
class node_lsp,node_vscode toneRose
class node_developer,node_llvm_external,node_crystal_external toneIndigo
```

## Components

### Compiler

- [Compiler CLI](https://github.com/iyilang/iyi/tree/master/src/compiler/command): `src/compiler/command`
- [Syntax front end](https://github.com/iyilang/iyi/tree/master/src/compiler/syntax): `src/compiler/syntax`
- [Semantic analysis](https://github.com/iyilang/iyi/tree/master/src/compiler/semantic): `src/compiler/semantic`
- [IR normalization](https://github.com/iyilang/iyi/tree/master/src/compiler/crystal): `src/compiler/crystal`
- [Intermediate representation](https://github.com/iyilang/iyi/tree/master/src/compiler/ir): `src/compiler/ir`
- [IR optimization](https://github.com/iyilang/iyi/tree/master/src/compiler/ir/opt): `src/compiler/ir/opt`
- [LLVM backend](https://github.com/iyilang/iyi/tree/master/src/compiler/backend/llvm): `src/compiler/backend/llvm`
- [Native backend](https://github.com/iyilang/iyi/tree/master/src/compiler/native): `src/compiler/native`

### Modules and tools

- [Module artifacts](https://github.com/iyilang/iyi/tree/master/src/compiler/artifact): `src/compiler/artifact`
- [Module loader](https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/loader): `src/compiler/iyi/loader`
- [Dependency management](https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/mod): `src/compiler/iyi/mod`

### Runtime and libraries

- [Language runtime](https://github.com/iyilang/iyi/tree/master/src/crystal): `src/crystal`
- [Concurrency](https://github.com/iyilang/iyi/tree/master/src/fiber): `src/fiber`
- [Standard library](https://github.com/iyilang/iyi/tree/master/src): `src`
- [Wasm host bindings](https://github.com/iyilang/iyi/blob/master/src/iyi/wasm/iyi.mjs): `src/iyi/wasm/iyi.mjs`

### Developer experience

- [Language server](https://github.com/iyilang/iyi/tree/master/src/compiler/iyi/lsp): `src/compiler/iyi/lsp`
- [VS Code client](https://github.com/iyilang/iyi/blob/master/editors/vscode/extension.js): `editors/vscode/extension.js`

### Other components

- **Developer**
- **LLVM**
- **Crystal ecosystem**
- **Editor user**

## Connections

- Developer → Compiler CLI: invokes (evidence: `README.md`)
- Compiler CLI → Module artifacts: emits or uses (evidence: `README.md`)
- Module artifacts → Module loader: supplies declarations (evidence: `README.md`)
- Compiler CLI → LLVM backend: compiles via (evidence: `README.md`)
- LLVM backend → LLVM: generates code with (evidence: `README.md`)
- Compiler CLI → Crystal ecosystem: supports Crystal (evidence: `README.md`)
- Editor user → VS Code client: edits code (evidence: `editors/vscode/extension.js`)
- VS Code client → Language server: starts (evidence: `editors/vscode/extension.js`)
- Compiler CLI → Dependency management: resolves and pins (evidence: `README.md`)
- Compiler CLI → Concurrency: compiles support for (evidence: `README.md`)
- Compiler CLI → Wasm host bindings: targets freestanding wasm
- Semantic analysis → Module artifacts: checks declarations from
- Syntax front end → Semantic analysis: feeds analysis
- Semantic analysis → IR normalization: lowers program
- IR normalization → Intermediate representation: produces IR
- Intermediate representation → IR optimization: is optimized by
- IR optimization → LLVM backend: feeds backend
- Language runtime → Standard library: supports library
