# todepond/sandpond architecture

> Architecture diagram of the GitHub repository todepond/sandpond, 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/todepond/sandpond
- Repository: https://github.com/todepond/sandpond

## Overview

SandPond is a browser-based spatial-cell engine: users choose elements and place them into a world, where spatial rules update the cells and the world is rendered. SpaceTode is the element language; the README also highlights custom elements and the example families represented by Life, Sandbox, and T2Tile. The excerpts show the dropper writing into the world and the main loop selecting update behavior. Other links are omitted where the sampled code does not establish them.

Main entry points: [`Source/Engine/Dropper.js`](https://github.com/todepond/sandpond/blob/main/Source/Engine/Dropper.js) (Element placement), [`Source/Engine/World.js`](https://github.com/todepond/sandpond/blob/main/Source/Engine/World.js) (Cell world), [`main.js`](https://github.com/todepond/sandpond/blob/main/main.js) (Runtime loop), [`Libraries/spacetode.js`](https://github.com/todepond/sandpond/blob/main/Libraries/spacetode.js) (SpaceTode language)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_ui["Controls and selection<br/>[ui.js]"]
  node_dropper["Element placement<br/>[Dropper.js]"]
end

subgraph group_simulation["Simulation engine"]
  node_main["Runtime loop<br/>[main.js]"]
  node_scheduling["Shuffle worker<br/>[ShuffleWorker.js]"]
end

subgraph group_language["Elements and language"]
  node_spacetode["SpaceTode language<br/>[spacetode.js]"]
  node_eatlegacy["Legacy parser helpers<br/>[eatlegacy.js]"]
  node_life["Life elements<br/>[Life.js]"]
  node_sandbox["Sandbox elements<br/>[Sandbox.js]"]
  node_t2tile["T2Tile elements<br/>[T2Tile.js]"]
  node_word["Word artwork<br/>[TwoTwoTwoTwo.js]"]
end

subgraph group_rendering["World rendering"]
  node_world[("Cell world<br/>[World.js]")]
end

node_user(("Player"))
node_habitat["Habitat library<br/>[habitat.js]"]

node_user -->|"selects controls"| node_ui
node_user -.->|"places elements"| node_dropper
node_main -->|"tries placement"| node_dropper
node_dropper -->|"selects cell"| node_world
node_dropper -->|"writes atom"| node_world
node_main -->|"creates worker"| node_scheduling
node_spacetode -->|"requires parser"| node_eatlegacy
node_spacetode -->|"requires library"| node_habitat
node_word -->|"selects cells"| node_world

click node_ui "https://github.com/todepond/sandpond/blob/main/ui.js"
click node_main "https://github.com/todepond/sandpond/blob/main/main.js"
click node_dropper "https://github.com/todepond/sandpond/blob/main/Source/Engine/Dropper.js"
click node_world "https://github.com/todepond/sandpond/blob/main/Source/Engine/World.js"
click node_scheduling "https://github.com/todepond/sandpond/blob/main/Source/Engine/ShuffleWorker.js"
click node_spacetode "https://github.com/todepond/sandpond/blob/main/Libraries/spacetode.js"
click node_eatlegacy "https://github.com/todepond/sandpond/blob/main/Libraries/eatlegacy.js"
click node_habitat "https://github.com/todepond/sandpond/blob/main/Libraries/habitat.js"
click node_life "https://github.com/todepond/sandpond/blob/main/Source/Elements/Life.js"
click node_sandbox "https://github.com/todepond/sandpond/blob/main/Source/Elements/Sandbox.js"
click node_t2tile "https://github.com/todepond/sandpond/blob/main/Source/Elements/T2Tile.js"
click node_word "https://github.com/todepond/sandpond/blob/main/Source/Elements/TwoTwoTwoTwo.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_ui,node_dropper toneBlue
class node_main,node_scheduling toneAmber
class node_spacetode,node_eatlegacy,node_life,node_sandbox,node_t2tile,node_word toneMint
class node_world toneRose
class node_user toneIndigo
class node_habitat toneTeal
```

## Components

### User interaction

- [Controls and selection](https://github.com/todepond/sandpond/blob/main/ui.js): `ui.js`
- [Element placement](https://github.com/todepond/sandpond/blob/main/Source/Engine/Dropper.js): `Source/Engine/Dropper.js`

### Simulation engine

- [Runtime loop](https://github.com/todepond/sandpond/blob/main/main.js): `main.js`
- [Shuffle worker](https://github.com/todepond/sandpond/blob/main/Source/Engine/ShuffleWorker.js): `Source/Engine/ShuffleWorker.js`

### Elements and language

- [SpaceTode language](https://github.com/todepond/sandpond/blob/main/Libraries/spacetode.js): `Libraries/spacetode.js`
- [Legacy parser helpers](https://github.com/todepond/sandpond/blob/main/Libraries/eatlegacy.js): `Libraries/eatlegacy.js`
- [Life elements](https://github.com/todepond/sandpond/blob/main/Source/Elements/Life.js): `Source/Elements/Life.js`
- [Sandbox elements](https://github.com/todepond/sandpond/blob/main/Source/Elements/Sandbox.js): `Source/Elements/Sandbox.js`
- [T2Tile elements](https://github.com/todepond/sandpond/blob/main/Source/Elements/T2Tile.js): `Source/Elements/T2Tile.js`
- [Word artwork](https://github.com/todepond/sandpond/blob/main/Source/Elements/TwoTwoTwoTwo.js): `Source/Elements/TwoTwoTwoTwo.js`

### World rendering

- [Cell world](https://github.com/todepond/sandpond/blob/main/Source/Engine/World.js): `Source/Engine/World.js`

### Other components

- **Player**
- [Habitat library](https://github.com/todepond/sandpond/blob/main/Libraries/habitat.js): `Libraries/habitat.js`

## Connections

- Player → Controls and selection: selects controls (evidence: `ui.js`)
- Player → Element placement: places elements
- Runtime loop → Element placement: tries placement (evidence: `main.js`)
- Element placement → Cell world: selects cell (evidence: `Source/Engine/Dropper.js`)
- Element placement → Cell world: writes atom (evidence: `Source/Engine/Dropper.js`)
- Runtime loop → Shuffle worker: creates worker (evidence: `main.js`)
- SpaceTode language → Legacy parser helpers: requires parser (evidence: `Libraries/spacetode.js`)
- SpaceTode language → Habitat library: requires library (evidence: `Libraries/spacetode.js`)
- Word artwork → Cell world: selects cells (evidence: `Source/Elements/TwoTwoTwoTwo.js`)
