Skip to main content

A high-performance graph database with ACID transactions

Project description

Sombra - Production-Ready Graph Database

Crates.io Documentation CI License: MIT

Sombra is a file-based graph database inspired by SQLite's single-file architecture. Built in Rust with a focus on reliability, performance, and ACID transactions.

Version 0.2.0 - Production Ready

  • Zero panic paths in production code
  • Comprehensive error handling with graceful degradation
  • Battle-tested with 10,000+ corruption scenarios
  • Structured logging and health monitoring
  • Complete API documentation and operational guides

Features

Core Features

  • Property Graph Model: Nodes, edges, and flexible properties
  • Single File Storage: SQLite-style database files
  • ACID Transactions: Full transactional support with rollback
  • Write-Ahead Logging: Crash-safe operations
  • Page-Based Storage: Efficient memory-mapped I/O

Performance Features ✨ NEW

  • Label Index: Fast label-based queries with O(1) lookup
  • LRU Node Cache: 90% hit rate for repeated reads
  • B-tree Primary Index: 25-40% memory reduction, better cache locality
  • Optimized Graph Traversals: 18-23x faster than SQLite for graph operations
  • Performance Metrics: Real-time monitoring of cache, queries, and traversals
  • Scalability Testing: Validated for 100K+ node graphs

Language Support

  • Rust API: Core library with full feature support
  • TypeScript/Node.js API: Complete NAPI bindings for JavaScript/TypeScript
  • Python API: PyO3 bindings with native performance (build with maturin -F python)
  • Cross-Platform: Linux, macOS, and Windows support

Reliability & Production Features (v0.2.0) ✨ NEW

  • Zero Panic Paths: All errors handled gracefully with Result types
  • Corruption Resistance: Safe deserialization with comprehensive validation
  • Structured Logging: Full tracing support with tracing crate
  • Health Monitoring: Built-in health checks and extended metrics
  • Graceful Shutdown: Clean database closure with WAL checkpoint
  • Resource Limits: Configurable limits for database size, WAL, and transactions
  • Database Inspector: CLI tools for inspection and repair

Testing & Quality

  • 100+ Comprehensive Tests: Unit, integration, stress, and fuzz tests
  • Corruption Fuzzing: 10,000+ scenarios tested without crashes
  • Multi-Platform CI: Linux, macOS, Windows with full test coverage
  • Zero Clippy Warnings: Strict linting with -D warnings
  • Benchmark Suite: Performance regression testing

Quick Start

Rust API

use sombra::prelude::*;

// Open or create a database
let mut db = GraphDB::open("my_graph.db")?;

// Use transactions for safe operations
let mut tx = db.begin_transaction()?;

// Add nodes and edges
let user = tx.add_node(Node::new(0))?;
let post = tx.add_node(Node::new(1))?;
tx.add_edge(Edge::new(user, post, "AUTHORED"))?;

// Commit to make changes permanent
tx.commit()?;

// Query the graph
let neighbors = db.get_neighbors(user)?;
println!("User {} authored {} posts", user, neighbors.len());

// Create property indexes for fast queries
db.create_property_index("User", "age")?;
let users_age_30 = db.find_nodes_by_property("User", "age", &PropertyValue::Int(30))?;
println!("Found {} users aged 30", users_age_30.len());

TypeScript/Node.js API

import { SombraDB, SombraPropertyValue } from 'sombradb';

const db = new SombraDB('./my_graph.db');

const createProp = (type: 'string' | 'int' | 'float' | 'bool', value: any): SombraPropertyValue => ({
  type,
  value
});

const alice = db.addNode(['Person'], {
  name: createProp('string', 'Alice'),
  age: createProp('int', 30)
});

const bob = db.addNode(['Person'], {
  name: createProp('string', 'Bob'),
  age: createProp('int', 25)
});

const knows = db.addEdge(alice, bob, 'KNOWS', {
  since: createProp('int', 2020)
});

const aliceNode = db.getNode(alice);
console.log('Alice:', aliceNode);

const neighbors = db.getNeighbors(alice);
console.log(`Alice has ${neighbors.length} connections`);

const bfsResults = db.bfsTraversal(alice, 3);
console.log('BFS traversal:', bfsResults);

const tx = db.beginTransaction();
try {
  const charlie = tx.addNode(['Person'], {
    name: createProp('string', 'Charlie')
  });
  tx.addEdge(alice, charlie, 'KNOWS');
  tx.commit();
} catch (error) {
  tx.rollback();
  throw error;
}

db.flush();
db.checkpoint();

Python API

from sombra import SombraDB

db = SombraDB("./my_graph.db")

alice = db.add_node(["Person"], {"name": "Alice", "age": 30})
bob = db.add_node(["Person"], {"name": "Bob", "age": 25})

db.add_edge(alice, bob, "KNOWS", {"since": 2020})

node = db.get_node(alice)
print(f"Alice -> {node.labels}, properties={node.properties}")

neighbors = db.get_neighbors(alice)
print(f"Alice has {len(neighbors)} connections")

tx = db.begin_transaction()
try:
    charlie = tx.add_node(["Person"], {"name": "Charlie"})
    tx.add_edge(alice, charlie, "KNOWS")
    tx.commit()
except Exception:
    tx.rollback()
    raise

Installation

Rust

cargo add sombra

TypeScript/Node.js

npm install sombradb

Python

# Install from PyPI (coming soon)
pip install sombra

# Or build from source
pip install maturin
maturin build --release -F python
pip install target/wheels/sombra-*.whl

CLI Tools

Install the unified CLI for database inspection, repair, and verification:

# Via Cargo (recommended)
cargo install sombra

# The 'sombra' command will be available system-wide
sombra --help

The CLI is also bundled with npm and pip installations:

# Via npm
npm install -g sombradb
sombra inspect mydb.db info

# Via pip
pip install sombra
sombra verify mydb.db

See the CLI documentation for complete usage guide.

Architecture

Sombra is built in layers:

  1. Storage Layer: Page-based file storage with 8KB pages
  2. Pager Layer: In-memory caching and dirty page tracking
  3. WAL Layer: Write-ahead logging for crash safety
  4. Transaction Layer: ACID transaction support
  5. Graph API: High-level graph operations
  6. NAPI Bindings: TypeScript/Node.js interface layer

Documentation

Getting Started

Language-Specific Guides

Technical Documentation

Development

Testing

# Run all tests
cargo test

# Run transaction tests specifically
cargo test transactions

# Run smoke tests
cargo test smoke

# Run stress tests
cargo test stress

Performance

Phase 1 Optimizations ✅ COMPLETE

Sombra now includes production-ready performance optimizations:

Optimization Improvement Status
Label Index Fast O(1) label queries ✅ Complete
Node Cache 90% hit rate for repeated reads ✅ Complete
B-tree Index 25-40% memory reduction ✅ Complete
Metrics System Real-time monitoring ✅ Complete

Benchmark Results (100K nodes):

Node Lookups:    ~1.5M ops/sec
Neighbor Queries: ~9.9M ops/sec  
Index Memory:    25% reduction (3.2MB → 2.4MB)
Cache Hit Rate:  90% after warmup

Graph Traversal Performance (vs SQLite):

  • Medium Dataset: 7,778 ops/sec vs 452 ops/sec (18x faster)
  • Large Dataset: 1,092 ops/sec vs 48 ops/sec (23x faster)

Running Benchmarks

# Index performance comparison
cargo bench --bench index_benchmark --features benchmarks

# BFS traversal performance
cargo bench --bench small_read_benchmark --features benchmarks

# Scalability testing (50K-500K nodes)
cargo bench --bench scalability_benchmark --features benchmarks

# Performance metrics demo
cargo run --example performance_metrics_demo --features benchmarks

Current Status

✅ Version 0.2.0 - Production Ready

Core Features:

  • Core graph operations (nodes, edges, properties)
  • Page-based storage with B-tree indexing (25-40% memory savings)
  • Write-ahead logging (WAL) for crash recovery
  • ACID transactions with rollback support
  • Label secondary index with O(1) lookup
  • LRU node cache (90% hit rate)
  • Adjacency indexing for fast traversals (18-23x faster than SQLite)
  • Property-based indexes for O(log n) queries

Production Hardening (v0.2.0):

  • ✅ Zero panic paths - All errors handled gracefully
  • ✅ Corruption resistance - 10,000+ fuzzing scenarios
  • ✅ Structured logging - Full tracing support
  • ✅ Health monitoring - Extended metrics and health checks
  • ✅ Graceful shutdown - Clean close() method
  • ✅ Resource limits - Configurable size/timeout limits
  • ✅ CLI tools - Inspector and repair utilities
  • ✅ 100+ tests passing - Unit, integration, stress, fuzz
  • ✅ Complete documentation - API docs, guides, examples
  • ✅ Multi-platform CI - Linux, macOS, Windows

Language Bindings:

  • ✅ Rust API (native)
  • ✅ Python bindings (PyO3)
  • ✅ TypeScript/Node.js bindings (NAPI)

🚀 Future Roadmap

Planned Features:

  • Page-level checksums for data integrity validation
  • Concurrent readers with MVCC
  • Query planner with cost-based optimization
  • Replication and high availability
  • Backup/restore utilities
  • Performance dashboard

See CHANGELOG.md for detailed release notes and docs/roadmap.md for future plans.

Examples

See the tests/ directory for comprehensive examples:

  • tests/smoke.rs - Basic usage patterns
  • tests/stress.rs - Performance and scalability
  • tests/transactions.rs - Transaction usage examples

License

This project is open source. See LICENSE for details.

Contributing

See Contributing Guidelines for information on how to contribute to Sombra.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sombra-0.2.0-cp314-cp314-win_amd64.whl (364.1 kB view details)

Uploaded CPython 3.14Windows x86-64

sombra-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl (568.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

sombra-0.2.0-cp314-cp314-macosx_11_0_arm64.whl (485.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

sombra-0.2.0-cp313-cp313-win_amd64.whl (366.3 kB view details)

Uploaded CPython 3.13Windows x86-64

sombra-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl (569.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

sombra-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (488.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

sombra-0.2.0-cp312-cp312-win_amd64.whl (366.8 kB view details)

Uploaded CPython 3.12Windows x86-64

sombra-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl (569.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

sombra-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (488.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

sombra-0.2.0-cp311-cp311-win_amd64.whl (360.5 kB view details)

Uploaded CPython 3.11Windows x86-64

sombra-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl (566.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

sombra-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (486.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file sombra-0.2.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: sombra-0.2.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 364.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sombra-0.2.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 a0eb2f1fa388b8eea5ee6ee81a107bbd4d813f347eb5f1e07bb57ce0032bf2cb
MD5 f58fd16bfdd3aeb5b56070920314eab1
BLAKE2b-256 6eb1c28b1d0d2f152990d4f5c1a508a6395c63efa95255e6fe5a2b9cdf9381f0

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 77d2ac63e88065e3221ead9dee34ed2c64bf9b1323fa6f4cf90c13722f492cb3
MD5 92326c0ed4e633a5429d5fb9d648f852
BLAKE2b-256 442c299747991864c0de7e9555ad6a27970045c837cac44c07a4b34ae994bf30

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40a461f8a79020cb3ff8865053e44d48e0033ae3c2ff7db1290447184e52e5cf
MD5 9e761a665bfa38f5c53018da281402f1
BLAKE2b-256 8a654eff75bc4518e9cf743fabd2cb2d7816482104fcc55efc1edf0b0b286763

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: sombra-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 366.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sombra-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a2694826264caf6c77a236024ea2514560ea222fea2c1d3072911a24b27961b5
MD5 b34a3de3b019ccbbf774aa9141fb4b11
BLAKE2b-256 8514e474937dd5c42275523482f1f515e00fd958714c69ad1e5b4e7d194472d4

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 96c10c369e621a29a57f9c202ba7b2aff9090ec755eddee75f5dc4339ed1cdfc
MD5 c8806a9f74d1728c2a6d8a6b8d3c64b9
BLAKE2b-256 0b429079057f1b407fe6012ca4b097593b8ce354256154b7dbec1862f8b1f58e

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0dfc06ea03b3dfd7acff2eb383bc98c6935e1bfdcfef6914c480a344081071a0
MD5 db21a76ca0a7388d3a5d5428244573c9
BLAKE2b-256 576b0e3afacd68dd17276317a83fb06d928832e34cdf9d22b0a22f7d20519fa7

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sombra-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 366.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sombra-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7abd43b00492f23d21c4055fb91980b808f05324c24c458789907f7ea4ab3bad
MD5 b1a1f67acc57e9c26ba5068c9660f685
BLAKE2b-256 d0e4b4943d427ddb6da79a5b2a2722096ddd99c5a168d5ddcd7d89320b4e38c8

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1335b28c6be47df45c5729f6857fac261a13079d39bbe9a33e4089b1afb0763d
MD5 3574d96709adb8f853029dccb5d8f5fc
BLAKE2b-256 f37018ec6d690d1b68edb1b5604d860fcadc712b4ffbe2ec2005ec839e66b350

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 316f425f672aa39ac06cfea5ed72155131e514f4019fd342d97e3849357916b3
MD5 7512aab1e36defa9ec124c0b1f80f3e9
BLAKE2b-256 d6c53ff61e765ac1e09642c5e2d38efc9432e7a8aa4976d2ea57c28b37b4e7fb

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sombra-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 360.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sombra-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 05d50720dc41287498b00bc40901df2f73df2178fdffb411cebec24b9582becc
MD5 be57320817c1514a10f66cc7ab316672
BLAKE2b-256 20f446d1dfe762cc65129e298483d6d1e52b7a84381630e1445ba78b9653f74f

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 81c5a9ce5558f166aa0e8f2935235c99655966159bd988a35d9ed1a3e7709a91
MD5 55a4d7f7a9835b72a5c637553ece9662
BLAKE2b-256 efbbff4e97e8ff4bb305032438254ef0a19161f234c99847704d9f8332c2468f

See more details on using hashes here.

File details

Details for the file sombra-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sombra-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b69c7d1e68524e6074bc8905f1ec9c596946dfbcbfbaeac23f3c908756667af2
MD5 28f2581d178aeefb1cf380a0815687b7
BLAKE2b-256 8c7c855858b879e2e2c1086bd4f3f1e0a3be88f5cf0f2f93ea0aa05c859f9772

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page