Skip to main content

A high-performance graph database with ACID transactions

Project description

Sombra - High-Performance Graph Database

Crates.io Documentation CI License: MIT

⚠️ Alpha Software: Sombra is under active development. APIs may change, and the project is not yet recommended for production use. Feedback and contributions are welcome!

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.

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 Features

  • Comprehensive Error Handling: 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.3.0 - Alpha

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
  • Multi-reader concurrency support (100+ concurrent readers)

Quality & Reliability:

  • ✅ Comprehensive error handling with graceful degradation
  • ✅ 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)

🚀 Roadmap to Production (v1.0)

In Progress:

  • Real-world testing and feedback collection
  • API stabilization and versioning strategy
  • Performance optimization and profiling

Planned Features:

  • Page-level checksums for data integrity validation
  • MVCC for improved concurrency
  • Query planner with cost-based optimization
  • Replication and high availability
  • Backup/restore utilities
  • Performance dashboard
  • Production deployment case studies

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.3.1-cp314-cp314-win_amd64.whl (413.8 kB view details)

Uploaded CPython 3.14Windows x86-64

sombra-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl (620.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

sombra-0.3.1-cp314-cp314-macosx_11_0_arm64.whl (530.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

sombra-0.3.1-cp313-cp313-win_amd64.whl (417.4 kB view details)

Uploaded CPython 3.13Windows x86-64

sombra-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl (623.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

sombra-0.3.1-cp313-cp313-macosx_11_0_arm64.whl (531.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

sombra-0.3.1-cp312-cp312-win_amd64.whl (418.0 kB view details)

Uploaded CPython 3.12Windows x86-64

sombra-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl (624.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

sombra-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (531.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

sombra-0.3.1-cp311-cp311-win_amd64.whl (413.2 kB view details)

Uploaded CPython 3.11Windows x86-64

sombra-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl (619.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

sombra-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (530.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: sombra-0.3.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 413.8 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.3.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 fee2bda0a4cf1118cfdf4dbee337cc10da1ed3f3931e749165bbb1bedbbf0a27
MD5 cebf9c373f3621747bb63a0cf4f5823a
BLAKE2b-256 d264158df23492e6606117bf1c3d3ee558f13a80049c4d017f7b81213e08d50e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1a3785a16225a538b4a20c98dafd68ebb8480e07d1c6739123aaa6c393350b0e
MD5 f8ffb07f8f1c5fcfcce52b55795966e7
BLAKE2b-256 d31bffd24d20cb83d2ce5908886fdbd2b110b5c419592d43d49feeed62ed7073

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fe2d749ba15e3dbe194a5833ec0c77458bb663fa5e2b8d5cbaa04e35bf12b57
MD5 b5abd7d5a44acdce9637fa9a7e206b07
BLAKE2b-256 3ed8cee36246419cb1458e3e5298d7b6bb1506b166a81d06adde3cf0b4754102

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sombra-0.3.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 417.4 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.3.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b5f212c95d9a9a40c33276b63b24b1e872236a1c04c7afb868bbc314665599eb
MD5 aa4d8ecb9006453c9da72df522522a85
BLAKE2b-256 423844045fde0c7387dba51f49d4accebb14ab86d63656d8c37f7008e2537e4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 21e9231baa7f5b14c49bac5b876cf51efe3e153e32f12ccf484bcf6d8c6ee3f2
MD5 b80e35e8895fa15c602672122f26d63d
BLAKE2b-256 1b8fe8cec8f4ec0d6a0f1b10425514bb1d4c6098158ab503bccdb1ff70b21a20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a043f335edc2354aeeaf33b791c97d56f5ddd6cc6a2d68b4fe992760a5a99c1
MD5 8c2230bfd1289b5e6b702e95892b83ac
BLAKE2b-256 393fc72086fffaca0be7b13e883f1f02a957ef672cceb9a2bc651e815af75b5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sombra-0.3.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 418.0 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.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1ba88836702d15004f139e4a703c12df222a9e0b6f2f4a3f74c199b1377f62c9
MD5 f9bac0335607c157c95b3f8080839f2d
BLAKE2b-256 c29c50c4f00611b26d55d0079f4e81c8673b3154a88c06d519580fba5a625310

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 942ed595a687a3ee9f19b9da2de67072117b0faa5d46417ba35d093c26977951
MD5 e9ed90a685f7a536b21b7ceccd996192
BLAKE2b-256 654371489824e4f4f89ffa92a63cf24db6ea10a462101d6a656070881611909d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c9f8c476da6180763c61b6cf3c06b5788973a80d6f05b7d9361947d8745840f
MD5 8cdc42b4d2ad1c1137f489d6ffaff616
BLAKE2b-256 fa467b05b40e27e681228ec3e18b973ac863d125affe9278cb6a3100fae3efea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sombra-0.3.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 413.2 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.3.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0767e9e52eb22269fbf88e8110677aa67c31450ee946380acf66ac29d51cd31d
MD5 200259190def32de4e21ffb5df2d8d15
BLAKE2b-256 dcf1ff6cc3046a175cb7daae74b74dc949eb5b3591dc629fde334b5d46b6cada

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bc15d23be9fa15e21af1262449caa49742cfcffa7077459a75f089c7c66c2be3
MD5 f26ea7524e364c8ad7d2bc7e7bc8ae70
BLAKE2b-256 70722d4a0c4816ac938a07f3c67066fdbce1a1f1f150c93d850985afbb1da38b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sombra-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0c30be8f9a5340d54a20dd8870b1143d52876c3e9967ee29597d785747db3c7
MD5 e1069963445d9057ea3e478a46fa62c6
BLAKE2b-256 42dca02d274880a1e56d0dde394a71921ec25fe274b9f3fb8d594c0f57a70760

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