Architecture

Workspace Crates

14 modular Rust crates comprising 117,804 lines across 205 source files, with 41,752 lines of tests.
CrateFilesLinesTestsTest Ratio
anvil-cluster71,73061741%
anvil-apoc101,79068641%
anvil-core3715,4645,25038%
anvil-algorithms72,24053827%
anvil-plugin-sdk144,9091,68638%
anvil-server4343,44613,63735%
anvil-cypher1220,6918,44946%
anvil33,8521,30837%
anvil-storage5217,2886,77145%
anvil-graphql22,07275440%
anvil-benches11933319%
anvil-migration51,51935626%
anvil-client61,30954947%
anvil-tests61,3011,118100%
Total205117,80441,75240%

anvil-cluster

Clustering and replication for Anvil DB.

crates/cluster

Source Files

7

Lines of Code

1,730

Test Lines

617

Test Ratio

41%

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,790

Test Lines

686

Test Ratio

41%

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

15,464

Test Lines

5,250

Test Ratio

38%

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,240

Test Lines

538

Test Ratio

27%

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,909

Test Lines

1,686

Test Ratio

38%

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

43

Lines of Code

43,446

Test Lines

13,637

Test Ratio

35%

Modules (25)

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.
emailEmail sending for verification and OTP.
file_storagePluggable storage backends for binary file content.
handlersHTTP request handlers for the Anvil DB server.
image_transformOn-the-fly image transformations with disk-cached variants (Phase 25.7).
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.
settingsRuntime Settings Store — hot-reconfigurable settings persisted in `system.settings` collection.
settings_bootstrapBootstrap system.settings collection on startup.
signed_urlsHMAC-SHA256 signed URLs for the storage subsystem (Phase 25.6).
storage_bootstrapBootstrap storage schema on startup.
storage_cypherCypher integration for the file-storage subsystem (Phase 25.4).
storage_handlersHTTP handlers for the `/storage/v1` REST API (Phase 25.3).
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,691

Test Lines

8,449

Test Ratio

46%

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

3

Lines of Code

3,852

Test Lines

1,308

Test Ratio

37%

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

17,288

Test Lines

6,771

Test Ratio

45%

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,072

Test Lines

754

Test Ratio

40%

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

193

Test Lines

33

Test Ratio

19%

anvil-migration

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

crates/migration

Source Files

5

Lines of Code

1,519

Test Lines

356

Test Ratio

26%

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,309

Test Lines

549

Test Ratio

47%

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%