# betteriutinfoaix/algocompiler architecture

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

- Interactive diagram: https://gitdiagram.com/betteriutinfoaix/algocompiler
- Repository: https://github.com/betteriutinfoaix/algocompiler

## Overview

AlgoCompiler is a Rust implementation of the IUT Aix algorithmic language, offering direct execution and Python generation through both a CLI and a browser playground. The principal workflow reads source, tokenizes it, parses an AST, then either interprets the program or generates Python. The graph also shows the browser’s WASM-facing bridge and shared diagnostics. The bridge implementation was not excerpted, so its connections to the runtime backends are marked unverified.

Main entry points: [`AlgoCompiler/src/parser/mod.rs`](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/parser/mod.rs) (Parser), [`AlgoCompiler/src/main.rs`](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/main.rs) (CLI file entry), [`AlgoCompiler/src/lexer/mod.rs`](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/lexer/mod.rs) (Tokenizer), [`playground/src/lib.rs`](https://github.com/betteriutinfoaix/algocompiler/blob/main/playground/src/lib.rs) (WASM bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI file entry<br/>[main.rs]"]
  node_playground_ui["Playground UI<br/>[app.js]"]
  node_wasm_bridge["WASM bridge<br/>[lib.rs]"]
end

subgraph group_frontend["Language front end"]
  node_lexer["Tokenizer<br/>[mod.rs]"]
  node_tokens["Tokens and spans<br/>[token.rs]"]
  node_parser["Parser<br/>[mod.rs]"]
  node_ast["Program AST<br/>[ast.rs]"]
end

subgraph group_backends["Execution and generation"]
  node_interpreter["Interpreter<br/>[interp.rs]"]
  node_python_codegen["Python generator<br/>[python.rs]"]
end

subgraph group_support["Shared support"]
  node_diagnostics["Compile diagnostics<br/>[errors.rs]"]
end

node_cli_user(("CLI user"))
node_playground_user(("Playground user"))

node_cli_user -->|"provides file"| node_cli
node_cli -->|"tokenizes source"| node_lexer
node_cli -->|"parses tokens"| node_parser
node_cli -->|"generates Python"| node_python_codegen
node_playground_user -->|"enters program"| node_playground_ui
node_playground_ui -->|"calls WASM exports"| node_wasm_bridge
node_wasm_bridge -.->|"runs program"| node_interpreter
node_wasm_bridge -.->|"compiles Python"| node_python_codegen
node_lexer -->|"emits tokens"| node_tokens
node_parser -->|"consumes tokens"| node_lexer
node_parser -->|"builds AST"| node_ast
node_lexer -->|"reports errors"| node_diagnostics
node_parser -->|"reports errors"| node_diagnostics
node_cli -->|"renders errors"| node_diagnostics
node_interpreter -->|"uses program AST"| node_parser
node_python_codegen -->|"uses program AST"| node_parser

click node_cli "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/main.rs"
click node_playground_ui "https://github.com/betteriutinfoaix/algocompiler/blob/main/playground/app.js"
click node_wasm_bridge "https://github.com/betteriutinfoaix/algocompiler/blob/main/playground/src/lib.rs"
click node_lexer "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/lexer/mod.rs"
click node_tokens "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/lexer/token.rs"
click node_parser "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/parser/mod.rs"
click node_ast "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/parser/ast.rs"
click node_diagnostics "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/errors.rs"
click node_interpreter "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/interp.rs"
click node_python_codegen "https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/codegen/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_cli,node_playground_ui,node_wasm_bridge,node_cli_user,node_playground_user toneBlue
class node_lexer,node_tokens,node_parser,node_ast toneAmber
class node_interpreter,node_python_codegen toneMint
class node_diagnostics toneRose
```

## Components

### User interfaces

- [CLI file entry](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/main.rs): `AlgoCompiler/src/main.rs`
- [Playground UI](https://github.com/betteriutinfoaix/algocompiler/blob/main/playground/app.js): `playground/app.js`
- [WASM bridge](https://github.com/betteriutinfoaix/algocompiler/blob/main/playground/src/lib.rs): `playground/src/lib.rs`

### Language front end

- [Tokenizer](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/lexer/mod.rs): `AlgoCompiler/src/lexer/mod.rs`
- [Tokens and spans](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/lexer/token.rs): `AlgoCompiler/src/lexer/token.rs`
- [Parser](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/parser/mod.rs): `AlgoCompiler/src/parser/mod.rs`
- [Program AST](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/parser/ast.rs): `AlgoCompiler/src/parser/ast.rs`

### Execution and generation

- [Interpreter](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/interp.rs): `AlgoCompiler/src/interp.rs`
- [Python generator](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/codegen/python.rs): `AlgoCompiler/src/codegen/python.rs`

### Shared support

- [Compile diagnostics](https://github.com/betteriutinfoaix/algocompiler/blob/main/AlgoCompiler/src/errors.rs): `AlgoCompiler/src/errors.rs`

### Other components

- **CLI user**
- **Playground user**

## Connections

- CLI user → CLI file entry: provides file (evidence: `AlgoCompiler/src/main.rs`)
- CLI file entry → Tokenizer: tokenizes source (evidence: `AlgoCompiler/src/main.rs`)
- CLI file entry → Parser: parses tokens (evidence: `AlgoCompiler/src/main.rs`)
- CLI file entry → Python generator: generates Python (evidence: `AlgoCompiler/src/main.rs`)
- Playground user → Playground UI: enters program (evidence: `README.md`)
- Playground UI → WASM bridge: calls WASM exports (evidence: `playground/app.js`)
- WASM bridge → Interpreter: runs program
- WASM bridge → Python generator: compiles Python
- Tokenizer → Tokens and spans: emits tokens (evidence: `AlgoCompiler/src/lexer/mod.rs`)
- Parser → Tokenizer: consumes tokens (evidence: `AlgoCompiler/src/parser/mod.rs`)
- Parser → Program AST: builds AST (evidence: `AlgoCompiler/src/parser/mod.rs`)
- Tokenizer → Compile diagnostics: reports errors (evidence: `AlgoCompiler/src/lexer/mod.rs`)
- Parser → Compile diagnostics: reports errors (evidence: `AlgoCompiler/src/parser/mod.rs`)
- CLI file entry → Compile diagnostics: renders errors (evidence: `AlgoCompiler/src/main.rs`)
- Interpreter → Parser: uses program AST (evidence: `AlgoCompiler/src/interp.rs`)
- Python generator → Parser: uses program AST (evidence: `AlgoCompiler/src/codegen/python.rs`)
