# nehanth/pooled architecture

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

- Interactive diagram: https://gitdiagram.com/nehanth/pooled
- Repository: https://github.com/nehanth/pooled

## Overview

Pooled is a browser-based, peer-to-peer LLM runtime: participants join a room, distribute model layers across their GPUs, and generate chat or coding-agent responses without a central inference server. The room coordinates membership and inference; each device executes its assigned layers, with hidden states transferred between peers. Additional branches expose room inference through local API and OpenClaw integrations, and let Code mode build and preview apps. The README documents major capabilities; several subsystem links below therefore cite it where source excerpts do not show the implementation.

Main entry points: [`room/pipeline.js`](https://github.com/nehanth/pooled/blob/main/room/pipeline.js) (Room orchestration), [`room.js`](https://github.com/nehanth/pooled/blob/main/room.js) (Room app), [`packages/room-node/source.js`](https://github.com/nehanth/pooled/blob/main/packages/room-node/source.js) (Model sourcing), [`harness/agent.js`](https://github.com/nehanth/pooled/blob/main/harness/agent.js) (Coding agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_room["Room coordination"]
  node_roomcoord["Room orchestration<br/>[pipeline.js]"]
  node_membership["Join and presence<br/>[joingate.js]"]
  node_transport["Peer transport<br/>[transport.js]"]
  node_modelplan["Layer planning<br/>[plan.js]"]
end

subgraph group_inference["Distributed inference"]
  node_modelsource["Model sourcing<br/>[source.js]"]
  node_weights["GGUF loading<br/>[gguf.js]"]
  node_gpuengine["WebGPU engine<br/>[qwen35.js]"]
  node_kernels["GPU kernels<br/>[qwen35.js]"]
  node_generation["Token generation<br/>[generate.js]"]
  node_conversation["Conversation state<br/>[conversation.js]"]
end

subgraph group_coding["Code mode"]
  node_codeagent["Coding agent<br/>[agent.js]"]
  node_codemodel["Agent model adapter<br/>[engine-model.js]"]
  node_preview["Sandboxed preview<br/>[preview.js]"]
end

subgraph group_interfaces["User interfaces"]
  node_roomui["Room app<br/>[room.js]"]
end

subgraph group_integrations["External integrations"]
  node_serveapi["Room API<br/>[api.js]"]
  node_localcli["Local API bridge<br/>[serverun.js]"]
  node_openclaw["OpenClaw provider<br/>[pool.js]"]
end

node_person(("Room participant"))
node_modelhub["Model sources"]
node_relay["TURN relay"]

node_person -->|"starts or joins"| node_roomui
node_roomui -->|"joins room"| node_membership
node_roomui -->|"runs room"| node_roomcoord
node_roomui -->|"plans layers"| node_modelplan
node_roomcoord -->|"sends hidden states"| node_transport
node_roomcoord -->|"runs inference"| node_generation
node_roomcoord -->|"manages turns"| node_conversation
node_modelplan -->|"assigns layers"| node_modelsource
node_modelsource -->|"downloads weights"| node_modelhub
node_modelsource -.->|"loads model data"| node_weights
node_weights -->|"provides tensors"| node_gpuengine
node_gpuengine -->|"dispatches kernels"| node_kernels
node_generation -->|"executes tokens"| node_gpuengine
node_person -->|"requests app"| node_codeagent
node_codeagent -->|"generates changes"| node_codemodel
node_codemodel -->|"generates tokens"| node_generation
node_codeagent -->|"builds and fixes"| node_preview
node_person -->|"sends API request"| node_localcli
node_localcli -->|"joins as client"| node_roomcoord
node_roomcoord -->|"serves requests"| node_serveapi
node_person -->|"configures provider"| node_openclaw
node_openclaw -->|"opens room"| node_roomcoord
node_transport -.->|"falls back to relay"| node_relay

click node_roomui "https://github.com/nehanth/pooled/blob/main/room.js"
click node_roomcoord "https://github.com/nehanth/pooled/blob/main/room/pipeline.js"
click node_membership "https://github.com/nehanth/pooled/blob/main/room/joingate.js"
click node_transport "https://github.com/nehanth/pooled/blob/main/room/transport.js"
click node_modelplan "https://github.com/nehanth/pooled/blob/main/room/plan.js"
click node_modelsource "https://github.com/nehanth/pooled/blob/main/packages/room-node/source.js"
click node_weights "https://github.com/nehanth/pooled/blob/main/engine/gguf.js"
click node_gpuengine "https://github.com/nehanth/pooled/blob/main/engine/qwen35.js"
click node_kernels "https://github.com/nehanth/pooled/blob/main/engine/wgsl/qwen35.js"
click node_generation "https://github.com/nehanth/pooled/blob/main/engine/generate.js"
click node_conversation "https://github.com/nehanth/pooled/blob/main/room/conversation.js"
click node_serveapi "https://github.com/nehanth/pooled/blob/main/room/api.js"
click node_codeagent "https://github.com/nehanth/pooled/blob/main/harness/agent.js"
click node_codemodel "https://github.com/nehanth/pooled/blob/main/harness/engine-model.js"
click node_preview "https://github.com/nehanth/pooled/blob/main/harness/preview.js"
click node_localcli "https://github.com/nehanth/pooled/blob/main/cli/lib/serverun.js"
click node_openclaw "https://github.com/nehanth/pooled/blob/main/packages/openclaw/src/pool.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_roomcoord,node_membership,node_transport,node_modelplan toneBlue
class node_modelsource,node_weights,node_gpuengine,node_kernels,node_generation,node_conversation toneAmber
class node_codeagent,node_codemodel,node_preview toneMint
class node_roomui toneRose
class node_serveapi,node_localcli,node_openclaw,node_person,node_modelhub,node_relay toneIndigo
```

## Components

### Room coordination

- [Room orchestration](https://github.com/nehanth/pooled/blob/main/room/pipeline.js): `room/pipeline.js`
- [Join and presence](https://github.com/nehanth/pooled/blob/main/room/joingate.js): `room/joingate.js`
- [Peer transport](https://github.com/nehanth/pooled/blob/main/room/transport.js): `room/transport.js`
- [Layer planning](https://github.com/nehanth/pooled/blob/main/room/plan.js): `room/plan.js`

### Distributed inference

- [Model sourcing](https://github.com/nehanth/pooled/blob/main/packages/room-node/source.js): `packages/room-node/source.js`
- [GGUF loading](https://github.com/nehanth/pooled/blob/main/engine/gguf.js): `engine/gguf.js`
- [WebGPU engine](https://github.com/nehanth/pooled/blob/main/engine/qwen35.js): `engine/qwen35.js`
- [GPU kernels](https://github.com/nehanth/pooled/blob/main/engine/wgsl/qwen35.js): `engine/wgsl/qwen35.js`
- [Token generation](https://github.com/nehanth/pooled/blob/main/engine/generate.js): `engine/generate.js`
- [Conversation state](https://github.com/nehanth/pooled/blob/main/room/conversation.js): `room/conversation.js`

### Code mode

- [Coding agent](https://github.com/nehanth/pooled/blob/main/harness/agent.js): `harness/agent.js`
- [Agent model adapter](https://github.com/nehanth/pooled/blob/main/harness/engine-model.js): `harness/engine-model.js`
- [Sandboxed preview](https://github.com/nehanth/pooled/blob/main/harness/preview.js): `harness/preview.js`

### User interfaces

- [Room app](https://github.com/nehanth/pooled/blob/main/room.js): `room.js`

### External integrations

- [Room API](https://github.com/nehanth/pooled/blob/main/room/api.js): `room/api.js`
- [Local API bridge](https://github.com/nehanth/pooled/blob/main/cli/lib/serverun.js): `cli/lib/serverun.js`
- [OpenClaw provider](https://github.com/nehanth/pooled/blob/main/packages/openclaw/src/pool.js): `packages/openclaw/src/pool.js`

### Other components

- **Room participant**
- **Model sources**
- **TURN relay**

## Connections

- Room participant → Room app: starts or joins (evidence: `README.md`)
- Room app → Join and presence: joins room (evidence: `room.js`)
- Room app → Room orchestration: runs room (evidence: `room.js`)
- Room app → Layer planning: plans layers (evidence: `README.md`)
- Room orchestration → Peer transport: sends hidden states (evidence: `room/pipeline.js`)
- Room orchestration → Token generation: runs inference (evidence: `room.js`)
- Room orchestration → Conversation state: manages turns (evidence: `room/pipeline.js`)
- Layer planning → Model sourcing: assigns layers (evidence: `README.md`)
- Model sourcing → Model sources: downloads weights (evidence: `README.md`)
- Model sourcing → GGUF loading: loads model data
- GGUF loading → WebGPU engine: provides tensors (evidence: `engine/qwen35.js`)
- WebGPU engine → GPU kernels: dispatches kernels (evidence: `engine/qwen35.js`)
- Token generation → WebGPU engine: executes tokens (evidence: `engine/generate.js`)
- Room participant → Coding agent: requests app (evidence: `README.md`)
- Coding agent → Agent model adapter: generates changes (evidence: `harness/engine-model.js`)
- Agent model adapter → Token generation: generates tokens
- Coding agent → Sandboxed preview: builds and fixes (evidence: `README.md`)
- Room participant → Local API bridge: sends API request (evidence: `README.md`)
- Local API bridge → Room orchestration: joins as client (evidence: `README.md`)
- Room orchestration → Room API: serves requests (evidence: `room.js`)
- Room participant → OpenClaw provider: configures provider
- OpenClaw provider → Room orchestration: opens room (evidence: `packages/openclaw/src/pool.js`)
- Peer transport → TURN relay: falls back to relay (evidence: `README.md`)
