# pihu21057w/bkl architecture

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

- Interactive diagram: https://gitdiagram.com/pihu21057w/bkl
- Repository: https://github.com/pihu21057w/bkl

## Overview

Bklang is a C11 interpreter for `.bkl` programs. The principal workflow is to invoke `rundi` with a script, have the interpreter parse and execute it, and produce program output or effects through built-ins. The runtime also exposes value and collection handling, a standard library, web-server and template features, and advanced language utilities. The graph reflects the sampled source and README; some built-in dispatch connections and unsampled capabilities are documented but their exact call paths are not shown.

Main entry points: [`main.c`](https://github.com/pihu21057w/bkl/blob/main/main.c) (Lexer and interpreter), [`advanced.c`](https://github.com/pihu21057w/bkl/blob/main/advanced.c) (Advanced dispatch), [`features.c`](https://github.com/pihu21057w/bkl/blob/main/features.c) (HTTP server), [`functions.c`](https://github.com/pihu21057w/bkl/blob/main/functions.c) (Standard library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Interpreter runtime"]
  node_rundi["rundi CLI<br/>[main.c]"]
  node_interpreter["Lexer and interpreter<br/>[main.c]"]
end

subgraph group_values["Values and library"]
  node_value_model["Values and collections<br/>[functions.c]"]
  node_stdlib["Standard library<br/>[functions.c]"]
  node_json["JSON parsing<br/>[functions.c]"]
end

subgraph group_web["Web features"]
  node_feature_dispatch["Feature dispatch<br/>[features.c]"]
  node_http_server["HTTP server<br/>[features.c]"]
  node_templates["Template rendering<br/>[features.c]"]
  node_static_assets["Static file serving<br/>[features.c]"]
end

subgraph group_advanced["Advanced built-ins"]
  node_advanced_dispatch["Advanced dispatch<br/>[advanced.c]"]
  node_regex["Regex engine<br/>[advanced.c]"]
  node_generators["Generators<br/>[advanced.c]"]
  node_events_channels["Events and channels<br/>[advanced.c]"]
  node_memoization["Memoization<br/>[advanced.c]"]
end

node_user(("Script author"))
node_browser(("HTTP client"))
node_program_result["Program output"]

node_user -->|"runs script"| node_rundi
node_rundi -->|"loads and executes"| node_interpreter
node_interpreter -.->|"produces output"| node_program_result
node_interpreter -->|"uses values"| node_value_model
node_interpreter -.->|"calls built-ins"| node_stdlib
node_stdlib -->|"parses and encodes"| node_json
node_browser -.->|"sends requests"| node_http_server
node_http_server -.->|"renders views"| node_templates
node_http_server -->|"serves files"| node_static_assets
node_interpreter -.->|"dispatches features"| node_feature_dispatch
node_feature_dispatch -->|"starts server"| node_http_server
node_feature_dispatch -->|"renders templates"| node_templates
node_interpreter -.->|"dispatches advanced calls"| node_advanced_dispatch
node_advanced_dispatch -->|"provides regex"| node_regex
node_advanced_dispatch -->|"provides generators"| node_generators
node_advanced_dispatch -->|"provides events"| node_events_channels
node_advanced_dispatch -->|"provides caching"| node_memoization

click node_rundi "https://github.com/pihu21057w/bkl/blob/main/main.c"
click node_interpreter "https://github.com/pihu21057w/bkl/blob/main/main.c"
click node_value_model "https://github.com/pihu21057w/bkl/blob/main/functions.c"
click node_stdlib "https://github.com/pihu21057w/bkl/blob/main/functions.c"
click node_json "https://github.com/pihu21057w/bkl/blob/main/functions.c"
click node_feature_dispatch "https://github.com/pihu21057w/bkl/blob/main/features.c"
click node_http_server "https://github.com/pihu21057w/bkl/blob/main/features.c"
click node_templates "https://github.com/pihu21057w/bkl/blob/main/features.c"
click node_static_assets "https://github.com/pihu21057w/bkl/blob/main/features.c"
click node_advanced_dispatch "https://github.com/pihu21057w/bkl/blob/main/advanced.c"
click node_regex "https://github.com/pihu21057w/bkl/blob/main/advanced.c"
click node_generators "https://github.com/pihu21057w/bkl/blob/main/advanced.c"
click node_events_channels "https://github.com/pihu21057w/bkl/blob/main/advanced.c"
click node_memoization "https://github.com/pihu21057w/bkl/blob/main/advanced.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_rundi,node_interpreter,node_browser toneBlue
class node_value_model,node_stdlib,node_json toneAmber
class node_feature_dispatch,node_http_server,node_templates,node_static_assets toneMint
class node_advanced_dispatch,node_regex,node_generators,node_events_channels,node_memoization toneRose
class node_user,node_program_result toneIndigo
```

## Components

### Interpreter runtime

- [rundi CLI](https://github.com/pihu21057w/bkl/blob/main/main.c): `main.c`
- [Lexer and interpreter](https://github.com/pihu21057w/bkl/blob/main/main.c): `main.c`

### Values and library

- [Values and collections](https://github.com/pihu21057w/bkl/blob/main/functions.c): `functions.c`
- [Standard library](https://github.com/pihu21057w/bkl/blob/main/functions.c): `functions.c`
- [JSON parsing](https://github.com/pihu21057w/bkl/blob/main/functions.c): `functions.c`

### Web features

- [Feature dispatch](https://github.com/pihu21057w/bkl/blob/main/features.c): `features.c`
- [HTTP server](https://github.com/pihu21057w/bkl/blob/main/features.c): `features.c`
- [Template rendering](https://github.com/pihu21057w/bkl/blob/main/features.c): `features.c`
- [Static file serving](https://github.com/pihu21057w/bkl/blob/main/features.c): `features.c`

### Advanced built-ins

- [Advanced dispatch](https://github.com/pihu21057w/bkl/blob/main/advanced.c): `advanced.c`
- [Regex engine](https://github.com/pihu21057w/bkl/blob/main/advanced.c): `advanced.c`
- [Generators](https://github.com/pihu21057w/bkl/blob/main/advanced.c): `advanced.c`
- [Events and channels](https://github.com/pihu21057w/bkl/blob/main/advanced.c): `advanced.c`
- [Memoization](https://github.com/pihu21057w/bkl/blob/main/advanced.c): `advanced.c`

### Other components

- **Script author**
- **HTTP client**
- **Program output**

## Connections

- Script author → rundi CLI: runs script (evidence: `README.md`)
- rundi CLI → Lexer and interpreter: loads and executes (evidence: `main.c`)
- Lexer and interpreter → Program output: produces output
- Lexer and interpreter → Values and collections: uses values
- Lexer and interpreter → Standard library: calls built-ins
- Standard library → JSON parsing: parses and encodes (evidence: `functions.c`)
- HTTP client → HTTP server: sends requests
- HTTP server → Template rendering: renders views (evidence: `features.c`)
- HTTP server → Static file serving: serves files (evidence: `README.md`)
- Lexer and interpreter → Feature dispatch: dispatches features
- Feature dispatch → HTTP server: starts server (evidence: `features.c`)
- Feature dispatch → Template rendering: renders templates (evidence: `features.c`)
- Lexer and interpreter → Advanced dispatch: dispatches advanced calls
- Advanced dispatch → Regex engine: provides regex (evidence: `advanced.c`)
- Advanced dispatch → Generators: provides generators (evidence: `advanced.c`)
- Advanced dispatch → Events and channels: provides events (evidence: `advanced.c`)
- Advanced dispatch → Memoization: provides caching (evidence: `advanced.c`)
