A self-hosted, publicly-accessible media automation control plane that manages discovery, decisioning, acquisition, verification, and import — delegating actual downloading to mature external clients (qBittorrent, Deluge, Transmission, NZBGet, SABnzbd).
Core goals: fast, explainable, secure, observable, great as a single-container install.
| Layer | Technology |
|---|---|
| API/Engine | Rust — axum + tokio + SQLx (SQLite), role-gated WebSocket hub |
| Storage | SQLite (WAL, enforced foreign keys), transactional migrations |
| Web UI | SvelteKit SSR (apps/web) |
| Deploy | Single container: nginx :8080 → Rust API :8081 + node :3000 |
security/— Argon2id passwords, AES-256-GCM secret box, bounded rate limiter, and the SSRF-safe outbound layer: every outbound request is validated once and its resolved IPs pinned into the client's DNS resolver; redirects are followed manually with per-hop revalidation. No adapter may construct a raw HTTP client.storage/— connection pool forcesforeign_keys/WAL/busy_timeoutregardless of DSN; migrations run one file perBEGIN IMMEDIATEtransaction, keyed by filename, with drift detection; durable job queue with leases, renewal, owner-checked terminal writes, and attempt caps.ws/— hub enforces channel clearance at delivery:auditis admin-only,downloads/importsoperator+,activity/jobs/healthany authenticated user. Unsubscribe is explicit.jobs/— worker panic-isolates handlers (a poisoned job fails, never the process); heartbeat renews leases; every pipeline continuation propagates enqueue errors; a reconciler rescues stale non-terminal acquisitions; a retention janitor prunes sessions/jobs/audit/candidates.adapters/— Newznab + Torznab indexers (Prowlarr aggregation, API-key redaction), qBittorrent (category-scoped, v5 state names), Deluge, Transmission, NZBGet, SABnzbd, dry-run simulator, TMDB/TVDB metadata.httpapi/— routes mirroringpackages/contracts/openapi.yaml; CSRF double-submit on cookie-auth mutations; RBAC viewer < operator < admin.
- A search run records all candidates + decisions and creates one acquisition for the best-scoring accepted candidate (score desc, seeders desc, title asc); the rest remain as rescout fallbacks.
- Enqueue identifies torrents exactly: magnet btih or a client-returned id
under the
rivetcategory. No fuzzy matching against unrelated downloads. - Monitor bounds ghost/paused polling (30 not-found / 60 paused polls → needs_review). Verify quarantines failures and records evidence; rescout fires once per verify failure budget and is depth-capped per target.
- Dry-run mode simulates download clients and never writes to the filesystem.
# Tests (Rust)
cargo test
# Web tests + build
npm -C apps/web install && npm -C apps/web test && npm -C apps/web run build
# Dev: backend :8080 + web :5173 (persists .rivet-secret-key and rivet-dev.db)
make dev
# Dry-run backend (simulated download clients, real indexer calls)
make backend-dry-run # or: DRY_RUN=1 make backendEnvironment: APP_ENV, HTTP_ADDR, DATABASE_URL, APP_SECRET_KEY
(base64, 32 bytes; required outside dev), SESSION_TTL, ALLOW_INTERNAL_URLS
(defaults true in dev), DRY_RUN, DRY_RUN_FIXTURE_PATH, FFPROBE_PATH.
With no users, only /api/v1/setup/* is reachable:
- Create admin — first user becomes admin; the gate flips synchronously
so the immediate login cannot race it. Optional TOTP two-factor
(
POST /auth/totp/setup→enable; enabled accounts require a 6-digit code at login). - Paths — downloads/quarantine/library roots validated (stat-only in dry-run).
- Download clients — qBittorrent/Deluge/Transmission + NZBGet/SABnzbd; connectivity tested under the SSRF policy; secrets encrypted at rest.
- Indexers — Torznab/Newznab or Prowlarr; test search + parsing.
- Metadata — TMDB/TVDB validation.
- Policies — quality profiles, banned tags, language.
- Finish — writes the setup report and opens the app.
docker build -t rivet:dev .
docker run --rm -p 8080:8080 -v "$PWD/data:/data" \
-e APP_ENV=prod \
-e APP_SECRET_KEY="$(python3 -c 'import base64,os;print(base64.b64encode(os.urandom(32)).decode())')" \
rivet:devThe entrypoint forwards SIGTERM/SIGINT to all three processes and tears the rest down if any child dies.
packages/contracts/openapi.yaml documents every endpoint including status
codes. The WebSocket protocol (/ws) uses {v, type, ts, payload} envelopes;
clients subscribe explicitly ({"type":"subscribe","channels":[...]}).
- Argon2id (m=64 MiB, t=3) password hashing; constant-shape login errors with dummy verification against timing enumeration.
- AES-256-GCM encryption for all stored credentials via ONE shared SecretBox.
- Per-IP login rate limiting (10/min fixed window).
- Outbound SSRF policy blocks loopback/private/link-local/CGNAT/multicast/
NAT64 targets unless
ALLOW_INTERNAL_URLSis set; pinned-IP dialing defeats DNS rebinding; redirect hops revalidated. - Audit events for auth/setup/admin actions; WS event payloads gated by role.