# ps22c/fx architecture

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

- Interactive diagram: https://gitdiagram.com/ps22c/fx
- Repository: https://github.com/ps22c/fx

## Overview

Fx is an embeddable scripting language and bytecode virtual machine. A user supplies a script path to the executable; the runtime loads the script, compiles it to bytecode, and runs it in the VM. The monolithic implementation also contains value/object and garbage-collection machinery and opens standard libraries. The README documents language features and library capabilities, but the excerpts do not show most internal call relationships; those links are omitted rather than inferred.

Main entry points: [`fx.c`](https://github.com/ps22c/fx/blob/main/fx.c) (Script entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Source Front End"]
  node_loader["File loader<br/>[fx.c]"]
  node_parser["Lexer and parser<br/>[fx.c]"]
  node_typing["Type checks<br/>[fx.c]"]
  node_compiler["Bytecode compiler<br/>[fx.c]"]
end

subgraph group_runtime["Execution Runtime"]
  node_cli["Script entry point<br/>[fx.c]"]
  node_vm["Bytecode VM<br/>[fx.c]"]
end

subgraph group_state["Values and State"]
  node_values["Values and objects<br/>[fx.c]"]
  node_gc["Garbage collection<br/>[fx.c]"]
end

subgraph group_libs["Standard Libraries"]
  node_base["Base functions<br/>[fx.c]"]
  node_objectlib["Object library<br/>[fx.c]"]
  node_ioos["I/O and OS<br/>[fx.c]"]
  node_stringmath["String and math<br/>[fx.c]"]
end

node_user(("Script author"))

node_user -->|"runs script"| node_cli
node_cli -->|"loads file"| node_loader
node_loader -->|"compiles source"| node_compiler
node_compiler -->|"emits bytecode"| node_vm
node_cli -->|"opens libraries"| node_base
node_cli -->|"opens libraries"| node_objectlib
node_cli -->|"opens libraries"| node_ioos
node_cli -->|"opens libraries"| node_stringmath

click node_cli "https://github.com/ps22c/fx/blob/main/fx.c"
click node_loader "https://github.com/ps22c/fx/blob/main/fx.c"
click node_parser "https://github.com/ps22c/fx/blob/main/fx.c"
click node_typing "https://github.com/ps22c/fx/blob/main/fx.c"
click node_compiler "https://github.com/ps22c/fx/blob/main/fx.c"
click node_vm "https://github.com/ps22c/fx/blob/main/fx.c"
click node_values "https://github.com/ps22c/fx/blob/main/fx.c"
click node_gc "https://github.com/ps22c/fx/blob/main/fx.c"
click node_base "https://github.com/ps22c/fx/blob/main/fx.c"
click node_objectlib "https://github.com/ps22c/fx/blob/main/fx.c"
click node_ioos "https://github.com/ps22c/fx/blob/main/fx.c"
click node_stringmath "https://github.com/ps22c/fx/blob/main/fx.c"

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_loader,node_parser,node_typing,node_compiler toneBlue
class node_cli,node_vm toneAmber
class node_values,node_gc toneMint
class node_base,node_objectlib,node_ioos,node_stringmath toneRose
class node_user toneIndigo
```

## Components

### Source Front End

- [File loader](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Lexer and parser](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Type checks](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Bytecode compiler](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`

### Execution Runtime

- [Script entry point](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Bytecode VM](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`

### Values and State

- [Values and objects](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Garbage collection](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`

### Standard Libraries

- [Base functions](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [Object library](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [I/O and OS](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`
- [String and math](https://github.com/ps22c/fx/blob/main/fx.c): `fx.c`

### Other components

- **Script author**

## Connections

- Script author → Script entry point: runs script (evidence: `fx.c`)
- Script entry point → File loader: loads file (evidence: `fx.c`)
- File loader → Bytecode compiler: compiles source (evidence: `README.md`)
- Bytecode compiler → Bytecode VM: emits bytecode (evidence: `README.md`)
- Script entry point → Base functions: opens libraries (evidence: `fx.c`)
- Script entry point → Object library: opens libraries (evidence: `README.md`)
- Script entry point → I/O and OS: opens libraries (evidence: `README.md`)
- Script entry point → String and math: opens libraries (evidence: `README.md`)
