# bruju/rdfpls architecture

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

- Interactive diagram: https://gitdiagram.com/bruju/rdfpls
- Repository: https://github.com/bruju/rdfpls

## Overview

RDFPLS is a small RDF-based joke programming language. Its runtime reads an RDF program, finds its unique main function, and interprets instructions and expressions, including variables, operators, functions, branches, loops, printing, and JavaScript-backed functions. The implementation is concentrated in `index.ts`; the graph reflects those runtime responsibilities rather than build or test infrastructure.

Main entry points: [`index.ts`](https://github.com/bruju/rdfpls/blob/master/index.ts) (Instruction interpreter)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_program["RDF program"]
node_runner["CLI runner<br/>[index.ts]"]
node_parser["RDF parser<br/>[index.ts]"]
node_dataset[("RDF dataset<br/>[index.ts]")]
node_entry["Main resolver<br/>[index.ts]"]
node_functions["Function executor<br/>[index.ts]"]
node_instructions["Instruction interpreter<br/>[index.ts]"]
node_expressions["Expression evaluator<br/>[index.ts]"]
node_state["Variable memory<br/>[index.ts]"]
node_control["Branch and loops<br/>[index.ts]"]
node_operations["Operators and comparisons<br/>[index.ts]"]
node_output["Console output<br/>[index.ts]"]
node_js["JavaScript runtime"]

node_program -->|"supplies input"| node_runner
node_runner -->|"reads and parses"| node_parser
node_runner -->|"adds quads"| node_dataset
node_runner -->|"executes program"| node_entry
node_entry -->|"finds main"| node_dataset
node_entry -->|"starts function"| node_functions
node_functions -->|"reads function data"| node_dataset
node_functions -->|"runs instructions"| node_instructions
node_instructions -->|"evaluates expressions"| node_expressions
node_expressions -->|"dispatches calls"| node_instructions
node_instructions -->|"updates variables"| node_state
node_expressions -->|"reads variables"| node_state
node_instructions -->|"handles branches"| node_control
node_control -->|"executes bodies"| node_instructions
node_instructions -->|"applies operations"| node_operations
node_instructions -->|"prints text"| node_output
node_functions -->|"evaluates code"| node_js

click node_runner "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_parser "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_dataset "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_entry "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_functions "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_instructions "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_expressions "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_state "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_control "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_operations "https://github.com/bruju/rdfpls/blob/master/index.ts"
click node_output "https://github.com/bruju/rdfpls/blob/master/index.ts"

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_program,node_js toneIndigo
class node_runner,node_parser,node_entry,node_functions,node_instructions,node_expressions,node_state,node_control,node_operations,node_output toneTeal
class node_dataset toneAmber
```

## Components

### Other components

- **RDF program**
- [CLI runner](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [RDF parser](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [RDF dataset](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Main resolver](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Function executor](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Instruction interpreter](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Expression evaluator](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Variable memory](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Branch and loops](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Operators and comparisons](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- [Console output](https://github.com/bruju/rdfpls/blob/master/index.ts): `index.ts`
- **JavaScript runtime**

## Connections

- RDF program → CLI runner: supplies input (evidence: `README.md`)
- CLI runner → RDF parser: reads and parses (evidence: `index.ts`)
- CLI runner → RDF dataset: adds quads (evidence: `index.ts`)
- CLI runner → Main resolver: executes program (evidence: `index.ts`)
- Main resolver → RDF dataset: finds main (evidence: `index.ts`)
- Main resolver → Function executor: starts function (evidence: `index.ts`)
- Function executor → RDF dataset: reads function data (evidence: `index.ts`)
- Function executor → Instruction interpreter: runs instructions (evidence: `index.ts`)
- Instruction interpreter → Expression evaluator: evaluates expressions (evidence: `index.ts`)
- Expression evaluator → Instruction interpreter: dispatches calls (evidence: `index.ts`)
- Instruction interpreter → Variable memory: updates variables (evidence: `index.ts`)
- Expression evaluator → Variable memory: reads variables (evidence: `index.ts`)
- Instruction interpreter → Branch and loops: handles branches (evidence: `index.ts`)
- Branch and loops → Instruction interpreter: executes bodies (evidence: `index.ts`)
- Instruction interpreter → Operators and comparisons: applies operations (evidence: `index.ts`)
- Instruction interpreter → Console output: prints text (evidence: `index.ts`)
- Function executor → JavaScript runtime: evaluates code (evidence: `index.ts`)
