# parth3930/threadloom architecture

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

- Interactive diagram: https://gitdiagram.com/parth3930/threadloom
- Repository: https://github.com/parth3930/threadloom

## Overview

#### Purpose and Entry Points
Threadloom is a Rust workspace for building reactive web/WASM UIs, native/serverless APIs, desktop apps, and Android apps. Consumers normally depend on the façade crate at `crates/threadloom/src/lib.rs`; application development and builds flow through the `distaff` CLI at `crates/distaff/src/main.rs`. The generated-project baseline is `crates/distaff/template/src/main.rs`, with an optional desktop binary at `crates/distaff/template/src/bin/desktop.rs`.

#### Public Framework Surface
`threadloom` re-exports the framework’s primary API and prelude, hiding most workspace-level composition from apps: `crates/threadloom/src/lib.rs`. The compile-time UI language is implemented by the procedural macro crate at `crates/threadloom-macro/src/lib.rs`. Reusable layout and presentation primitives such as Container, Row, Column, and Section belong to `crates/threadloom-ui/src/lib.rs` and `crates/threadloom-ui/src/components/layout.rs`.

#### Reactive Core
The framework’s state and execution model is centered in `crates/threadloom-core/src/signal.rs`, which provides fine-grained reactive signals. Shared rendering/context types and resource support reside in `crates/threadloom-core/src/context.rs` and `crates/threadloom-core/src/resource.rs`. Async work is separated into `crates/threadloom-scheduler/src/lib.rs`, forming a boundary between reactive UI updates and scheduled/background tasks.

#### Browser/WASM Rendering
Browser applications compile Rust to WebAssembly and use `threadloom-dom` as the runtime integration layer. Its public entry point is `crates/threadloom-dom/src/lib.rs`; rendering and DOM mutation are handled in `crates/threadloom-dom/src/render.rs` and `crates/threadloom-dom/src/patch.rs`. Browser-facing boundaries include events, persistence, and development WebSocket support in `crates/threadloom-dom/src/events.rs`, `crates/threadloom-dom/src/storage.rs`, and `crates/threadloom-dom/src/ws.rs`.

#### Server and API Boundary
Server capabilities are abstracted behind `crates/threadloom-server/src/lib.rs`, supporting native Actix Web execution and Vercel-oriented serverless deployment as described by the project. Apps define API endpoints separately from pages; the template demonstrates route aggregation in `crates/distaff/template/src/api_routes.rs` and an endpoint implementation in `crates/distaff/template/src/api/hello/route.rs`. Core RPC/client-related primitives are in `crates/threadloom-core/src/rpc.rs`.

#### Tooling, Build, and Live Development
`distaff` owns project scaffolding, execution, build orchestration, hot reload, and production patching: `crates/distaff/src/init.rs`, `crates/distaff/src/hot_reload.rs`, and `crates/distaff/src/hot_patch.rs`. Its internal server and plugin orchestration are in `crates/distaff/src/server.rs` and `crates/distaff/src/plugins.rs`. The CLI bridges Cargo/Rust compilation, WASM/browser assets, and platform-specific launch flows rather than requiring an application-managed JavaScript build pipeline.

#### Native Targets and Reference Application
Desktop support is exposed through `crates/threadloom-desktop/src/lib.rs`; Android Rust integration is exposed by `crates/threadloom-android/src/lib.rs`, with Android WebView/activity bridge code packaged under `crates/distaff/android_java/com/threadloom/app/`. The `examples/whiteboard` app is the end-to-end reference: its app entry is `examples/whiteboard/src/main.rs`, its collaborative board UI is `examples/whiteboard/src/pages/board/page.rs`, and its WebSocket handling is `examples/whiteboard/src/ws/handler.rs`. It also demonstrates route-based APIs and a database boundary via `examples/whiteboard/src/api_routes.rs` and `examples/whiteboard/src/db.rs`.

Main entry points: [`crates/threadloom/src/lib.rs`](https://github.com/parth3930/threadloom/blob/master/crates/threadloom/src/lib.rs) (threadloom façade), [`crates/distaff/src/main.rs`](https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/main.rs) (distaff CLI), [`crates/threadloom-core/src/signal.rs`](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/signal.rs) (Reactive signals), [`crates/threadloom-dom/src/lib.rs`](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/lib.rs) (DOM runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_framework["Framework crates"]
  node_facade["threadloom façade<br/>public API<br/>[lib.rs]"]
  node_macro{{"UI macro<br/>procedural macro<br/>[lib.rs]"}}
  node_ui["UI primitives<br/>component library<br/>[lib.rs]"]
  node_signals["Reactive signals<br/>reactive core<br/>[signal.rs]"]
  node_context["Context and resources<br/>core support<br/>[context.rs]"]
  node_scheduler["Scheduler<br/>async runtime<br/>[lib.rs]"]
  node_rpc["RPC primitives<br/>core API<br/>[rpc.rs]"]
  node_dom["DOM runtime<br/>WASM browser runtime<br/>[lib.rs]"]
  node_render["DOM render and patch<br/>renderer<br/>[render.rs]"]
  node_browser_boundaries["Browser boundaries<br/>events, storage, WebSocket<br/>[events.rs]"]
  node_server["Server runtime<br/>API runtime<br/>[lib.rs]"]
  node_desktop["Desktop runtime<br/>native runtime<br/>[lib.rs]"]
  node_android["Android integration<br/>mobile runtime<br/>[lib.rs]"]
end

subgraph group_tooling["Tooling"]
  node_distaff{{"distaff CLI<br/>build CLI<br/>[main.rs]"}}
  node_live_dev["Live development<br/>hot reload and patching<br/>[hot_reload.rs]"]
  node_tool_server["Tool server and plugins<br/>orchestration<br/>[server.rs]"]
end

subgraph group_apps["Applications"]
  node_template_app["Generated app baseline<br/>application template<br/>[main.rs]"]
  node_template_api["Template API routes<br/>[api_routes.rs]"]
  node_whiteboard["Whiteboard app<br/>reference application<br/>[main.rs]"]
  node_board["Collaborative board UI<br/>application page<br/>[page.rs]"]
  node_whiteboard_ws["Board WebSocket handler<br/>application WebSocket<br/>[handler.rs]"]
  node_whiteboard_db[("Whiteboard database<br/>database boundary<br/>[db.rs]")]
end

node_facade -->|"re-exports"| node_macro
node_facade -->|"re-exports"| node_ui
node_facade -->|"re-exports"| node_signals
node_facade -.->|"selects for browser"| node_dom
node_signals -->|"uses render context"| node_context
node_signals -->|"schedules async work"| node_scheduler
node_dom -->|"renders through"| node_render
node_render -->|"reacts to updates"| node_signals
node_dom -->|"integrates"| node_browser_boundaries
node_rpc -->|"connects clients to APIs"| node_server
node_distaff -->|"scaffolds"| node_template_app
node_distaff -->|"orchestrates"| node_tool_server
node_distaff -->|"drives"| node_live_dev
node_live_dev -.->|"uses development WebSocket"| node_browser_boundaries
node_template_app -->|"depends on"| node_facade
node_template_app -->|"defines APIs"| node_template_api
node_template_api -->|"runs on"| node_server
node_whiteboard -->|"uses"| node_facade
node_whiteboard -->|"hosts"| node_board
node_board -->|"collaborates via"| node_whiteboard_ws
node_whiteboard_ws -->|"persists data"| node_whiteboard_db
node_distaff -.->|"launches desktop target"| node_desktop
node_distaff -.->|"launches Android target"| node_android

click node_facade "https://github.com/parth3930/threadloom/blob/master/crates/threadloom/src/lib.rs"
click node_macro "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-macro/src/lib.rs"
click node_ui "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-ui/src/lib.rs"
click node_signals "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/signal.rs"
click node_context "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/context.rs"
click node_scheduler "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-scheduler/src/lib.rs"
click node_rpc "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/rpc.rs"
click node_dom "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/lib.rs"
click node_render "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/render.rs"
click node_browser_boundaries "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/events.rs"
click node_server "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-server/src/lib.rs"
click node_desktop "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-desktop/src/lib.rs"
click node_android "https://github.com/parth3930/threadloom/blob/master/crates/threadloom-android/src/lib.rs"
click node_distaff "https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/main.rs"
click node_live_dev "https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/hot_reload.rs"
click node_tool_server "https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/server.rs"
click node_template_app "https://github.com/parth3930/threadloom/blob/master/crates/distaff/template/src/main.rs"
click node_template_api "https://github.com/parth3930/threadloom/blob/master/crates/distaff/template/src/api_routes.rs"
click node_whiteboard "https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/main.rs"
click node_board "https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/pages/board/page.rs"
click node_whiteboard_ws "https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/ws/handler.rs"
click node_whiteboard_db "https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/db.rs"

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_facade,node_macro,node_ui,node_signals,node_context,node_scheduler,node_rpc,node_dom,node_render,node_browser_boundaries,node_server,node_desktop,node_android toneBlue
class node_distaff,node_live_dev,node_tool_server toneAmber
class node_template_app,node_template_api,node_whiteboard,node_board,node_whiteboard_ws,node_whiteboard_db toneMint
```

## Components

### Framework crates

Public UI, reactive, and platform runtime layers.

- [threadloom façade](https://github.com/parth3930/threadloom/blob/master/crates/threadloom/src/lib.rs): public API · Consumer-facing framework API and prelude. · `crates/threadloom/src/lib.rs`
- [UI macro](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-macro/src/lib.rs): procedural macro · Compile-time UI language implementation. · `crates/threadloom-macro/src/lib.rs`
- [UI primitives](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-ui/src/lib.rs): component library · Reusable layout and presentation components. · `crates/threadloom-ui/src/lib.rs`
- [Reactive signals](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/signal.rs): reactive core · Fine-grained state and update model. · `crates/threadloom-core/src/signal.rs`
- [Context and resources](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/context.rs): core support · Shared rendering context and resource support. · `crates/threadloom-core/src/context.rs`
- [Scheduler](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-scheduler/src/lib.rs): async runtime · Separates background work from reactive updates. · `crates/threadloom-scheduler/src/lib.rs`
- [RPC primitives](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-core/src/rpc.rs): core API · Client and RPC-related primitives. · `crates/threadloom-core/src/rpc.rs`
- [DOM runtime](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/lib.rs): WASM browser runtime · Browser runtime integration. · `crates/threadloom-dom/src/lib.rs`
- [DOM render and patch](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/render.rs): renderer · Rendering and DOM mutation pipeline. · `crates/threadloom-dom/src/render.rs`
- [Browser boundaries](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-dom/src/events.rs): events, storage, WebSocket · Browser events, persistence, and development WebSocket support. · `crates/threadloom-dom/src/events.rs`
- [Server runtime](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-server/src/lib.rs): API runtime · Native Actix and Vercel-oriented serverless execution. · `crates/threadloom-server/src/lib.rs`
- [Desktop runtime](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-desktop/src/lib.rs): native runtime · `crates/threadloom-desktop/src/lib.rs`
- [Android integration](https://github.com/parth3930/threadloom/blob/master/crates/threadloom-android/src/lib.rs): mobile runtime · Rust-side Android integration. · `crates/threadloom-android/src/lib.rs`

### Tooling

Project lifecycle and live-development orchestration.

- [distaff CLI](https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/main.rs): build CLI · Scaffolds, builds, runs, and coordinates platform launches. · `crates/distaff/src/main.rs`
- [Live development](https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/hot_reload.rs): hot reload and patching · Hot reload and production patching workflow. · `crates/distaff/src/hot_reload.rs`
- [Tool server and plugins](https://github.com/parth3930/threadloom/blob/master/crates/distaff/src/server.rs): orchestration · Internal server and plugin orchestration. · `crates/distaff/src/server.rs`

### Applications

Generated and reference application entry points.

- [Generated app baseline](https://github.com/parth3930/threadloom/blob/master/crates/distaff/template/src/main.rs): application template · Default application entry generated by the CLI. · `crates/distaff/template/src/main.rs`
- [Template API routes](https://github.com/parth3930/threadloom/blob/master/crates/distaff/template/src/api_routes.rs): API routes · Aggregates generated-app endpoints. · `crates/distaff/template/src/api_routes.rs`
- [Whiteboard app](https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/main.rs): reference application · End-to-end collaborative reference app. · `examples/whiteboard/src/main.rs`
- [Collaborative board UI](https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/pages/board/page.rs): application page · `examples/whiteboard/src/pages/board/page.rs`
- [Board WebSocket handler](https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/ws/handler.rs): application WebSocket · `examples/whiteboard/src/ws/handler.rs`
- [Whiteboard database](https://github.com/parth3930/threadloom/blob/master/examples/whiteboard/src/db.rs): database boundary · `examples/whiteboard/src/db.rs`

## Connections

- threadloom façade → UI macro: re-exports
- threadloom façade → UI primitives: re-exports
- threadloom façade → Reactive signals: re-exports
- threadloom façade → DOM runtime: selects for browser
- Reactive signals → Context and resources: uses render context
- Reactive signals → Scheduler: schedules async work
- DOM runtime → DOM render and patch: renders through
- DOM render and patch → Reactive signals: reacts to updates
- DOM runtime → Browser boundaries: integrates
- RPC primitives → Server runtime: connects clients to APIs
- distaff CLI → Generated app baseline: scaffolds
- distaff CLI → Tool server and plugins: orchestrates
- distaff CLI → Live development: drives
- Live development → Browser boundaries: uses development WebSocket
- Generated app baseline → threadloom façade: depends on
- Generated app baseline → Template API routes: defines APIs
- Template API routes → Server runtime: runs on
- Whiteboard app → threadloom façade: uses
- Whiteboard app → Collaborative board UI: hosts
- Collaborative board UI → Board WebSocket handler: collaborates via
- Board WebSocket handler → Whiteboard database: persists data
- distaff CLI → Desktop runtime: launches desktop target
- distaff CLI → Android integration: launches Android target
