Anvil DB
A graph database and backend platform in Rust - Cypher, GraphQL, documents, files, auth, and multi-tenant apps.
Anvil is a full graph database built from the storage engine up: a page-based store with write-ahead logging and MVCC, a complete Cypher query pipeline, an auto-generated GraphQL API, graph algorithms, clustering, and row-level security - all in Rust. Around the engine it has grown into a backend platform: a document store kept in sync with the graph, object storage, graph-native auth, edge functions, triggers, and first-class multi-tenant apps with portable backups - five services in one self-hosted binary, where everything from an index to a whole tenant is created in Cypher. Managed from the browser or the desktop with its companion UI, Hammer.
Cypher Engine
Full lexer → parser → semantic analyzer → cost-based planner → Volcano executor with 25+ operators, multi-hop BFS, quantified paths, and MERGE.
GraphQL API
Schema auto-generated from graph structure, Relay-spec connections, filtering, and live subscriptions over graphql-transport-ws.
ACID Transactions
MVCC with version chains, three snapshot-isolation levels, record-level locking, deadlock detection, and ARIES-style recovery.
Storage Engine
Page-based store with LRU cache, CRC32 WAL, B+ tree indexes (unique / composite / full-text / spatial), LZ4/Zstd compression, tiered I/O.
Graph Algorithms
PageRank, Dijkstra / A*, BFS/DFS, Louvain and label propagation, connected components, centrality measures, MST, and node similarity.
Clustering
Leader-follower WAL streaming, Raft consensus, read replicas with causal consistency, hash / label sharding, and rolling upgrades.
Plugin System
Hybrid native Rust plus scripting (Lua, Python, WASM, JS/TS, Starlark) with sandboxing, hot-reload, and namespace isolation.
Security & Auth
Row-level security on nodes, relationships and documents plus column-level property masks that follow data across models; graph-native users, roles and sessions you can MATCH; JWT (RS256) with JWKS, Argon2id, refresh tokens, OTP login, and email verification.
Client Drivers
First-party drivers for Rust, TypeScript, Python, and Go, all speaking the anvil:// (and anvil+tls://) URI scheme.
Document Store
A built-in NoSQL store with schema-namespaced collections, composite keys, TTL, and secondary indexes (GSI/LSI) - no separate database needed.
Graph-Document Sync
Sync rules bind a node label to a document collection both ways: write a :User node and the auth.users document updates, drop a field and it leaves the node - with conflict resolution and cascade semantics built in.
Apps & Multi-Tenancy
First-class apps: each tenant gets an isolated schema, membership with reader/editor/admin privileges, scoped settings and custom auth emails - and one call exports a tenant as a self-contained JSON bundle that restores anywhere with ids remapped.
File Storage
Built-in object storage with content-addressed blobs, signed URLs, on-the-fly image transforms, TUS resumable uploads, and pluggable backends (local, S3, R2, MinIO).
Functions & Triggers
Stored Cypher functions with typed parameters and CALL...YIELD, and event-driven triggers on INSERT/UPDATE/DELETE with BEFORE/AFTER timing and OLD/NEW variables.
Edge Functions
JavaScript and TypeScript served from the database over HTTP endpoints, on a Deno or Node.js subprocess runtime with on-demand execution.
Observability
Built-in event log, slow query detection, query analytics with p95/p99 latency, an index advisor, dependency analysis, configurable alert rules, and Prometheus metrics.
Why it is built this way
17 decision records, dated from the repository's history and tied to the commits and crates that carry them: why the storage engine is its own, why transactions are MVCC, why Cypher runs end to end, why documents sync with the graph, and how clustering, indexes and multi-tenant apps came to be. 7 of them quote the reasoning recorded in the repo at the time.
- ANV-0171 Sept 2026Make apps first-class tenants over the existing store, with membership kept beside global identity
- ANV-01628 May 2026Build the sharded index manager as a storage primitive ahead of cluster integration
- ANV-01527 May 2026Put the index fast path inside the live MATCH executor, not the planner
- ANV-01426 May 2026Maintain indexes through an IndexObserver trait owned by core, hooked into every mutation path