Architecture Overview
Reactor is an AI-first backend platform built as a Rust workspace. One unified HTTP surface exposes identity, data, storage, functions, jobs, sites, gateway, and connect — composed in a single process for small deployments or split into independent services at scale.
Design principles
Section titled “Design principles”- Library composition, not subprocess orchestration — capabilities expose
router(state),Config, andmigrator(). The server wires them together. - One HTTP contract, every topology — SDK and CLI code never branch on deployment grade.
- Auth in-process by default —
InProcessAuthClienteliminates JWT round-trips in the unified binary. - One
Reactor.toml— single config file fans out to per-capability structs at boot. - Postgres-first — every capability shares one database pool (or one database per tenant on shared cluster).
Rust workspace
Section titled “Rust workspace”reactor-cloud/├── crates/│ ├── reactor-core/ # Shared types, AuthClient trait, TenantCtx│ ├── reactor-policy/ # Policy engine│ ├── reactor-cache/ # KV / queue primitives│ ├── reactor-vault/ # Secrets (embedded + OpenBao)│ ││ ├── reactor-auth/ # Identity library│ ├── reactor-auth-server/ # Standalone auth binary (sizes 5–6)│ ├── reactor-data/ # Data API library│ ├── reactor-data-server/ # Standalone data binary (sizes 5–6)│ ├── reactor-storage/ # Object storage library│ ├── reactor-storage-server/│ ├── reactor-functions/ # Serverless functions│ ├── reactor-functions-server/│ ├── reactor-jobs/ # Background jobs│ ├── reactor-jobs-server/│ ├── reactor-sites/ # Static/SSR hosting│ ├── reactor-sites-server/│ ├── reactor-ai/ # LLM gateway│ ├── reactor-connect/ # Data connectors│ ├── reactor-analytics/ # Product analytics│ ││ ├── reactor-server/ # Unified binary (sizes 1–2)│ ├── reactor-cloud/ # Control plane library│ ├── reactor-cloud-server/ # Control plane binary│ └── reactor-cli/ # Developer CLI│└── studio/ # Reactor Studio (Tauri desktop)Each capability follows the same library shape:
// Every capability crate exposes:pub fn router(state: AuthState) -> axum::Router { /* /cap/v1/... */ }pub fn migrator() -> sqlx::migrate::Migrator { /* schema */ }pub struct Config { /* ... */ }pub struct State { /* ... */ }Eight capabilities
Section titled “Eight capabilities”| Capability | Prefix | Purpose |
|---|---|---|
| Identity | /auth/v1/* | Sign-up, login, JWT, OAuth, magic links |
| Data | /data/v1/* | PostgREST-style API, RLS, realtime subscriptions |
| Storage | /storage/v1/* | Object storage, signed URLs, multipart upload |
| Functions | /fn/v1/* | WASM, Bun, and Lambda runtimes |
| Jobs | /jobs/v1/* | Scheduled and event-driven background work |
| Sites | /sites/v1/* + domains | Static assets, SSR, ISR |
| Gateway | /ai/v1/* | LLM routing (OpenRouter, Bedrock, Azure) |
| Connect | /connect/v1/* | Third-party data sync (Airbyte-style) |
Analytics (/analytics/v1/*) extends the platform with product event ingestion.
Unified server binary
Section titled “Unified server binary”reactor-server is the sizes 1–2 deployment artifact. It:
- Builds shared resources once (
PgPool, HTTP client, cache, tracing) - Runs migrations across all enabled capabilities
- Constructs
AuthService+InProcessAuthClient - Merges capability routers under their prefixes
- Mounts admin, health, and metrics routes
- Spawns background tasks (job scheduler, signed-URL janitor, Bun warm pool)
- Drains all tasks on graceful shutdown
// Composition sketch (crates/reactor-server/src/lib.rs)pub async fn run(cfg: ReactorConfig) -> anyhow::Result<()> { let shared = boot::pool::init(&cfg).await?; boot::migrate::run_all(&shared, &cfg).await?; let auth = boot::auth::build(&shared, &cfg).await?;
let caps = compose::ServerCapabilities::build(&shared, &auth, &cfg).await?; let app = caps.router() .merge(admin::router(&shared, &caps, &cfg)) .layer(TraceLayer::new_for_http());
let (shutdown_tx, shutdown_rx) = watch::channel(false); caps.spawn_background(shutdown_rx.clone());
// bind, serve, wait for signal, drain Ok(())}Boot timeline (size 2)
Section titled “Boot timeline (size 2)”Target: listening in under 1 second.
| Step | ~ms | Action |
|---|---|---|
| 0 | 0 | Parse argv, load Reactor.toml + env |
| 10 | 10 | Init tracing |
| 20 | 20 | Build shared PgPool |
| 40 | 40 | Ping Postgres |
| 50–200 | 200 | Run all capability migrations |
| 200 | 200 | Build AuthService + InProcessAuthClient |
| 250–400 | 400 | Build per-capability state, merge routers |
| 420 | 420 | Mount /_admin/*, /health, /metrics |
| 450–470 | 470 | Spawn background tasks, bind listener |
HTTP surface
Section titled “HTTP surface”GET /health Composite health checkGET /metrics Prometheus metrics
POST /auth/v1/signup IdentityPOST /auth/v1/tokenGET /data/v1/{table} Data (RLS-enforced)POST /storage/v1/objects/{bucket} StoragePOST /fn/v1/{name} FunctionsPOST /jobs/v1/runs JobsGET /sites/v1/... Sites admin *.yourdomain.com Sites serve (by Host header)
POST /_admin/deploy Admin (CLI contract)GET /_admin/doctorGET /_admin/logsPOST /_admin/migratePOST /_admin/shutdownGET /_admin/versionGET /health returns 503 if any mounted capability fails its internal health check.
Topology mapping
Section titled “Topology mapping”reactor-server as embedded library inside Reactor Studio. Binds 127.0.0.1 only. Cargo feature g1-tauri trims heavy adapters.
reactor-server binary. One process, one Postgres, one filesystem. Caddy/nginx for TLS.
Per-capability reactor-*-server binaries. Independent scaling. Microservices auth mode with HTTP between capabilities.
Stateless reactor-shared instances + shared Postgres (tenant DBs) + NATS + Supavisor + OpenBao. Control plane at api.reactor.cloud.
The HTTP surface is byte-identical across sizes 1–6 because every binary mounts the same cap::router(state).
Shared resources
Section titled “Shared resources”Built once in boot::pool and handed to every capability:
pub struct SharedResources { pub pg: sqlx::PgPool, pub http: reqwest::Client, pub cache: Arc<dyn CacheBackend>, pub clock: Arc<dyn Clock>, pub shutdown: watch::Receiver<bool>,}Capabilities never create their own database pools in the unified binary.
Background tasks
Section titled “Background tasks”| Capability | Background work | Shutdown |
|---|---|---|
| Jobs | Scheduler poll + worker pool | Drain in-flight runs |
| Storage | Signed-URL janitor, multipart cleanup | Finish current pass |
| Functions | Bun warm-pool reaper, deployment reconciler | Destroy idle handles |
| Auth | Key rotation timer | Finish current rotation |
| Sites | Bundle GC, certificate renewal | Finish current pass |
All tasks subscribe to a shared shutdown channel. Default drain budget: 30 seconds.
Cargo features
Section titled “Cargo features”[features]default = ["g2-full"]g1-tauri = ["cap-auth", "cap-data", "cap-storage", "cap-functions/runtime-wasm", "cap-jobs"]g2-full = ["cap-auth", "cap-data", "cap-storage", "cap-functions", "cap-jobs", "cap-sites"]
cap-auth = ["dep:reactor-auth"]cap-data = ["dep:reactor-data"]cap-storage = ["dep:reactor-storage"]cap-functions = ["dep:reactor-functions"]cap-jobs = ["dep:reactor-jobs"]cap-sites = ["dep:reactor-sites"]Binary size budgets:
- Size 1 (Tauri): ≤ 30 MB stripped
- Size 2 default: ≤ 60 MB stripped
Control plane (optional)
Section titled “Control plane (optional)”reactor-cloud-api is separate from reactor-server. It provisions infrastructure (Fly.io today), manages deployments, domains, secrets, and billing — but self-hosters at sizes 1–6 never need it.
reactor-cli → reactor-cloud-api → FlyProvider → customer reactor-serverSee Deployment grades for when to use managed vs self-hosted.
Related
Section titled “Related”- Adapters — swappable backend pattern
- Reactor Studio — desktop developer environment
- Configuration —
Reactor.tomlreference - FAQ — common architecture questions