# inputoutputstream/thevmproject architecture

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

- Interactive diagram: https://gitdiagram.com/inputoutputstream/thevmproject
- Repository: https://github.com/inputoutputstream/thevmproject

## Overview

THOTH_VM is a small C virtual-machine prototype. Its demonstrated workflow is: the executable entry point allocates a VM, builds a sample instruction stream, runs it through the execution loop and opcode dispatcher, then prints memory. The header defines the VM state and instruction set; the C file implements the runtime. The README is empty, so this map reflects only the sampled source and does not infer additional capabilities.

Main entry points: [`THOTH_VM/THOTH_VM.c`](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c) (Executable entry), [`THOTH_VM/THOTH_VM.h`](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.h) (VM memory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["VM runtime"]
  node_entry["Executable entry<br/>[THOTH_VM.c]"]
  node_opmap["Opcode sizing<br/>[THOTH_VM.c]"]
  node_loop["Execution loop<br/>[THOTH_VM.c]"]
  node_dispatch["Instruction dispatch<br/>[THOTH_VM.c]"]
  node_handlers["MOV and halt<br/>[THOTH_VM.c]"]
  node_errors["Error handling<br/>[THOTH_VM.c]"]
end

subgraph group_program["Program and state"]
  node_vmstate["VM state<br/>[THOTH_VM.h]"]
  node_vmalloc["VM allocation<br/>[THOTH_VM.c]"]
  node_sample["Sample program builder<br/>[THOTH_VM.c]"]
  node_memory[("VM memory<br/>[THOTH_VM.h]")]
end

node_user(("Program user"))

node_user -->|"runs"| node_entry
node_entry -->|"allocates"| node_vmalloc
node_entry -->|"builds"| node_sample
node_entry -->|"runs"| node_loop
node_entry -->|"prints"| node_memory
node_vmalloc -->|"allocates"| node_vmstate
node_sample -->|"gets sizes"| node_opmap
node_sample -->|"writes program"| node_memory
node_loop -->|"gets size"| node_opmap
node_loop -->|"dispatches"| node_dispatch
node_dispatch -->|"gets size"| node_opmap
node_dispatch -->|"dispatches"| node_handlers
node_dispatch -->|"signals fault"| node_errors
node_handlers -->|"halts via"| node_errors

click node_entry "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_vmstate "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.h"
click node_vmalloc "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_sample "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_opmap "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_loop "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_dispatch "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_handlers "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_errors "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c"
click node_memory "https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.h"

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_entry,node_opmap,node_loop,node_dispatch,node_handlers,node_errors,node_user toneBlue
class node_vmstate,node_vmalloc,node_sample,node_memory toneAmber
```

## Components

### VM runtime

- [Executable entry](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [Opcode sizing](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [Execution loop](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [Instruction dispatch](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [MOV and halt](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [Error handling](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`

### Program and state

- [VM state](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.h): `THOTH_VM/THOTH_VM.h`
- [VM allocation](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [Sample program builder](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.c): `THOTH_VM/THOTH_VM.c`
- [VM memory](https://github.com/inputoutputstream/thevmproject/blob/main/THOTH_VM/THOTH_VM.h): `THOTH_VM/THOTH_VM.h`

### Other components

- **Program user**

## Connections

- Program user → Executable entry: runs (evidence: `THOTH_VM/THOTH_VM.c`)
- Executable entry → VM allocation: allocates (evidence: `THOTH_VM/THOTH_VM.c`)
- Executable entry → Sample program builder: builds (evidence: `THOTH_VM/THOTH_VM.c`)
- Executable entry → Execution loop: runs (evidence: `THOTH_VM/THOTH_VM.c`)
- Executable entry → VM memory: prints (evidence: `THOTH_VM/THOTH_VM.c`)
- VM allocation → VM state: allocates (evidence: `THOTH_VM/THOTH_VM.c`)
- Sample program builder → Opcode sizing: gets sizes (evidence: `THOTH_VM/THOTH_VM.c`)
- Sample program builder → VM memory: writes program (evidence: `THOTH_VM/THOTH_VM.c`)
- Execution loop → Opcode sizing: gets size (evidence: `THOTH_VM/THOTH_VM.c`)
- Execution loop → Instruction dispatch: dispatches (evidence: `THOTH_VM/THOTH_VM.c`)
- Instruction dispatch → Opcode sizing: gets size (evidence: `THOTH_VM/THOTH_VM.c`)
- Instruction dispatch → MOV and halt: dispatches (evidence: `THOTH_VM/THOTH_VM.c`)
- Instruction dispatch → Error handling: signals fault (evidence: `THOTH_VM/THOTH_VM.c`)
- MOV and halt → Error handling: halts via (evidence: `THOTH_VM/THOTH_VM.c`)
