Architecture

Workspace Crates

14 modular Rust crates comprising 91,884 lines across 178 source files, with 30,330 lines of tests.
CrateFilesLinesTestsTest Ratio
anvil-cluster71,68457139%
anvil-apoc101,68658237%
anvil-core3714,7554,83437%
anvil-algorithms72,20250025%
anvil-plugin-sdk144,7891,56637%
anvil-server1721,8075,07626%
anvil-cypher1220,0567,81444%
anvil21,85844126%
anvil-storage5216,7766,25943%
anvil-graphql22,02170338%
anvil-benches11892917%
anvil-migration51,49232924%
anvil-client61,26850846%
anvil-tests61,3011,118100%
Total17891,88430,33037%

anvil-cluster

Clustering and replication for Anvil DB.

crates/cluster

Source Files

7

Lines of Code

1,684

Test Lines

571

Test Ratio

39%

Modules (6)

discoveryCluster discovery and membership protocol.
raftRaft consensus for automatic leader election.
read_routingRead replicas: route reads to followers, writes to the leader.
replicationLeader-follower replication via WAL streaming.
rolling_upgradeRolling upgrades: zero-downtime version migration across cluster nodes.
shardingSharding strategy: hash-based or label-based partitioning.

anvil-apoc

Awesome Procedures on Anvil (apoc) — built-in plugin standard library.

crates/apoc

Source Files

10

Lines of Code

1,686

Test Lines

582

Test Ratio

37%

Modules (9)

bitwiseapoc.bitwise — bitwise operations on integers.
collectionsapoc.coll — collection utilities.
convertapoc.convert — serialization and encoding utilities.
dateapoc.date — date/time utilities.
import_exportapoc.export / apoc.import / apoc.load — import/export procedures.
mathapoc.math — mathematical utilities.
refactorapoc.refactor — graph refactoring procedures (native Rust only).
spatialapoc.spatial — geospatial functions.
textapoc.text — text similarity and transformation utilities.

anvil-core

Core data model: property graph, document store, labels, properties, sync engine, and RLS.

crates/core

Source Files

37

Lines of Code

14,755

Test Lines

4,834

Test Ratio

37%

Modules (36)

alertAlert rules — fire when event patterns match configurable conditions.
collectionCollection configuration and management for document collections.
dependencyDependency analysis — static analysis of triggers, functions, and sync rules.
doc_btree_storeB+ tree backed document storage — an alternative to the HashMap-based MemDocumentStore.
doc_compressionDocument value compression using the storage layer's LZ4/Zstd codecs.
doc_transactionUnified transactions spanning both graph and document operations.
documentDocument struct with ID, key, body, and metadata.
document_indexSecondary index definitions and configuration for document collections.
document_keyDocument key types including simple keys and composite (partition + sort) keys.
document_storeDocument store trait defining CRUD operations for collections and documents.
edge_functionEdge functions — standalone serverless TypeScript/JavaScript functions.
event_logStructured event log — ring buffer of system events for observability.
functionStored database functions — user-defined Cypher functions.
graphGraph trait for creating, reading, updating, and deleting nodes and relationships.
idStrongly-typed IDs for nodes, relationships, labels, property keys, and other entities.
mem_document_storeIn-memory implementation of the `DocumentStore` trait.
memgraphIn-memory implementation of the `Graph` trait.
nodeNode struct with an ID, labels, and properties.
pathPath representation for variable-length graph traversals.
propertyProperty values, property maps, and serialization for graph and document properties.
registryBidirectional string-to-ID registry for interning labels, relationship types, and property keys.
relationshipRelationship struct with type, direction, source/target nodes, and properties.
rlsRow-Level Security policy definitions.
rls_adminRLS admin and observability tools.
rls_contextSession context and predicate evaluation for RLS policies.
rls_docsDocument collection RLS filtering.
rls_engineRLS engine — manages policies, evaluates access decisions.
rls_graphGraph-specific RLS filtering.
rls_queryRLS query engine integration.
schemaSchema constraints and index definitions for the graph.
sessionPer-connection session management.
snapshotBinary snapshot serialization for persisting the in-memory graph to disk.
sync_engineBidirectional graph-document synchronization engine.
sync_ruleSync rule definitions and configuration for graph-document synchronization.
triggerStored database triggers — event-driven logic on data changes.
wal_mutationWAL mutation types — serializable representations of all state changes.

anvil-algorithms

Graph algorithms extension library for Anvil DB.

crates/algorithms

Source Files

7

Lines of Code

2,202

Test Lines

500

Test Ratio

25%

Modules (6)

centralityCentrality algorithms: PageRank, betweenness, closeness, degree.
communityCommunity detection: Louvain, Label Propagation, Connected Components.
pathPath algorithms: shortest paths, MST, topological sort, k-hop, triangles.
procedureExpose graph algorithms as Cypher-callable procedures.
similarityNode similarity: Jaccard, Cosine, Overlap.
traversalBFS and DFS graph traversals.
Depends onanvil-core

anvil-plugin-sdk

Anvil DB Plugin SDK.

crates/plugin-sdk

Source Files

14

Lines of Code

4,789

Test Lines

1,566

Test Ratio

37%

Modules (13)

configPlugin configuration (TOML/JSON-style key-value settings).
discoveryPlugin discovery: auto-load plugins from a `plugins/` directory.
functionPlugin-defined Cypher functions (usable in expressions).
js_runtimeJavaScript/TypeScript scripting runtime for Anvil DB plugins.
lua_runtimeLua scripting runtime for Anvil DB plugins.
nativeNative Rust plugin loading via dynamic libraries with a stable C ABI bridge.
procedurePlugin-defined Cypher procedures (`CALL plugin.proc() YIELD col1, col2`).
python_runtimePython scripting runtime for Anvil DB plugins.
registryPlugin registry: load, unload, and look up plugins at runtime.
starlark_runtimeStarlark scripting runtime for Anvil DB plugins.
typesCore types shared across the plugin system.
versionSemantic versioning for plugins.
wasm_runtimeWebAssembly scripting runtime for Anvil DB plugins.
Depends onanvil-core

anvil-server

HTTP server: Axum routes, JWT authentication, Cypher/GraphQL/REST handlers, and middleware.

crates/server

Source Files

17

Lines of Code

21,807

Test Lines

5,076

Test Ratio

26%

Modules (16)

appServer application: shared state, router construction, and startup.
authBuilt-in user/role store with authentication and authorization.
auth_bootstrapBootstrap auth collections on first startup.
auth_middlewareAuth middleware — extracts JWT from Bearer header, validates, creates per-request Session.
configServer configuration with TOML file loading, environment variable overrides,
doc_handlersHTTP handlers for the document store REST API.
doc_walDocument WAL manager for separate WAL mode.
edge_runtimeEdge function execution runtime — spawns JS subprocess to execute functions.
handlersHTTP request handlers for the Anvil DB server.
jwtJWT token generation and validation using RS256 (RSA asymmetric signing).
loggingStructured logging with JSON output and configurable query/transaction logging.
metricsPrometheus-compatible metrics and OpenTelemetry trace export.
routesHTTP route definitions for the Anvil DB server.
trigger_engineTrigger execution engine — fires triggers in response to data changes.
wal_managerUnified WAL manager — handles all mutation types (graph, documents, metadata).
wal_replayWAL replay — apply recovered mutations to in-memory state.

anvil-cypher

Cypher query language: lexer, recursive-descent parser, semantic analyzer, type checker, cost-based optimizer, and Volcano-model executor.

crates/cypher

Source Files

12

Lines of Code

20,056

Test Lines

7,814

Test Ratio

44%

Modules (11)

astAST types for Cypher queries.
cachePrepared statement cache and query result cache for query performance.
executorVolcano / iterator model query executor (pull-based, row-at-a-time).
functionsBuilt-in Cypher function registry and implementations.
lexerTokenizer/lexer for the Cypher query language.
parallelParallel query execution: pipeline stages across threads, vectorized
parserRecursive-descent parser for Cypher queries.
plannerLogical query plan operators for the Cypher query planner.
semanticSemantic analysis and validation for Cypher ASTs.
thread_poolWork-stealing thread pool for query execution.
typecheckType checking for Cypher expressions and queries.

anvil

Anvil DB command-line interface: start/stop server, import data, interactive shell, and configuration.

crates/cli

Source Files

2

Lines of Code

1,858

Test Lines

441

Test Ratio

26%

anvil-storage

Page-based storage engine: WAL, B+ tree indexes, MVCC, compression, tiered I/O, and crash recovery.

crates/storage

Source Files

52

Lines of Code

16,776

Test Lines

6,259

Test Ratio

43%

Modules (19)

backupOnline backup, incremental (WAL-based) backup, verification, and scheduling.
columnarColumn-oriented property storage for analytics workloads.
compressionCompression for property values and WAL data.
concurrentLock-free and concurrent data structures, plus read-write separation.
disk_ioLow-level disk I/O operations for reading and writing pages.
freelistFree page tracking and recycled page ID allocation.
id_allocatorThread-safe sequential ID allocator with free-list reuse.
index
integrityData integrity: page checksums, WAL checksums, consistency verification,
io_schedulerRead-ahead, write batching, and tiered storage I/O scheduling.
latchLightweight read/write latches for page-level concurrency control.
layoutOn-disk file and directory layout definitions for the database.
lockFile-based process lock to prevent concurrent database access.
pagePage abstraction with configurable page sizes for the storage engine.
page_cacheLRU page cache with configurable capacity and dirty-page eviction tracking.
record
tx
versionStorage format version management and compatibility checks.
wal

anvil-graphql

Auto-generated GraphQL API: schema generation from graph structure, Relay connections, filtering, and introspection.

crates/graphql

Source Files

2

Lines of Code

2,021

Test Lines

703

Test Ratio

38%

Modules (1)

schemaAuto-generate GraphQL schema from graph schema (labels, relationship types, properties).

anvil-benches

Benchmark utilities and shared helpers for Anvil DB benchmarks.

crates/benches

Source Files

1

Lines of Code

189

Test Lines

29

Test Ratio

17%

anvil-migration

Migration tooling: import/export for Neo4j dumps, CSV, GraphML, and JSON-LD.

crates/migration

Source Files

5

Lines of Code

1,492

Test Lines

329

Test Ratio

24%

Modules (4)

csv_importNeo4j CSV export importer (nodes.csv + relationships.csv).
cypher_dumpNeo4j Cypher dump importer.
graphmlGraphML import/export.
jsonldJSON-LD import/export for graph data.
Depends onanvil-core

anvil-client

Official Rust client driver for Anvil DB.

crates/client

Source Files

6

Lines of Code

1,268

Test Lines

508

Test Ratio

46%

Modules (5)

connection_uriConnection URI parsing: `anvil://user:pass@host:port/database`
driverHigh-level client driver: connects, authenticates, executes queries.
protocolWire protocol: request/response serialization for the Anvil HTTP API.
resultQuery result types for the client driver.
transactionClient-side transaction management.

anvil-tests

Integration and strategy tests for Anvil DB.

crates/tests

Source Files

6

Lines of Code

1,301

Test Lines

1,118

Test Ratio

100%