Architecture overview#
flowchart LR
subgraph Local["Researcher machine (works offline)"]
CLI[rvc CLI] --> CORE
SDK[researchvc SDK] --> CORE
CORE[rvc_core engine<br/>objects · refs · index · merge · graph · runs · datasets]
CORE --> PARSE[rvc_parsers<br/>LaTeX · Markdown · notebooks]
CLI --> INTEL[rvc_intel<br/>diff · claims · audit · assistant]
INTEL --> GW[Model gateway<br/>privacy gate · cache · usage]
end
CORE <-- sync protocol --> API
subgraph Cloud["Self-hostable server"]
API[FastAPI rvc_api] --> PG[(PostgreSQL + pgvector)]
API --> S3[(S3-compatible objects)]
API --> RD[(Redis: rate limits)]
WK[rvc-worker] --> PG
WK --> S3
WEB[Next.js web app] -->|/api proxy| API
end
Layers and rules#
- Deterministic core (
rvc_core): the only code that creates history. No network, no AI. - Parsers (
rvc_parsers): pure functions from bytes to structured documents with source maps. - Intelligence (
rvc_intel): reads history, never writes commits. Deterministic facts first (semantic diff, audit checks, evidence matching); optional model calls only throughModelGateway, which enforces the privacy policy, redacts secrets, validates JSON-schema output, caches by (provider, model, prompt version, input) and records token usage. - Server (
rvc_api): the same engine code runs server-side against a per-repository bare object store. PostgreSQL stores collaboration state authoritatively (users, orgs, refs, comments, finding statuses, integrations, jobs, logs) and a derived index of immutable objects (commits, entity versions, graph snapshots, runs, metrics) rebuilt idempotently by theingestjob. - Web (
apps/web): reads through the API; mutations from the web are web commits (preview → explicit apply with expected head) so history remains immutable and attributed.
Key flows#
rvc runexecutes the command, tees output, captures provenance (Git state, allowlisted env, hardware, GPU, lockfiles, packages, seeds, rusage), discovers outputs, and stages an immutable run entity plus USES/TESTS/PRODUCED_BY edges.rvc push→ server validates objects and closure → CAS ref update →ingestjob indexes new commits →auditjob recomputes findings for the default branch head.- The web overview, graph explorer, manuscript viewer and audit pages read the indexed data and the object store; recursive graph neighborhoods are SQL queries.
Background jobs#
background_jobs table; claimed with FOR UPDATE SKIP LOCKED on PostgreSQL; retries with
exponential backoff; dedup by (kind, dedup_key) for pending jobs; RVC_INLINE_JOBS=true
runs them in-process for tests and single-user installs. Job failure never affects history.
See also: docs/architecture/database.md, docs/protocol/*, docs/security.md, ADRs.