Architecture
Backers is a single Rust binary. One process serves the REST API, the admin
dashboard, WebSockets, and three server-sent-event streams; a second mode
(backers mcp serve) exposes the same data over the Model Context Protocol.
System overview
Crate layout
crates/
backers-core/ # SQLite schema, migrations, models, wire types
backers-server/ # HTTP API, realtime, admin dashboard, all features
backers-mcp/ # MCP stdio server (backers_* tools)
backers/ # thin binary: `backers serve` / `backers kv` / `backers mcp serve`
backers-core owns persistence and knows nothing about HTTP. backers-server
owns every feature and embeds the dashboard assets (public/) into the binary
via rust-embed. backers-mcp talks to the same SQLite database directly, so
MCP tools and the HTTP API always agree.
Request lifecycle
Every /api/* request passes through the same middleware stack:
- Request logging — method, path, status, duration.
- CORS — permissive, so browser apps on any origin can call the API.
- Rate limiting — per-IP token bucket.
- Content-Type check — mutating requests must send
application/json(multipart uploads are exempt). - Body limit — 10 MiB maximum request body.
- Handler — JWT auth (
Authorization: Bearer <token>), then RBAC role checks against the target collection/bucket.
Persistence model
Everything lives in one SQLite file inside BACKERS_DATA:
collections+ dynamically-created record tables — schemaless-ish records validated against the collection's JSON schema.buckets+files— metadata in SQLite, bytes on the filesystem underBACKERS_DATA/files/.users,permissions— auth and RBAC.webhooks,webhook_logs,secrets,cache,notifications,logs,cron_jobs,cron_job_logs,ws_connections,ws_messages,pubsub_topics,pubsub_messages.
Because it is one file, backup is a file copy and export/import is a JSON document.
Realtime fan-out
Three independent channels share the same in-process hub pattern:
- WebSocket (
/ws) — persistent bidirectional connections; the server can push to one client or broadcast to all. - SSE (
/api/notifications/stream,/api/logs/stream,/api/pubsub/{name}/stream) — one-way server→client streams over plain HTTP, ideal for dashboards and browsers that cannot hold WebSockets.
MCP mode
backers mcp serve starts a stdio JSON-RPC server exposing tools such as
backers_list_collections, backers_list_records, backers_export, and
backers_import. It reads the same BACKERS_DATA database, so an agent can
inspect and modify a running Backers backend without HTTP credentials.
backers mcp serve --kv HOST:PORT instead proxies a remote backers kv
listener and exposes backers_kv_* tools over the inline TCP protocol.