congraphdb
v0.2.1
Published
A high-performance, embedded graph database for Node.js built with Rust
Maintainers
Readme
CongraphDB
"SQLite for Graphs & Vectors" — A high-performance, embedded hybrid graph-vector database for Node.js built with Rust
CongraphDB is an embedded, serverless hybrid graph-vector database designed for local-first AI applications. Built with Rust for memory safety and extreme performance, it combines the power of native graph traversals with high-performance vector similarity search.
⚠️ Early Stage Development: This project is in active development (v0.2.x). While the core architecture is in place, some features are still being implemented. See the Roadmap for planned features.
📚 New users: We recommend starting with congraphdb-sdk for examples and best practices.
Features
- 🚀 Hybrid Graph-Vector Engine — A unified storage engine for both property graph data and high-dimensional vector embeddings.
- ⚡ High Performance — Rust-powered with memory-mapped I/O, columnar storage, and vectorized execution.
- 🤖 Native Vector Search — Built-in HNSW index with parallel batch ingestion (297x faster), batch search, and metric-aware scoring (Cosine, L2, IP).
- 🧠 Graph RAG Ready — Specialized algorithms and optimized retrieval APIs designed specifically for AI/LLM workflows.
- 🔍 DRIFT Search — Intent-based search with BROAD (community-level), SPECIFIC (entity-level), and COMPLEX (dual-level) modes for optimized retrieval.
- 📊 Drift Detection — High-performance corpus monitoring with < 100ms performance for 10k documents.
- 🔍 Dual Query Interface — Cypher graph query language OR JavaScript-native API for flexible development.
- 📦 Embedded & Serverless — No separate database process. Store data locally in a single
.cgraphfile. - 💾 ACID Transactions — Serializable transactions with write-ahead logging (WAL) and crash recovery.
- 🔒 Memory Safe — Built with Rust — no segfaults, no memory leaks.
- 🛤️ Path Finding — BFS-based shortestPath() and allShortestPaths() functions for complex relationship analysis.
- 📄 Document API — Native methods for managing chunks, entities, and facts in RAG pipelines.
Performance
Last Run: * April 17, 2026 | View congraphdb-benchmark for detailed results.
Overall Score - Small Dataset
| Rank | Engine | Score | Ingestion | Traversal | PageRank | Memory | | :--: | :------------- | :------: | :-------: | :-------: | :------: | :----: | | 🥇 | CongraphDB | 80.8 | 95K/s | 🥇 0.7ms | 🥇 0.0s | 133MB | | 🥈 | SQLite | 42.3 | 17K/s | 1.4ms | 1.8s | 179MB | | 🥉 | LevelGraph | 42.1 | 3K/s | 1.7ms | 🥇 0.0s | 415MB | | 4 | Graphology | 40.9 | 18K/s | 2.4ms | 🥇 0.1s | 433MB | | 5 | Ladybug | 28.6 | 0K/s | 14.0ms | 🥇 0.0s | 489MB |
Overall Score - Medium Dataset
| Rank | Engine | Score | Ingestion | Traversal | PageRank | Memory | | :--: | :------------- | :------: | :-------: | :-------: | :------: | :----: | | 🥇 | CongraphDB | 85.1 | 69K/s | 🥇 0.6ms | 🥇 0.0s | 501MB | | 🥈 | LevelGraph | 45.8 | 2K/s | 1.7ms | 🥇 0.0s | 2124MB | | 🥉 | Graphology | 29.7 | 7K/s | 58.8ms | 🥇 2.4s | 2870MB | | 4 | SQLite | 23.1 | 7K/s | 10.4ms | 51.1s | 651MB |
Overall Score - Large Dataset
| Rank | Engine | Score | Ingestion | Traversal | PageRank | Memory | | :--: | :------------- | :-------: | :-------: | :-------: | :-------: | :-------: | | 🥇 | CongraphDB | 100.0 | 🥇 110K/s | 🥇 0.6ms | 🥇 168.0s | 🥇 3250MB | | 🥈 | Neo4j | 72.7 | 88K/s | 🥇 0.8ms | 285.0s | 8200MB | | 🥉 | Kuzu | 70.9 | 82K/s | 🥇 0.8ms | 380.0s | 5800MB | | 4 | Graphology | 57.7 | 68K/s | 🥇 0.8ms | 920.0s | 8500MB | | 5 | SQLite | 28.6 | 38K/s | 13.0ms | 850.0s | 5200MB |
CongraphDB is optimized for:
- Local-first applications — No network overhead
- Multi-core systems — Parallel query execution using Rayon
- Analytical workloads — Columnar storage for fast aggregations
- Vector similarity — HNSW algorithm for ANN search with O(log n) complexity
Quick Start
Choose your query interface:
Option 1: Cypher Query Language (Industry Standard)
npm install congraphdbconst { Database } = require('congraphdb')
// Create or open a database
const db = new Database('./my-graph.cgraph')
db.init()
// Create a connection
const conn = db.createConnection()
// Define schema
await conn.query(`
CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))
`)
await conn.query(`
CREATE REL TABLE Knows(FROM User TO User, since INT64)
`)
// Insert data
await conn.query(`
CREATE (alice:User {name: 'Alice', age: 30})
-[:Knows {since: 2020}]->
(bob:User {name: 'Bob', age: 25})
`)
// Query
const result = await conn.query(`
MATCH (u:User)-[k:Knows]->(f:User)
WHERE u.name = 'Alice'
RETURN u.name, k.since, f.name
`)
// Get all results
const rows = result.getAll()
for (const row of rows) {
console.log(row)
}
db.close()Option 2: JavaScript-Native API (Developer Friendly)
npm install congraphdbconst { Database, CongraphDBAPI } = require('congraphdb')
// Initialize
const db = new Database('./my-graph.cgraph')
await db.init()
const api = new CongraphDBAPI(db)
// Create nodes
const alice = await api.createNode('User', { name: 'Alice', age: 30 })
const bob = await api.createNode('User', { name: 'Bob', age: 25 })
// Create relationships
await api.createEdge(alice._id, 'KNOWS', bob._id, { since: 2020 })
// Query with pattern matching
const friends = await api.find({
subject: alice._id,
predicate: 'KNOWS',
object: api.v('friend'),
})
// Fluent traversal API (LevelGraph-compatible)
const friendsOfFriends = await api.nav(alice._id).out('KNOWS').out('KNOWS').values()
// Cleanup
await api.close()
await db.close()💡 For more examples, check out congraphdb-sdk — a comprehensive SDK with sample applications demonstrating various CongraphDB features and usage patterns.
Query Languages
CongraphDB supports two query interfaces for maximum flexibility:
| Interface | Best For | Style | | ------------------ | ------------------------------------------------------- | ---------------------------------------------- | | Cypher | Complex queries, graph analytics, power users | Industry-standard graph query language | | JavaScript API | Simple CRUD, application integration, rapid development | Native JavaScript methods with fluent chaining |
When to Use Each
Use Cypher when:
- Writing complex graph traversals
- Using path finding algorithms
- Performing aggregations and analytics
- Migrating from Neo4j or other Cypher databases
Use JavaScript API when:
- Building application-specific CRUD operations
- Prefer programmatic interfaces over query strings
- Want IDE autocomplete and type safety
- Building simple node/edge operations
- Need LevelGraph-compatible API
Cypher Support
CongraphDB supports the Cypher graph query language with the following capabilities:
- Schema Definition — Node tables with primary keys, relationship tables
- Pattern Matching — MATCH clauses with variable-length paths (
*1..3) - Property Filters — Filters in patterns like
(u:User {name: "Alice"}) - Path Finding —
shortestPath()andallShortestPaths()functions - Pattern Comprehensions — List extraction from graph patterns
- Temporal Types — Date, DateTime, Duration, and timestamp functions
- Advanced Features — Regex matching (
=~), map literals, multi-label nodes - Vector Search — HNSW index for similarity search on embeddings
- DML Operations — CREATE with properties, SET, DELETE, REMOVE, MERGE with ON MATCH/ON CREATE
- CASE Expressions — Full conditional logic with WHEN/THEN/ELSE
- Query Result Modifiers — ORDER BY with ASC/DESC, SKIP, LIMIT clauses
- Variable-Length Paths —
[*..n]syntax for flexible path patterns - Union Operator — Combine results from multiple pattern combinations
Full Documentation: Cypher Reference
JavaScript API (v0.1.5+)
CongraphDB provides a JavaScript-native API layer as an alternative to Cypher for developers who prefer a programmatic interface.
Core Classes
- CongraphDBAPI — Main API with node/edge operations, pattern matching, transactions
- Navigator — Fluent graph traversal API (LevelDB-compatible)
- Schema API — JavaScript-native schema management (v0.1.8+)
const { Database, CongraphDBAPI } = require('congraphdb')
const db = new Database('./my-graph.cgraph')
await db.init()
const api = new CongraphDBAPI(db)
// Node operations
const node = await api.createNode('User', { name: 'Alice', age: 30 })
const user = await api.getNode(node._id)
// Edge operations
await api.createEdge(alice._id, 'KNOWS', bob._id, { since: 2020 })
// Pattern matching
const friends = await api.find({
subject: alice._id,
predicate: 'KNOWS',
object: api.v('friend'),
})
// Fluent traversal
const fof = await api.nav(alice._id).out('KNOWS').out('KNOWS').values()
// Schema management (v0.1.8+)
await api.schema.createNodeTable('User', {
properties: { id: 'string', name: 'string', age: 'int64' },
primaryKey: 'id',
})
await api.close()
await db.close()Full Documentation: JavaScript API Reference
Architecture
CongraphDB is built with a modern, layered architecture designed for performance and safety:
- Rust Core Engine — Memory safety guarantees, zero-cost abstractions, LLVM optimizations
- napi-rs Bindings — Pre-built native binaries, minimal overhead, async worker pool
- Columnar Storage — Similar to KuzuDB/DuckDB, efficient compression, vectorized execution
- Hybrid Query Processing — Cypher and JavaScript API both execute through the same optimized engine
| Layer | Technology | Purpose | | ------------ | ----------------- | ----------------------------------- | | Bindings | napi-rs + Node.js | FFI bridge, async execution | | Storage | memory-map2 | Zero-copy file I/O | | Concurrency | Rayon | Parallel query execution | | Vector Index | HNSW lib | Approximate nearest neighbor search | | Compression | Zstd | Column compression | | Parsing | Logos | Cypher tokenization |
Building from Source
Prerequisites
- Rust 1.70 or later
- Node.js 20 or later
- CMake (for building on some platforms)
Build Steps
# Clone the repository
git clone https://github.com/congraph-ai/congraphdb.git
cd congraphdb
# Install dependencies
npm install
# Build the native module
npm run build
# Run tests
npm testStatus
CongraphDB is currently in alpha development (v0.2.1). The core storage engine and transaction system are hardened with chained page support and WAL recovery. It features comprehensive Cypher query support, a high-performance HNSW Vector Index with parallel ingestion, specialized Graph RAG algorithms, and a JavaScript-native API.
Test Coverage: 2,814 Rust tests and 217 JavaScript tests passing (100% stability)
Query Interfaces: Cypher Query Language + JavaScript API (CongraphDBAPI)
Run npm test to see the current test coverage.
Roadmap
- [x] Cypher query support - Core operators, expressions, functions, ORDER BY, SKIP/LIMIT, DISTINCT
- [x] JavaScript API - NodeAPI, EdgeAPI, Pattern matching, Navigator API
- [x] Path finding functions - shortestPath(), allShortestPaths() with BFS-based algorithms
- [x] Pattern comprehensions - Single-node and relationship patterns with outer variable scope
- [x] Temporal types - Date, DateTime, Duration support with temporal functions
- [x] Multi-label nodes - Nodes with multiple labels support
- [x] Regex matching - Pattern matching with =~ operator
- [x] Map literals - Map literal expressions in queries
- [x] DML operations - CREATE with properties, SET, DELETE, REMOVE, MERGE with ON MATCH/ON CREATE
- [x] Property filter handling - Property filters in MATCH patterns now work correctly
- [x] Dynamic property creation - Auto-create columns when setting non-existent properties
- [x] CASE expressions - Full conditional logic support in queries
- [x] Query execution statistics - Track query performance metrics
- [x] Query result modifiers - ORDER BY, SKIP, LIMIT clauses for result control
- [x] Variable-length path traversal -
[*..n]syntax for path patterns - [x] Union operator - Combine results from multiple pattern combinations
- [x] Case-insensitive keywords - All Cypher keywords now case-insensitive
- [x] Schema API - JavaScript-native schema management (v0.1.8+)
- [x] Document API - RAG workflow support (v0.1.10+)
- [x] Lock Manager - Deadlock prevention (v0.1.10+)
- [x] SQL DDL Syntax - CREATE TABLE/INSERT INTO (v0.1.10+)
- [x] Query Parameters - $placeholder substitution (v0.1.10+)
- [x] UNWIND Clause - Support for bulk operations and list decomposition (v0.2.1+)
- [x] Chained Page Storage - Support for large data payloads (v0.2.1+)
- [x] Batch Vector Search - Parallel HNSW ingestion and search with 297x batch insert performance (v0.2.1+)
- [x] Graph Analytics - PageRank, Louvain, Leiden, Label Propagation, etc. (v0.1.11+)
- [x] Transaction control - BEGIN and COMMIT statements (v0.1.11+)
- [x] WAL recovery - Data durability and crash recovery (v0.1.11+)
- [ ] OPTIONAL MATCH with variable-length paths
- [ ] Async iteration support for QueryResult
- [ ] Distributed queries
- [ ] GraphQL endpoint
- [ ] WebAssembly support
- [ ] Additional index types (B-tree, hash, etc.)
- [ ] Query optimization and execution plan visualization
- [ ] Backup and restore utilities
Resources
- Documentation — Official API and feature documentation
- Benchmark — Performance benchmarks and comparisons
- SDK — Comprehensive SDK and usage patterns
- Demo — Interactive movie database with D3.js visualization
- CHANGELOG.md — Version history and release notes
- CONTRIBUTING.md — Contribution guidelines
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License — see LICENSE file for details.
Acknowledgments
CongraphDB is inspired by:
- KuzuDB — For its columnar storage architecture
- SQLite — For the embedded database philosophy
- Apache AGE — For Cypher language support
CongraphDB — The embedded graph database for the edge.
