# i42output/neos architecture

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

- Interactive diagram: https://gitdiagram.com/i42output/neos
- Repository: https://github.com/i42output/neos

## Overview

neos is a language-agnostic scripting engine: a language schema and semantic concept library define a language, which is compiled to custom bytecode and executed by its VM/JIT. The graph preserves the documented schema/library capability and the sampled compiler-emission behavior. Runtime links beyond the visible concept-to-compiler calls are dashed because the available excerpts do not establish those calls; the bundled libffi dependency is not mapped as a product subsystem.

Main entry points: [`src/compiler.cpp`](https://github.com/i42output/neos/blob/master/src/compiler.cpp) (Compiler), [`src/bytecode/vm.cpp`](https://github.com/i42output/neos/blob/master/src/bytecode/vm.cpp) (Virtual Machine), [`src/api/context.cpp`](https://github.com/i42output/neos/blob/master/src/api/context.cpp) (Execution Context), [`include/neos/bytecode/bytecode.hpp`](https://github.com/i42output/neos/blob/master/include/neos/bytecode/bytecode.hpp) (Bytecode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_language["Language Definition"]
  node_schema["Language Schema<br/>[schema.cpp]"]
  node_concept_api["Concept Library API"]
  node_core_language["Core Language Concepts<br/>[language.cpp]"]
  node_python_language["Python Concepts<br/>[python.cpp]"]
  node_python_builtins["Python Builtins<br/>[builtins.py]"]
  node_semantic_model["Semantic Concepts"]
end

subgraph group_compile["Compilation"]
  node_compiler["Compiler<br/>[compiler.cpp]"]
  node_compiler_api["Compiler API<br/>[compiler.hpp]"]
  node_ast["Language AST<br/>[ast.hpp]"]
  node_scope["Scopes and Symbols<br/>[scope.hpp]"]
end

subgraph group_runtime["Bytecode Runtime"]
  node_context["Execution Context<br/>[context.cpp]"]
  node_bytecode["Bytecode<br/>[bytecode.hpp]"]
  node_opcodes["Opcode Set<br/>[opcodes.hpp]"]
  node_vm["Virtual Machine<br/>[vm.cpp]"]
  node_jit["Custom JIT<br/>[jit.cpp]"]
  node_bytecode_text["Bytecode Text<br/>[text.cpp]"]
  node_console["Console<br/>[console.cpp]"]
end

node_author(("Language Author"))
node_result(("Script Result"))

node_author -->|"defines syntax"| node_schema
node_author -->|"defines semantics"| node_concept_api
node_schema -.->|"describes language"| node_compiler
node_concept_api -.->|"supplies concepts"| node_compiler
node_core_language -->|"emits constructs"| node_compiler_api
node_python_language -->|"emits constructs"| node_compiler_api
node_python_builtins -.->|"extends language"| node_python_language
node_compiler -.->|"builds syntax tree"| node_ast
node_compiler -.->|"tracks bindings"| node_scope
node_compiler -.->|"produces bytecode"| node_bytecode
node_bytecode -.->|"encodes operations"| node_opcodes
node_context -.->|"provides context"| node_compiler
node_context -.->|"runs scripts"| node_vm
node_vm -.->|"uses JIT"| node_jit
node_bytecode_text -.->|"formats bytecode"| node_bytecode
node_console -.->|"invokes engine"| node_context
node_vm -.->|"returns result"| node_result

click node_schema "https://github.com/i42output/neos/blob/master/src/schema.cpp"
click node_concept_api "https://github.com/i42output/neos/blob/master/include/neos/language/concept_library.hpp"
click node_core_language "https://github.com/i42output/neos/blob/master/concepts/src/core/language.cpp"
click node_python_language "https://github.com/i42output/neos/blob/master/concepts/src/core/python.cpp"
click node_python_builtins "https://github.com/i42output/neos/blob/master/languages/packages/python/builtins.py"
click node_compiler "https://github.com/i42output/neos/blob/master/src/compiler.cpp"
click node_compiler_api "https://github.com/i42output/neos/blob/master/include/neos/language/compiler.hpp"
click node_ast "https://github.com/i42output/neos/blob/master/include/neos/language/ast.hpp"
click node_semantic_model "https://github.com/i42output/neos/blob/master/include/neos/language/semantic_concept.hpp"
click node_scope "https://github.com/i42output/neos/blob/master/include/neos/language/scope.hpp"
click node_context "https://github.com/i42output/neos/blob/master/src/api/context.cpp"
click node_bytecode "https://github.com/i42output/neos/blob/master/include/neos/bytecode/bytecode.hpp"
click node_opcodes "https://github.com/i42output/neos/blob/master/include/neos/bytecode/opcodes.hpp"
click node_vm "https://github.com/i42output/neos/blob/master/src/bytecode/vm.cpp"
click node_jit "https://github.com/i42output/neos/blob/master/src/bytecode/jit.cpp"
click node_bytecode_text "https://github.com/i42output/neos/blob/master/src/bytecode/text.cpp"
click node_console "https://github.com/i42output/neos/blob/master/console/src/console.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_schema,node_concept_api,node_core_language,node_python_language,node_python_builtins,node_semantic_model toneBlue
class node_compiler,node_compiler_api,node_ast,node_scope toneAmber
class node_context,node_bytecode,node_opcodes,node_vm,node_jit,node_bytecode_text,node_console toneMint
class node_author,node_result toneIndigo
```

## Components

### Language Definition

- [Language Schema](https://github.com/i42output/neos/blob/master/src/schema.cpp): `src/schema.cpp`
- [Concept Library API](https://github.com/i42output/neos/blob/master/include/neos/language/concept_library.hpp): `include/neos/language/concept_library.hpp`
- [Core Language Concepts](https://github.com/i42output/neos/blob/master/concepts/src/core/language.cpp): `concepts/src/core/language.cpp`
- [Python Concepts](https://github.com/i42output/neos/blob/master/concepts/src/core/python.cpp): `concepts/src/core/python.cpp`
- [Python Builtins](https://github.com/i42output/neos/blob/master/languages/packages/python/builtins.py): `languages/packages/python/builtins.py`
- [Semantic Concepts](https://github.com/i42output/neos/blob/master/include/neos/language/semantic_concept.hpp): `include/neos/language/semantic_concept.hpp`

### Compilation

- [Compiler](https://github.com/i42output/neos/blob/master/src/compiler.cpp): `src/compiler.cpp`
- [Compiler API](https://github.com/i42output/neos/blob/master/include/neos/language/compiler.hpp): `include/neos/language/compiler.hpp`
- [Language AST](https://github.com/i42output/neos/blob/master/include/neos/language/ast.hpp): `include/neos/language/ast.hpp`
- [Scopes and Symbols](https://github.com/i42output/neos/blob/master/include/neos/language/scope.hpp): `include/neos/language/scope.hpp`

### Bytecode Runtime

- [Execution Context](https://github.com/i42output/neos/blob/master/src/api/context.cpp): `src/api/context.cpp`
- [Bytecode](https://github.com/i42output/neos/blob/master/include/neos/bytecode/bytecode.hpp): `include/neos/bytecode/bytecode.hpp`
- [Opcode Set](https://github.com/i42output/neos/blob/master/include/neos/bytecode/opcodes.hpp): `include/neos/bytecode/opcodes.hpp`
- [Virtual Machine](https://github.com/i42output/neos/blob/master/src/bytecode/vm.cpp): `src/bytecode/vm.cpp`
- [Custom JIT](https://github.com/i42output/neos/blob/master/src/bytecode/jit.cpp): `src/bytecode/jit.cpp`
- [Bytecode Text](https://github.com/i42output/neos/blob/master/src/bytecode/text.cpp): `src/bytecode/text.cpp`
- [Console](https://github.com/i42output/neos/blob/master/console/src/console.cpp): `console/src/console.cpp`

### Other components

- **Language Author**
- **Script Result**

## Connections

- Language Author → Language Schema: defines syntax
- Language Author → Concept Library API: defines semantics
- Language Schema → Compiler: describes language
- Concept Library API → Compiler: supplies concepts
- Core Language Concepts → Compiler API: emits constructs (evidence: `concepts/src/core/language.cpp`)
- Python Concepts → Compiler API: emits constructs (evidence: `concepts/src/core/python.cpp`)
- Python Builtins → Python Concepts: extends language
- Compiler → Language AST: builds syntax tree
- Compiler → Scopes and Symbols: tracks bindings
- Compiler → Bytecode: produces bytecode
- Bytecode → Opcode Set: encodes operations
- Execution Context → Compiler: provides context
- Execution Context → Virtual Machine: runs scripts
- Virtual Machine → Custom JIT: uses JIT
- Bytecode Text → Bytecode: formats bytecode
- Console → Execution Context: invokes engine
- Virtual Machine → Script Result: returns result
