# tobureinhardt/neyuki architecture

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

- Interactive diagram: https://gitdiagram.com/tobureinhardt/neyuki
- Repository: https://github.com/tobureinhardt/neyuki

## Overview

Neyuki is a Lua-like scripting language whose primary workflow takes `.nyk` source through parsing, semantic checks and IR-based bytecode generation to execution on a register VM. The repository also provides linting, module loading, package management, debugger protocol support, and HTTP, SQL, crypto and UI libraries. Runtime wiring is based on the sampled entry points and module-loader code; library capability links are documented in the README, but their internal call paths were not sampled.

Main entry points: [`src/vm/machine.rs`](https://github.com/tobureinhardt/neyuki/blob/main/src/vm/machine.rs) (Register VM), [`src/compiler/mod.rs`](https://github.com/tobureinhardt/neyuki/blob/main/src/compiler/mod.rs) (Compiler), [`src/main.rs`](https://github.com/tobureinhardt/neyuki/blob/main/src/main.rs) (CLI), [`src/module_loader/mod.rs`](https://github.com/tobureinhardt/neyuki/blob/main/src/module_loader/mod.rs) (Module loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_language["Language Front End"]
  node_lexer["Lexer<br/>[lexer.rs]"]
  node_parser["Parser and AST<br/>[mod.rs]"]
  node_sema["Semantic analysis<br/>[mod.rs]"]
  node_lint["Lint rules<br/>[mod.rs]"]
  node_diagnostics["Diagnostics<br/>[mod.rs]"]
end

subgraph group_execution["Compilation and Execution"]
  node_compiler["Compiler<br/>[mod.rs]"]
  node_ir["IR optimizer<br/>[mod.rs]"]
  node_bytecode["Bytecode format<br/>[mod.rs]"]
  node_vm["Register VM<br/>[machine.rs]"]
  node_runtime["Tree-walk runtime<br/>[runtime.rs]"]
end

subgraph group_runtime["Runtime Capabilities"]
  node_module_loader["Module loader<br/>[mod.rs]"]
  node_http["HTTP library<br/>[http_lib.rs]"]
  node_crypto["Crypto library<br/>[crypto_lib.rs]"]
  node_sql["SQL library<br/>[sql_lib.rs]"]
  node_ui["UI library<br/>[ui_lib.rs]"]
  node_filesystem["Filesystem library<br/>[fs_lib.rs]"]
end

subgraph group_services["Developer and Package Services"]
  node_cli["CLI<br/>[main.rs]"]
  node_pkg["Package manager<br/>[mod.rs]"]
  node_dap["Debugger protocol<br/>[dap.rs]"]
  node_stack_trace["Stack traces<br/>[mod.rs]"]
end

node_user(("Script author"))
node_external_services(("HTTP and database services"))
node_program(("Program output"))

node_user -->|"runs command"| node_cli
node_cli -->|"runs lint"| node_lint
node_cli -->|"compiles source"| node_compiler
node_cli -->|"runs file"| node_vm
node_lexer -->|"provides tokens"| node_parser
node_parser -->|"provides AST"| node_compiler
node_compiler -->|"checks semantics"| node_sema
node_sema -->|"returns diagnostics"| node_compiler
node_compiler -->|"builds and optimizes"| node_ir
node_ir -->|"generates bytecode"| node_bytecode
node_bytecode -->|"executes proto"| node_vm
node_lint -->|"parses source"| node_compiler
node_lint -->|"renders report"| node_diagnostics
node_cli -->|"runs package commands"| node_pkg
node_cli -->|"starts session"| node_dap
node_module_loader -->|"reads modules"| node_filesystem
node_module_loader -->|"compiles source modules"| node_compiler
node_module_loader -->|"deserializes and verifies"| node_bytecode
node_vm -.->|"exposes library"| node_http
node_vm -.->|"exposes library"| node_crypto
node_vm -.->|"exposes library"| node_sql
node_vm -.->|"exposes library"| node_ui
node_http -.->|"sends requests"| node_external_services
node_sql -.->|"queries databases"| node_external_services
node_vm -->|"produces results"| node_program
node_runtime -.->|"evaluates source"| node_program
node_vm -.->|"formats trace"| node_stack_trace

click node_cli "https://github.com/tobureinhardt/neyuki/blob/main/src/main.rs"
click node_lexer "https://github.com/tobureinhardt/neyuki/blob/main/src/lexer.rs"
click node_parser "https://github.com/tobureinhardt/neyuki/blob/main/src/parser/mod.rs"
click node_sema "https://github.com/tobureinhardt/neyuki/blob/main/src/sema/mod.rs"
click node_lint "https://github.com/tobureinhardt/neyuki/blob/main/src/lint/mod.rs"
click node_diagnostics "https://github.com/tobureinhardt/neyuki/blob/main/src/diagnostics/mod.rs"
click node_compiler "https://github.com/tobureinhardt/neyuki/blob/main/src/compiler/mod.rs"
click node_ir "https://github.com/tobureinhardt/neyuki/blob/main/src/compiler/ir/mod.rs"
click node_bytecode "https://github.com/tobureinhardt/neyuki/blob/main/src/bytecode/mod.rs"
click node_vm "https://github.com/tobureinhardt/neyuki/blob/main/src/vm/machine.rs"
click node_runtime "https://github.com/tobureinhardt/neyuki/blob/main/src/runtime.rs"
click node_module_loader "https://github.com/tobureinhardt/neyuki/blob/main/src/module_loader/mod.rs"
click node_pkg "https://github.com/tobureinhardt/neyuki/blob/main/src/pkg/mod.rs"
click node_dap "https://github.com/tobureinhardt/neyuki/blob/main/src/dap.rs"
click node_stack_trace "https://github.com/tobureinhardt/neyuki/blob/main/src/stack_trace/mod.rs"
click node_http "https://github.com/tobureinhardt/neyuki/blob/main/src/http_lib.rs"
click node_crypto "https://github.com/tobureinhardt/neyuki/blob/main/src/crypto_lib.rs"
click node_sql "https://github.com/tobureinhardt/neyuki/blob/main/src/sql_lib.rs"
click node_ui "https://github.com/tobureinhardt/neyuki/blob/main/src/ui_lib.rs"
click node_filesystem "https://github.com/tobureinhardt/neyuki/blob/main/src/fs_lib.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_sema,node_lint,node_diagnostics toneBlue
class node_compiler,node_ir,node_bytecode,node_vm,node_runtime,node_external_services toneAmber
class node_module_loader,node_http,node_crypto,node_sql,node_ui,node_filesystem toneMint
class node_cli,node_pkg,node_dap,node_stack_trace toneRose
class node_user,node_program toneIndigo
```

## Components

### Language Front End

- [Lexer](https://github.com/tobureinhardt/neyuki/blob/main/src/lexer.rs): `src/lexer.rs`
- [Parser and AST](https://github.com/tobureinhardt/neyuki/blob/main/src/parser/mod.rs): `src/parser/mod.rs`
- [Semantic analysis](https://github.com/tobureinhardt/neyuki/blob/main/src/sema/mod.rs): `src/sema/mod.rs`
- [Lint rules](https://github.com/tobureinhardt/neyuki/blob/main/src/lint/mod.rs): `src/lint/mod.rs`
- [Diagnostics](https://github.com/tobureinhardt/neyuki/blob/main/src/diagnostics/mod.rs): `src/diagnostics/mod.rs`

### Compilation and Execution

- [Compiler](https://github.com/tobureinhardt/neyuki/blob/main/src/compiler/mod.rs): `src/compiler/mod.rs`
- [IR optimizer](https://github.com/tobureinhardt/neyuki/blob/main/src/compiler/ir/mod.rs): `src/compiler/ir/mod.rs`
- [Bytecode format](https://github.com/tobureinhardt/neyuki/blob/main/src/bytecode/mod.rs): `src/bytecode/mod.rs`
- [Register VM](https://github.com/tobureinhardt/neyuki/blob/main/src/vm/machine.rs): `src/vm/machine.rs`
- [Tree-walk runtime](https://github.com/tobureinhardt/neyuki/blob/main/src/runtime.rs): `src/runtime.rs`

### Runtime Capabilities

- [Module loader](https://github.com/tobureinhardt/neyuki/blob/main/src/module_loader/mod.rs): `src/module_loader/mod.rs`
- [HTTP library](https://github.com/tobureinhardt/neyuki/blob/main/src/http_lib.rs): `src/http_lib.rs`
- [Crypto library](https://github.com/tobureinhardt/neyuki/blob/main/src/crypto_lib.rs): `src/crypto_lib.rs`
- [SQL library](https://github.com/tobureinhardt/neyuki/blob/main/src/sql_lib.rs): `src/sql_lib.rs`
- [UI library](https://github.com/tobureinhardt/neyuki/blob/main/src/ui_lib.rs): `src/ui_lib.rs`
- [Filesystem library](https://github.com/tobureinhardt/neyuki/blob/main/src/fs_lib.rs): `src/fs_lib.rs`

### Developer and Package Services

- [CLI](https://github.com/tobureinhardt/neyuki/blob/main/src/main.rs): `src/main.rs`
- [Package manager](https://github.com/tobureinhardt/neyuki/blob/main/src/pkg/mod.rs): `src/pkg/mod.rs`
- [Debugger protocol](https://github.com/tobureinhardt/neyuki/blob/main/src/dap.rs): `src/dap.rs`
- [Stack traces](https://github.com/tobureinhardt/neyuki/blob/main/src/stack_trace/mod.rs): `src/stack_trace/mod.rs`

### Other components

- **Script author**
- **HTTP and database services**
- **Program output**

## Connections

- Script author → CLI: runs command
- CLI → Lint rules: runs lint
- CLI → Compiler: compiles source
- CLI → Register VM: runs file
- Lexer → Parser and AST: provides tokens
- Parser and AST → Compiler: provides AST
- Compiler → Semantic analysis: checks semantics
- Semantic analysis → Compiler: returns diagnostics
- Compiler → IR optimizer: builds and optimizes
- IR optimizer → Bytecode format: generates bytecode
- Bytecode format → Register VM: executes proto
- Lint rules → Compiler: parses source
- Lint rules → Diagnostics: renders report
- CLI → Package manager: runs package commands
- CLI → Debugger protocol: starts session
- Module loader → Filesystem library: reads modules
- Module loader → Compiler: compiles source modules
- Module loader → Bytecode format: deserializes and verifies
- Register VM → HTTP library: exposes library
- Register VM → Crypto library: exposes library
- Register VM → SQL library: exposes library
- Register VM → UI library: exposes library
- HTTP library → HTTP and database services: sends requests
- SQL library → HTTP and database services: queries databases
- Register VM → Program output: produces results
- Tree-walk runtime → Program output: evaluates source
- Register VM → Stack traces: formats trace
