Skip to content

Architecture Overview

Snippbot is organized as a Python monorepo with a React frontend. All components run on your own infrastructure as a single self-hosted daemon.

┌──────────────────────────────────┐
│ Client Interfaces │
│ CLI · Web UI · REST API · WS │
└────────────────┬─────────────────┘
┌────────────────▼─────────────────┐
│ Starlette HTTP Server │
│ packages/local/src/snippbot/ │
│ server.py │
│ port 18781 (API + UI) │
│ │
│ Middleware: Auth · CORS · CSRF │
│ Rate Limiting · Security Headers │
└────────────────┬─────────────────┘
┌───────────────────────────┼──────────────────────────┐
│ │ │
┌────────▼───────┐ ┌──────────▼────────┐ ┌──────────▼────────┐
│ Core Engine │ │ Background │ │ Integrations │
│ snippbot_core │ │ Workers │ │ │
│ │ │ │ │ • Browser (CDP) │
│ • Projects │ │ • Scheduler │ │ • Sandbox │
│ • Agents │ │ • Workflow engine │ │ (Docker/Podman) │
│ • Memory │ │ • Sub-agent mgr │ │ • Channels (6) │
│ • Security │ │ • Insight queue │ │ • Email (SMTP) │
│ • SNIPP │ │ • Digest engine │ │ • Devices (WS) │
│ • Hooks │ │ • MCP servers │ │ • Audio (STT/TTS) │
│ • Config │ │ • Thinking engine │ │ • Push (APNs/FCM) │
│ • Security │ │ • Game engine │ │ • Files / Assets │
│ • Proactivity │ │ │ │ │
└────────┬───────┘ └──────────┬─────────┘ └────────────────────┘
│ │
└───────────────────────────┤
┌────────────────▼─────────────────┐
│ SQLite Databases │
│ ~/.snippbot/*.db │
└──────────────────────────────────┘
packages/
├── core/ → snippbot_core Shared business logic
│ └── src/snippbot_core/
│ ├── config.py 40+ env vars, multi-DB config
│ ├── event_bus.py Pub/sub, JSONL logging, 100+ event types
│ ├── project_store.py Project/Phase/Task FSM
│ ├── executor.py Task execution with worker pools
│ ├── proactivity.py 5-level insight generation
│ ├── risk_scorer.py Execution risk computation
│ ├── memory/ 5-tier: episodic, keyword, vector, hybrid, graph
│ ├── scheduler/ Cron/every/at jobs, NL parsing, chains
│ ├── workflows/ DAG step execution, templates, checkpoints
│ ├── sub_agent/ Multi-agent orchestration, team models
│ ├── thinking/ Autonomous reasoning cycles
│ ├── chat/ Conversations, context, command processor
│ ├── channel_adapter/ 6 messaging platform adapters
│ ├── tools/browser/ CDP browser automation, stealth, recording
│ ├── sandbox/ Docker/Podman/bubblewrap/firejail isolation
│ ├── hooks/ Event hooks, webhooks, analytics
│ ├── mcp/ MCP server lifecycle, tool discovery
│ ├── audio/ STT + TTS providers (local + cloud)
│ ├── email/ IMAP + SMTP, templates
│ ├── device/ Device registry, pairing, protocol
│ ├── snipp/ Token economy, wallets, escrow, reputation
│ ├── security/ DLP, CSRF, rate limiting, secret store, scanner
│ ├── game/ Game saves, world state (My Infinite Saga)
│ ├── license/ Tier-based feature gating
│ ├── marketplace/ Package management, manifests, permissions
│ ├── push/ APNs, FCM, Web Push
│ ├── notifications/ Webhook delivery, subscriptions
│ ├── digest/ Periodic summary composition
│ ├── remote_session/ Secure session sharing, TOTP
│ ├── assets/ File and asset storage
│ └── insight_queue.py Proactive insight delivery
├── local/ → snippbot Self-hosted daemon
│ └── src/snippbot/
│ ├── server.py Starlette app, middleware stack
│ └── api/ 47 REST API route modules (236+ endpoints)
├── cli/ → snippbot_cli CLI commands
│ └── src/snippbot_cli/
│ ├── commands/ 17 command groups (60+ commands)
│ └── user_config.py ~/.snippbot/config.toml
├── ui/ → React frontend Web interface
│ └── src/
│ ├── pages/ 37 page components
│ ├── components/ 30+ feature areas
│ └── stores/ 12 Zustand state stores
├── device/ → snippbot_device Device agent (runs on remote devices)
├── shared/ → Shared types TypeScript type definitions
├── docs/ → Documentation Starlight docs site
├── desktop/ → Desktop app Electron wrapper
├── mobile/ → Mobile app React Native
├── registry/ → Package registry Singularity registry
├── site/ → Marketing site snippbot.com
├── site-marketplace/ → Marketplace site Singularity marketplace
├── snipp-api/ → SNIPP API Token economy backend
├── snipp-contracts/ → SNIPP contracts Smart contracts
├── edge/ → snippbot_edge [Future: hybrid edge]
└── cloud/ → snippbot_cloud [Future: managed service]

REST API request:

Client
│ HTTP request + Bearer token
Starlette middleware
│ Auth check (token → user lookup)
│ CORS validation
│ CSRF protection
│ Rate limiting
│ Security headers
Route handler (packages/local/src/snippbot/api/)
│ Input validation
│ Permission check
│ Business logic call
snippbot_core module
│ Database read/write
│ Background task dispatch
│ Event bus publish
JSON response

Task execution flow:

POST /api/projects/{id}/approve
project_store.py: status → approved
Background worker picks up project
Permission check: verify agent permissions
executor.py: load agent + tools + memory context
Team orchestration: Architect → Executor → Reviewer
LLM API call (streaming)
Tool calls executed (browser, files, search, sandbox, etc.)
Episode written to memory
Task status → completed / failed
Event bus → hooks, notifications, digest, insights

All components communicate via an in-process pub/sub event bus with 100+ event types:

# Publish an event
await event_bus.publish("task.completed", {"task_id": "...", "status": "completed"})
# Subscribe to events
@event_bus.subscribe("task.*")
async def on_task_event(event_type: str, data: dict):
...

Events are also written to a JSONL log at ~/.snippbot/events.jsonl for replay and debugging.

Snippbot uses multiple SQLite databases, all in ~/.snippbot/:

FilePurpose
snippbot.dbProjects, phases, tasks, agents, conversations, messages
auth.dbUsers, sessions, API keys, refresh tokens
memory.dbEpisodic memory, embeddings, metadata
vector.dbVector embeddings (FTS5 + faiss)
graph.dbKnowledge graph (entities, relations)
scheduler.dbJobs, run history, chains, NL parsing history
workflows.dbWorkflow definitions, versions, templates, runs, step runs
sub_agents.dbSub-agent state, messages, approvals

| settings.db | UI settings (14 categories) | | channels.db | Channel platform credentials, bindings, access | | devices.db | Paired device registry, capabilities, health | | insights.db | Proactive insights, engagement signals | | credentials.db | Encrypted secrets and audit log | | execution.db | Execution jobs, plans, messages, worker state |

Plus additional databases for metrics, sandbox audit, game saves, notifications, thinking cycles, and subsystem configuration.