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

Next Steps