# gloudx/pil architecture

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

- Interactive diagram: https://gitdiagram.com/gloudx/pil
- Repository: https://github.com/gloudx/pil

## Overview

PicoLisp on Go is an interpreter runtime: a user runs Lisp source or enters expressions, which the VM reads and evaluates, with optional database-backed state and higher-level language capabilities. The README documents the object database, Pilog, and web framework as major features; only the Go runtime and selected JavaScript client files appear in the supplied tree. Edges for documented but unsampled Lisp-layer behavior are cited to the README, not presented as inspected implementation details.

Main entry points: [`cmd/pil/main.go`](https://github.com/gloudx/pil/blob/main/cmd/pil/main.go) (CLI runner), [`vm/vm.go`](https://github.com/gloudx/pil/blob/main/vm/vm.go) (VM context), [`db/builtin.go`](https://github.com/gloudx/pil/blob/main/db/builtin.go) (DB built-ins), [`vm/eval.go`](https://github.com/gloudx/pil/blob/main/vm/eval.go) (Evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Runtime entry"]
  node_cli["CLI runner<br/>[main.go]"]
end

subgraph group_language["Language runtime"]
  node_vm["VM context<br/>[vm.go]"]
  node_reader["Lisp reader<br/>[read.go]"]
  node_evaluator["Evaluator<br/>[eval.go]"]
  node_builtins["Built-in functions"]
  node_objectmodel["Object model<br/>[oop.go]"]
  node_io["I/O primitives<br/>[builtin_io2.go]"]
  node_network["Go networking<br/>[net.go]"]
  node_ffi["FFI bridge<br/>[ffi_on.go]"]
end

subgraph group_state["Persistence"]
  node_dbbinding["DB built-ins<br/>[builtin.go]"]
  node_externsymbols["External symbols<br/>[extern.go]"]
  node_store[("Block store<br/>[store.go]")]
end

subgraph group_capabilities["PicoLisp capabilities"]
  node_entitydb["Entity relations"]
  node_pilog["Pilog solver<br/>[pilog.go]"]
  node_webframework["Web framework"]
end

subgraph group_webclient["Web client"]
  node_forms["Form client<br/>[form.js]"]
  node_canvas["Canvas client<br/>[canvas.js]"]
  node_gis["GIS client<br/>[gis.js]"]
  node_plio["PLIO decoder<br/>[plio.js]"]
end

node_user(("Lisp user"))

node_user -->|"runs source"| node_cli
node_cli -->|"creates VM"| node_vm
node_cli -->|"registers DB"| node_dbbinding
node_cli -->|"loads files"| node_reader
node_cli -->|"evaluates input"| node_evaluator
node_reader -.->|"produces forms"| node_evaluator
node_evaluator -.->|"dispatches functions"| node_builtins
node_vm -->|"provides runtime"| node_objectmodel
node_vm -->|"provides runtime"| node_io
node_vm -->|"provides sockets"| node_network
node_vm -->|"offers optional bridge"| node_ffi
node_dbbinding -->|"commits records"| node_store
node_store -->|"loads values"| node_externsymbols
node_dbbinding -.->|"registers store"| node_externsymbols
node_entitydb -->|"uses store API"| node_dbbinding
node_entitydb -->|"persists objects"| node_store
node_pilog -->|"runs goal code"| node_evaluator
node_webframework -->|"serves pages"| node_network
node_forms -->|"posts form actions"| node_webframework
node_canvas -->|"requests drawing"| node_webframework
node_gis -->|"calls Lisp actions"| node_forms
node_plio -.->|"decodes PLIO data"| node_webframework

click node_cli "https://github.com/gloudx/pil/blob/main/cmd/pil/main.go"
click node_vm "https://github.com/gloudx/pil/blob/main/vm/vm.go"
click node_reader "https://github.com/gloudx/pil/blob/main/vm/read.go"
click node_evaluator "https://github.com/gloudx/pil/blob/main/vm/eval.go"
click node_builtins "https://github.com/gloudx/pil/tree/main/vm"
click node_objectmodel "https://github.com/gloudx/pil/blob/main/vm/oop.go"
click node_io "https://github.com/gloudx/pil/blob/main/vm/builtin_io2.go"
click node_network "https://github.com/gloudx/pil/blob/main/vm/net.go"
click node_ffi "https://github.com/gloudx/pil/blob/main/vm/ffi_on.go"
click node_dbbinding "https://github.com/gloudx/pil/blob/main/db/builtin.go"
click node_externsymbols "https://github.com/gloudx/pil/blob/main/vm/extern.go"
click node_store "https://github.com/gloudx/pil/blob/main/db/store.go"
click node_entitydb "https://github.com/gloudx/pil/tree/main/lisp"
click node_pilog "https://github.com/gloudx/pil/blob/main/vm/pilog.go"
click node_webframework "https://github.com/gloudx/pil/tree/main/lisp"
click node_forms "https://github.com/gloudx/pil/blob/main/lisp/lib/form.js"
click node_canvas "https://github.com/gloudx/pil/blob/main/lisp/lib/canvas.js"
click node_gis "https://github.com/gloudx/pil/blob/main/lisp/lib/gis.js"
click node_plio "https://github.com/gloudx/pil/blob/main/lisp/lib/plio.js"

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_cli,node_user toneBlue
class node_vm,node_reader,node_evaluator,node_builtins,node_objectmodel,node_io,node_network,node_ffi toneAmber
class node_dbbinding,node_externsymbols,node_store toneMint
class node_entitydb,node_pilog,node_webframework toneRose
class node_forms,node_canvas,node_gis,node_plio toneIndigo
```

## Components

### Runtime entry

- [CLI runner](https://github.com/gloudx/pil/blob/main/cmd/pil/main.go): `cmd/pil/main.go`

### Language runtime

- [VM context](https://github.com/gloudx/pil/blob/main/vm/vm.go): `vm/vm.go`
- [Lisp reader](https://github.com/gloudx/pil/blob/main/vm/read.go): `vm/read.go`
- [Evaluator](https://github.com/gloudx/pil/blob/main/vm/eval.go): `vm/eval.go`
- [Built-in functions](https://github.com/gloudx/pil/tree/main/vm): `vm`
- [Object model](https://github.com/gloudx/pil/blob/main/vm/oop.go): `vm/oop.go`
- [I/O primitives](https://github.com/gloudx/pil/blob/main/vm/builtin_io2.go): `vm/builtin_io2.go`
- [Go networking](https://github.com/gloudx/pil/blob/main/vm/net.go): `vm/net.go`
- [FFI bridge](https://github.com/gloudx/pil/blob/main/vm/ffi_on.go): `vm/ffi_on.go`

### Persistence

- [DB built-ins](https://github.com/gloudx/pil/blob/main/db/builtin.go): `db/builtin.go`
- [External symbols](https://github.com/gloudx/pil/blob/main/vm/extern.go): `vm/extern.go`
- [Block store](https://github.com/gloudx/pil/blob/main/db/store.go): `db/store.go`

### PicoLisp capabilities

- [Entity relations](https://github.com/gloudx/pil/tree/main/lisp): `lisp`
- [Pilog solver](https://github.com/gloudx/pil/blob/main/vm/pilog.go): `vm/pilog.go`
- [Web framework](https://github.com/gloudx/pil/tree/main/lisp): `lisp`

### Web client

- [Form client](https://github.com/gloudx/pil/blob/main/lisp/lib/form.js): `lisp/lib/form.js`
- [Canvas client](https://github.com/gloudx/pil/blob/main/lisp/lib/canvas.js): `lisp/lib/canvas.js`
- [GIS client](https://github.com/gloudx/pil/blob/main/lisp/lib/gis.js): `lisp/lib/gis.js`
- [PLIO decoder](https://github.com/gloudx/pil/blob/main/lisp/lib/plio.js): `lisp/lib/plio.js`

### Other components

- **Lisp user**

## Connections

- Lisp user → CLI runner: runs source
- CLI runner → VM context: creates VM (evidence: `cmd/pil/main.go`)
- CLI runner → DB built-ins: registers DB (evidence: `cmd/pil/main.go`)
- CLI runner → Lisp reader: loads files (evidence: `cmd/pil/main.go`)
- CLI runner → Evaluator: evaluates input (evidence: `cmd/pil/main.go`)
- Lisp reader → Evaluator: produces forms
- Evaluator → Built-in functions: dispatches functions
- VM context → Object model: provides runtime
- VM context → I/O primitives: provides runtime
- VM context → Go networking: provides sockets
- VM context → FFI bridge: offers optional bridge
- DB built-ins → Block store: commits records (evidence: `db/builtin.go`)
- Block store → External symbols: loads values (evidence: `db/store.go`)
- DB built-ins → External symbols: registers store
- Entity relations → DB built-ins: uses store API
- Entity relations → Block store: persists objects
- Pilog solver → Evaluator: runs goal code (evidence: `vm/pilog.go`)
- Web framework → Go networking: serves pages
- Form client → Web framework: posts form actions (evidence: `lisp/lib/form.js`)
- Canvas client → Web framework: requests drawing (evidence: `lisp/lib/canvas.js`)
- GIS client → Form client: calls Lisp actions (evidence: `lisp/lib/gis.js`)
- PLIO decoder → Web framework: decodes PLIO data
