Architecture
Overview
Section titled “Overview”Coldrune is a single Rust binary with an embedded SQLite database. No external services are required for core operation.
Data model
Section titled “Data model”All entities use UUIDs as primary keys. Soft deletes via removed_at timestamp.
Request flow
Section titled “Request flow”- Request hits reverse proxy (nginx/Caddy) — TLS terminated, rate limited,
X-Real-Ipset - Axum receives the request on
127.0.0.1:7100 - Auth middleware extracts the caller:
Authorization: Bearer <token>→ session lookup →AuthUserX-API-Key: cr_sa_...→ hash lookup →ServiceAccount- Both wrapped in a
Callerenum for handlers that accept either
- Route handler validates input, checks org membership + role
- For secret operations: ACL check against project/env patterns
- Handler executes the operation
- Audit log entry written (fire-and-forget — failures don’t block the response)
- JSON response returned
Background workers
Section titled “Background workers”Maintenance worker
Section titled “Maintenance worker”Runs every hour, unconditionally:
- Deletes expired sessions (older than 30 days)
- Deletes used/expired magic links (older than 1 hour, preserving the lockout window)
Backup worker
Section titled “Backup worker”Runs on a configurable interval (BACKUP_SCHEDULE_HOURS). Disabled when set to 0 or when S3 is not configured.
- Creates an encrypted database snapshot
- Uploads to S3
- Runs retention cleanup (daily + weekly policy)
Database
Section titled “Database”SQLite in WAL (Write-Ahead Logging) mode for concurrent read access.
Key characteristics:
- File permissions set to
0600(owner-only) on Unix PRAGMA foreign_keys = ONenforced per connection- All foreign keys use
ON UPDATE RESTRICT ON DELETE RESTRICT - Migrations embedded at compile time, run on startup
- Partial unique indexes enable name reuse after soft deletion
API error format
Section titled “API error format”All errors follow a consistent format:
Error codes use SCREAMING_SNAKE_CASE. Internal details are never leaked to clients.
Two modes
Section titled “Two modes”The coldrune binary operates in two modes:
- Server mode (
coldrune server start) — runs the HTTP API, accesses the database directly - Client mode (
coldrune <command>) — a pure HTTP client that talks to the server’s REST API
The CLI never touches the database. All operations go through the HTTP API. Exception: coldrune server rotate-key accesses the database directly for offline key rotation.