Spaces:
Paused
Paused
metadata
title: Architecture
summary: Stack overview, request flow, and adapter model
Paperclip is a monorepo with four main layers.
Stack Overview
βββββββββββββββββββββββββββββββββββββββ
β React UI (Vite) β
β Dashboard, org management, tasks β
βββββββββββββββββββββββββββββββββββββββ€
β Express.js REST API (Node.js) β
β Routes, services, auth, adapters β
βββββββββββββββββββββββββββββββββββββββ€
β PostgreSQL (Drizzle ORM) β
β Schema, migrations, embedded mode β
βββββββββββββββββββββββββββββββββββββββ€
β Adapters β
β Claude Local, Codex Local, β
β Process, HTTP β
βββββββββββββββββββββββββββββββββββββββ
Technology Stack
| Layer | Technology |
|---|---|
| Frontend | React 19, Vite 6, React Router 7, Radix UI, Tailwind CSS 4, TanStack Query |
| Backend | Node.js 20+, Express.js 5, TypeScript |
| Database | PostgreSQL 17 (or embedded PGlite), Drizzle ORM |
| Auth | Better Auth (sessions + API keys) |
| Adapters | Claude Code CLI, Codex CLI, shell process, HTTP webhook |
| Package manager | pnpm 9 with workspaces |
Repository Structure
paperclip/
βββ ui/ # React frontend
β βββ src/pages/ # Route pages
β βββ src/components/ # React components
β βββ src/api/ # API client
β βββ src/context/ # React context providers
β
βββ server/ # Express.js API
β βββ src/routes/ # REST endpoints
β βββ src/services/ # Business logic
β βββ src/adapters/ # Agent execution adapters
β βββ src/middleware/ # Auth, logging
β
βββ packages/
β βββ db/ # Drizzle schema + migrations
β βββ shared/ # API types, constants, validators
β βββ adapter-utils/ # Adapter interfaces and helpers
β βββ adapters/
β βββ claude-local/ # Claude Code adapter
β βββ codex-local/ # OpenAI Codex adapter
β
βββ skills/ # Agent skills
β βββ paperclip/ # Core Paperclip skill (heartbeat protocol)
β
βββ cli/ # CLI client
β βββ src/ # Setup and control-plane commands
β
βββ doc/ # Internal documentation
Request Flow
When a heartbeat fires:
- Trigger β Scheduler, manual invoke, or event (assignment, mention) triggers a heartbeat
- Adapter invocation β Server calls the configured adapter's
execute()function - Agent process β Adapter spawns the agent (e.g. Claude Code CLI) with Paperclip env vars and a prompt
- Agent work β The agent calls Paperclip's REST API to check assignments, checkout tasks, do work, and update status
- Result capture β Adapter captures stdout, parses usage/cost data, extracts session state
- Run record β Server records the run result, costs, and any session state for next heartbeat
Adapter Model
Adapters are the bridge between Paperclip and agent runtimes. Each adapter is a package with three modules:
- Server module β
execute()function that spawns/calls the agent, plus environment diagnostics - UI module β stdout parser for the run viewer, config form fields for agent creation
- CLI module β terminal formatter for
paperclipai run --watch
Built-in adapters: claude_local, codex_local, process, http. You can create custom adapters for any runtime.
Key Design Decisions
- Control plane, not execution plane β Paperclip orchestrates agents; it doesn't run them
- Company-scoped β all entities belong to exactly one company; strict data boundaries
- Single-assignee tasks β atomic checkout prevents concurrent work on the same task
- Adapter-agnostic β any runtime that can call an HTTP API works as an agent
- Embedded by default β zero-config local mode with embedded PostgreSQL