Architecture
Understanding SeaClip's hub-spoke architecture and data flow
System Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SeaClip Hub โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ React Dashboard โ โ Express API โ โ WebSocket Hub โ โ
โ โ (Vite + Tailwind)โ โ (REST + Auth) โ โ (Real-time) โ โ
โ โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Service Layer โ โ
โ โ AgentService ยท DeviceService ยท IssueService ยท CostService โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Adapter Layer โ โ
โ โ SeaClaw ยท Ollama ยท AgentZero ยท Telegram ยท Process ยท HTTP โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Data Layer โ โ
โ โ PostgreSQL (Drizzle ORM) โ SpacetimeDB (Real-time) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโดโโโโโโ โโโโโโดโโโโโ โโโโโโโดโโโโโโ
โ Raspberry โ โ Jetson โ โ Laptop โ
โ Pi โ โ Orin โ โ (Linux) โ
โ Spoke โ โ Spoke โ โ Spoke โ
โโโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโ
Technology Stack
| Layer | Technology | Package |
|---|---|---|
| Dashboard | React 18, Vite, TailwindCSS, shadcn/ui | @seaclip/ui |
| API Server | Node.js, Express, tsx | @seaclip/server |
| Real-time | WebSocket (ws), SpacetimeDB | @seaclip/server |
| ORM | Drizzle ORM | @seaclip/server |
| Database | PostgreSQL 17 (prod), SQLite (dev) | โ |
| AI Runtime | Ollama, Agent Zero | adapter layer |
| CLI | Commander.js, Inquirer, Ora | @seaclip/cli |
| Monorepo | pnpm workspaces, Turborepo | root |
Hub vs Spoke
Hub (Central Server)
- Runs the dashboard UI
- Hosts the REST API
- Stores all data (PostgreSQL)
- Dispatches tasks to agents
- Monitors device health
- Handles authentication
Spoke (Edge Device)
- Runs AI agents locally
- Sends telemetry to hub
- Receives task assignments
- Executes LLM inference
- Reports results back
- Lightweight footprint
Request Flow: Heartbeat Lifecycle
A heartbeat run is the fundamental unit of agent activity:
Agent (spoke) Hub (server) Database
โ โ โ
โ 1. GET /api/companies/:c/ โ โ
โ agents/:a โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ โ
โ โ SELECT agent WHERE id=:a โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ agent config + instructions โ โ
โ โ โ
โ 2. GET /api/companies/:c/ โ โ
โ issues?assigneeAgentId=:a โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ [list of todo issues] โ โ
โ โ โ
โ 3. POST /issues/:id/checkout โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ UPDATE status=in_progress โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
โ run_id + issue detail โ โ
โ โ โ
โ [agent does the work] โ โ
โ โ โ
โ 4. PATCH /issues/:id โ โ
โ { status: "done" } โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ UPDATE issue โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ INSERT heartbeat_run โ
โ updated issue โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบโ
Database Schema
Core Tables
| Table | Description |
|---|---|
companies |
Top-level tenant / workspace |
agents |
AI agents, one per logical worker |
agent_configs |
Per-agent adapter configuration (JSON) |
issues |
Tasks / work items |
heartbeat_runs |
Audit log of agent invocations |
cost_entries |
Token + compute cost records |
devices |
Registered edge devices (spokes) |
device_telemetry |
Time-series telemetry snapshots |
Entity Relationships
companies (1) โโโโ (N) agents
companies (1) โโโโ (N) issues
companies (1) โโโโ (N) devices
agents (1) โโโโ (N) issues [assignee]
agents (1) โโโโ (N) heartbeat_runs
heartbeat_runs (1) โโ (N) cost_entries
devices (1) โโโโ (N) device_telemetry
Adapter Model
Adapters are pluggable drivers that communicate with different AI backends:
typescript
interface AgentAdapter {
// Invoke the agent โ send a task
invoke(params: InvokeParams): Promise<InvokeResult>;
// Check if agent is reachable
ping(): Promise<PingResult>;
// Optional: stream output in real time
stream?(params: InvokeParams): AsyncIterable<string>;
}
Available Adapters
| Adapter | Description |
|---|---|
seaclaw |
SSH + REST to SeaClaw edge nodes |
ollama |
HTTP to Ollama API with GPU tracking |
agent_zero |
Agent Zero sessions with memory sync |
telegram |
Telegram bot interface |
process |
Local CLI command execution |
http |
Generic webhook adapter |
WebSocket Events
Real-time events broadcast to connected clients:
| Event | Payload | Trigger |
|---|---|---|
issue:created |
Issue object | New issue inserted |
issue:updated |
Issue object | Status or field change |
agent:heartbeat |
{ agentId, status, runId } |
Heartbeat run completes |
device:telemetry |
Telemetry snapshot | Device posts telemetry |
device:status |
{ deviceId, status } |
Device online/offline |
Repository Structure
text
seaclip/
โโโ cli/ CLI tool (@seaclip/cli)
โ โโโ src/
โ โโโ commands/ One file per command
โ โโโ config/ Config read/write
โ โโโ checks/ Health check functions
โโโ server/ Express API (@seaclip/server)
โ โโโ src/
โ โโโ db/ Drizzle schema + migrations
โ โโโ routes/ Express routers
โ โโโ services/ Business logic
โ โโโ adapters/ Adapter implementations
โ โโโ ws/ WebSocket hub
โโโ ui/ React dashboard (@seaclip/ui)
โ โโโ src/
โ โโโ pages/ Route-based pages
โ โโโ components/ Shared UI components
โ โโโ lib/ API client, utilities
โโโ shared/ Shared types (@seaclip/shared)
โโโ spacetimedb/ SpacetimeDB module (Rust)
โโโ doc/ Extended documentation
โโโ docs/ HTML documentation (this site)
โโโ scripts/ Dev and ops scripts