# shelllite/shlcpp architecture

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

- Interactive diagram: https://gitdiagram.com/shelllite/shlcpp
- Repository: https://github.com/shelllite/shlcpp

## Overview

ShellLite is a pseudocode-oriented programming language. Its main workflow runs from CLI input through lexing and parsing into AST-based compilation, then bytecode execution in the VM; the CLI also exposes formatting and bytecode workflows. The tree shows concurrency, native modules, UI, web/database, and platform capabilities. Some subsystem links are omitted because their runtime wiring is not shown in the excerpts or SOURCE INDEX.

Main entry points: [`shell_lite/vm.cpp`](https://github.com/shelllite/shlcpp/blob/main/shell_lite/vm.cpp) (Virtual machine), [`shell_lite/main.cpp`](https://github.com/shelllite/shlcpp/blob/main/shell_lite/main.cpp) (CLI and REPL), [`shell_lite/native_registry.hpp`](https://github.com/shelllite/shlcpp/blob/main/shell_lite/native_registry.hpp) (Native registry), [`shell_lite/modules/module_core.cpp`](https://github.com/shelllite/shlcpp/blob/main/shell_lite/modules/module_core.cpp) (Core built-ins)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Language Front End"]
  node_lexer["Lexer<br/>[lexer.cpp]"]
  node_parser["Parser"]
  node_ast["AST nodes<br/>[ast_nodes.hpp]"]
end

subgraph group_execution["Compilation Runtime"]
  node_compiler["Bytecode compiler<br/>[compiler.cpp]"]
  node_chunk["Bytecode chunk<br/>[chunk.hpp]"]
  node_vm["Virtual machine<br/>[vm.cpp]"]
  node_values["Values and objects<br/>[value.hpp]"]
  node_gc["Garbage collector<br/>[gc.hpp]"]
  node_errors["Error reporting<br/>[error_reporter.cpp]"]
end

subgraph group_features["Built-in Features"]
  node_native["Native registry"]
  node_corebuiltins["Core built-ins<br/>[module_core.cpp]"]
  node_modules["Standard modules"]
  node_webdb["Web and database"]
  node_ui["UI subsystem<br/>[ui_subsystem.cpp]"]
  node_platform["Platform layer<br/>[platform.hpp]"]
  node_concurrency["Concurrency pool<br/>[thread_pool.cpp]"]
  node_eventloop["Event loop<br/>[event_loop.cpp]"]
end

subgraph group_tooling["CLI Tooling"]
  node_cli["CLI and REPL<br/>[main.cpp]"]
  node_formatter["Source formatter<br/>[formatter.cpp]"]
end

node_user(("Language user"))
node_output(("Program output"))

node_user -->|"submits code"| node_cli
node_cli -->|"lexes input"| node_lexer
node_cli -->|"parses input"| node_parser
node_parser -->|"uses tokens"| node_lexer
node_parser -->|"builds nodes"| node_ast
node_cli -->|"compiles program"| node_compiler
node_compiler -->|"compiles nodes"| node_ast
node_compiler -->|"emits bytecode"| node_chunk
node_cli -->|"executes function"| node_vm
node_vm -->|"reads bytecode"| node_chunk
node_vm -->|"operates on values"| node_values
node_vm -->|"uses allocation"| node_gc
node_vm -->|"reports errors"| node_errors
node_vm -->|"uses registry"| node_native
node_corebuiltins -->|"registers built-ins"| node_native
node_modules -->|"registers functions"| node_native
node_webdb -->|"registers functions"| node_native
node_corebuiltins -->|"polls events"| node_eventloop
node_webdb -->|"uses event loop"| node_eventloop
node_vm -->|"uses thread pool"| node_concurrency
node_corebuiltins -->|"uses platform API"| node_platform
node_cli -->|"formats source"| node_formatter
node_formatter -->|"formats syntax tree"| node_ast
node_vm -.->|"produces results"| node_output

click node_cli "https://github.com/shelllite/shlcpp/blob/main/shell_lite/main.cpp"
click node_lexer "https://github.com/shelllite/shlcpp/blob/main/shell_lite/lexer.cpp"
click node_parser "https://github.com/shelllite/shlcpp/tree/main/shell_lite/parser"
click node_ast "https://github.com/shelllite/shlcpp/blob/main/shell_lite/ast_nodes.hpp"
click node_compiler "https://github.com/shelllite/shlcpp/blob/main/shell_lite/compiler.cpp"
click node_chunk "https://github.com/shelllite/shlcpp/blob/main/shell_lite/chunk.hpp"
click node_vm "https://github.com/shelllite/shlcpp/blob/main/shell_lite/vm.cpp"
click node_values "https://github.com/shelllite/shlcpp/blob/main/shell_lite/value.hpp"
click node_gc "https://github.com/shelllite/shlcpp/blob/main/shell_lite/gc.hpp"
click node_errors "https://github.com/shelllite/shlcpp/blob/main/shell_lite/error/error_reporter.cpp"
click node_native "https://github.com/shelllite/shlcpp/blob/main/shell_lite/native_registry.hpp"
click node_corebuiltins "https://github.com/shelllite/shlcpp/blob/main/shell_lite/modules/module_core.cpp"
click node_modules "https://github.com/shelllite/shlcpp/tree/main/shell_lite/modules"
click node_webdb "https://github.com/shelllite/shlcpp/tree/main/shell_lite/modules"
click node_ui "https://github.com/shelllite/shlcpp/blob/main/shell_lite/ui/ui_subsystem.cpp"
click node_platform "https://github.com/shelllite/shlcpp/blob/main/shell_lite/pal/platform.hpp"
click node_concurrency "https://github.com/shelllite/shlcpp/blob/main/shell_lite/concurrency/thread_pool.cpp"
click node_eventloop "https://github.com/shelllite/shlcpp/blob/main/shell_lite/event_loop.cpp"
click node_formatter "https://github.com/shelllite/shlcpp/blob/main/shell_lite/formatter.cpp"

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_user toneBlue
class node_compiler,node_chunk,node_vm,node_values,node_gc,node_errors toneAmber
class node_native,node_corebuiltins,node_modules,node_webdb,node_ui,node_platform,node_concurrency,node_eventloop toneMint
class node_cli,node_formatter toneRose
class node_output toneIndigo
```

## Components

### Language Front End

- [Lexer](https://github.com/shelllite/shlcpp/blob/main/shell_lite/lexer.cpp): `shell_lite/lexer.cpp`
- [Parser](https://github.com/shelllite/shlcpp/tree/main/shell_lite/parser): `shell_lite/parser`
- [AST nodes](https://github.com/shelllite/shlcpp/blob/main/shell_lite/ast_nodes.hpp): `shell_lite/ast_nodes.hpp`

### Compilation Runtime

- [Bytecode compiler](https://github.com/shelllite/shlcpp/blob/main/shell_lite/compiler.cpp): `shell_lite/compiler.cpp`
- [Bytecode chunk](https://github.com/shelllite/shlcpp/blob/main/shell_lite/chunk.hpp): `shell_lite/chunk.hpp`
- [Virtual machine](https://github.com/shelllite/shlcpp/blob/main/shell_lite/vm.cpp): `shell_lite/vm.cpp`
- [Values and objects](https://github.com/shelllite/shlcpp/blob/main/shell_lite/value.hpp): `shell_lite/value.hpp`
- [Garbage collector](https://github.com/shelllite/shlcpp/blob/main/shell_lite/gc.hpp): `shell_lite/gc.hpp`
- [Error reporting](https://github.com/shelllite/shlcpp/blob/main/shell_lite/error/error_reporter.cpp): `shell_lite/error/error_reporter.cpp`

### Built-in Features

- [Native registry](https://github.com/shelllite/shlcpp/blob/main/shell_lite/native_registry.hpp): `shell_lite/native_registry.hpp`
- [Core built-ins](https://github.com/shelllite/shlcpp/blob/main/shell_lite/modules/module_core.cpp): `shell_lite/modules/module_core.cpp`
- [Standard modules](https://github.com/shelllite/shlcpp/tree/main/shell_lite/modules): `shell_lite/modules`
- [Web and database](https://github.com/shelllite/shlcpp/tree/main/shell_lite/modules): `shell_lite/modules`
- [UI subsystem](https://github.com/shelllite/shlcpp/blob/main/shell_lite/ui/ui_subsystem.cpp): `shell_lite/ui/ui_subsystem.cpp`
- [Platform layer](https://github.com/shelllite/shlcpp/blob/main/shell_lite/pal/platform.hpp): `shell_lite/pal/platform.hpp`
- [Concurrency pool](https://github.com/shelllite/shlcpp/blob/main/shell_lite/concurrency/thread_pool.cpp): `shell_lite/concurrency/thread_pool.cpp`
- [Event loop](https://github.com/shelllite/shlcpp/blob/main/shell_lite/event_loop.cpp): `shell_lite/event_loop.cpp`

### CLI Tooling

- [CLI and REPL](https://github.com/shelllite/shlcpp/blob/main/shell_lite/main.cpp): `shell_lite/main.cpp`
- [Source formatter](https://github.com/shelllite/shlcpp/blob/main/shell_lite/formatter.cpp): `shell_lite/formatter.cpp`

### Other components

- **Language user**
- **Program output**

## Connections

- Language user → CLI and REPL: submits code (evidence: `README.md`)
- CLI and REPL → Lexer: lexes input (evidence: `shell_lite/main.cpp`)
- CLI and REPL → Parser: parses input (evidence: `shell_lite/main.cpp`)
- Parser → Lexer: uses tokens
- Parser → AST nodes: builds nodes
- CLI and REPL → Bytecode compiler: compiles program (evidence: `shell_lite/main.cpp`)
- Bytecode compiler → AST nodes: compiles nodes
- Bytecode compiler → Bytecode chunk: emits bytecode
- CLI and REPL → Virtual machine: executes function (evidence: `shell_lite/main.cpp`)
- Virtual machine → Bytecode chunk: reads bytecode
- Virtual machine → Values and objects: operates on values
- Virtual machine → Garbage collector: uses allocation (evidence: `shell_lite/vm.cpp`)
- Virtual machine → Error reporting: reports errors (evidence: `shell_lite/vm.cpp`)
- Virtual machine → Native registry: uses registry (evidence: `shell_lite/vm.cpp`)
- Core built-ins → Native registry: registers built-ins (evidence: `shell_lite/modules/module_core.cpp`)
- Standard modules → Native registry: registers functions (evidence: `shell_lite/modules/module_io.cpp`)
- Web and database → Native registry: registers functions (evidence: `shell_lite/modules/module_web.cpp`)
- Core built-ins → Event loop: polls events (evidence: `shell_lite/modules/module_core.cpp`)
- Web and database → Event loop: uses event loop (evidence: `shell_lite/modules/module_web.cpp`)
- Virtual machine → Concurrency pool: uses thread pool (evidence: `shell_lite/vm.cpp`)
- Core built-ins → Platform layer: uses platform API (evidence: `shell_lite/modules/module_core.cpp`)
- CLI and REPL → Source formatter: formats source (evidence: `shell_lite/main.cpp`)
- Source formatter → AST nodes: formats syntax tree
- Virtual machine → Program output: produces results
