bkndb
An embedded, zero-daemon hybrid graph-relational database engine with ACID transactions, written in Rust.
bkndb unifies relational tables (with secondary indexes and prefix matching) and a property graph engine into a single storage layer with unified atomic transactions, sub-millisecond graph traversal, and native single-file .bkndb container persistence.
Designed for AI agents, GraphRAG, code intelligence tools, local-first applications, and embedded analytics.
Key Features
- Embedded & In-Process: Zero network overhead, runs directly inside your application process (like SQLite/libsqlite3).
- Unified Hybrid ACID Transactions: Read and write relational rows and property graph nodes/edges in a single atomic transaction with snapshot isolation (
db.write_tx/db.read_tx). - High-Performance Native Storage (.bkndb): Single-file container using an append-only LSM architecture with memory-mapped zero-copy reading (
memmap2) and MemTable buffering. - Sub-Millisecond Graph Traversal: Built-in BFS shortest path, multi-hop radius traversal (blast radius), in-degree centrality (top hubs), and cascading node deletion.
- Relational Indexing & Hybrid Join: Secondary indexing, fast prefix search, and zero-cost joining of graph node traversals with relational metadata tables.
- High-Volume Bulk Ingestion: Batch synchronization API (
SyncBatch) capable of ingesting 100,000+ nodes, edges, and rows in under a second. - Zero Heavy Dependencies: Core uses no heavy C/C++ runtimes.
Performance Highlights
In real-world code intelligence workloads (call graph traversal & AST storage) comparing bkndb against SQLite:
| Operation | bkndb (Native LSM) |
SQLite (WAL mode) | Speedup |
|---|---|---|---|
| BFS Shortest Path (Call Graph) | 81.7 µs | 2,912.0 µs | 35.6x faster |
| Blast Radius / Impact Traversal | 41.8 µs | 994.9 µs | 23.8x faster |
| AST Batch Sync (10k items) | 123.4 ms | 133.2 ms | 1.08x faster |
Installation
Add bkndb to your Cargo.toml:
[]
= "0.1"
Feature Flags
| Feature | Default | Description |
|---|---|---|
lsm-backend |
Yes | Native single-file .bkndb container with zero-copy mmap. |
mem-backend |
Yes | High-throughput in-memory storage engine. |
graph |
Yes | Property graph layer (nodes, directed edges, graph algorithms). |
relational-layer |
Yes | Relational tables, primary keys, secondary indices, and prefix queries. |
redb-backend |
No | Optional storage backend powered by redb. |
Quick Start
1. Basic Graph and Relational Usage
use BknDb;
use ;
use PropValue;
use ;
2. Graph Algorithms: Shortest Path & Blast Radius
use BknDb;
use ;
Multi-Language Ecosystem
bkn-db also provides bindings for other languages:
- Python:
bindings/python/(supports GraphRAG & AI memory structures) - Swift / iOS:
bindings/bkndb_ffi.swift - Kotlin / Android:
bindings/uniffi/bkndb_ffi/(16KB memory page size compliant)
License
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).