Zero-Gravity Embedded Vector Database - Offline-first, RAM-efficient vector search
Project description
🚀 SvDB - Zero-Gravity Embedded Vector Database
"All the intelligence, none of the weight."
SvDB is a high-performance embedded vector database designed for offline-first, mobile-ready, and RAM-efficient applications. Built in Rust with sub-millisecond search speeds.
✨ Key Features
- 🔌 Offline-First: No network calls, no latency, no cloud bills
- 💾 RAM-Efficient: Uses
mmapfor zero-copy vector access, OS manages memory - ⚡ Blazing Fast: Sub-5ms search on 100k vectors using binary quantization
- 📱 Mobile-Ready: Designed for embedded systems, iOS, Android, and IoT
- 🎯 Simple API: Clean Rust trait interface with minimal complexity
🏗️ Architecture
Dual-File System
vectors.bin: Memory-mapped binary quantized vectors (1 bit/dimension)metadata.db: Embedded key-value store (redb) for metadata
Search Pipeline
- Coarse Search: Hamming distance via XOR/popcount (parallelized with rayon)
- Fine Rescore: Optional exact similarity for top-k candidates (future)
📦 Installation
Add to your Cargo.toml:
[dependencies]
svdb = "1.0.0"
🚀 Quick Start
use svdb::{SvDB, Vector, VectorEngine};
use anyhow::Result;
fn main() -> Result<()> {
// Initialize database
let mut db = SvDB::new("./my_vectors")?;
// Add a vector (1536 dimensions for OpenAI embeddings)
let vec = Vector::new(vec![0.1; 1536]);
let id = db.add(&vec, r#"{"title": "example"}"#)?;
// Search for similar vectors
let results = db.search(&vec, 10)?;
for result in results {
println!("ID: {}, Score: {:.4}", result.id, result.score);
}
// Persist to disk
db.persist()?;
Ok(())
}
📊 Performance
- Latency: < 5ms for 100k vectors (standard mobile CPU)
- Memory: < 50MB baseline overhead
- Binary Size: < 10MB (stripped release build)
- Storage: 192 bytes per vector (1536 dimensions)
🛠️ Tech Stack
- Storage:
memmap2for vectors,redbfor metadata - Parallelism:
rayonfor multi-threaded search - Quantization: Binary quantization (1 bit per dimension)
- Error Handling:
anyhow+thiserror
📖 Examples
Run the basic example:
cargo run --example basic
🧪 Testing
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run benchmarks (when implemented)
cargo bench
🎯 Use Cases
- Mobile AI: On-device semantic search without cloud dependency
- IoT Devices: Lightweight vector search on resource-constrained hardware
- Offline Apps: RAG systems that work without internet
- Edge Computing: Vector search at the edge with minimal latency
📝 API Reference
VectorEngine Trait
pub trait VectorEngine {
fn new(path: &str) -> Result<Self>;
fn add(&mut self, vec: &Vector, meta: &str) -> Result<u64>;
fn search(&self, query: &Vector, k: usize) -> Result<Vec<SearchResult>>;
fn get_metadata(&self, id: u64) -> Result<Option<String>>;
fn persist(&mut self) -> Result<()>;
}
Types
pub struct Vector {
pub data: Vec<f32>, // 1536 dimensions
}
pub struct SearchResult {
pub id: u64,
pub score: f32, // 0.0 to 1.0
pub metadata: Option<String>,
}
🗺️ Roadmap
- MVP: Binary quantization + Hamming search
- Product quantization for better accuracy
- HNSW graph index for faster search
- ARM NEON SIMD optimizations
- C FFI bindings for mobile (iOS/Android)
- Incremental indexing (hot updates)
- Metadata filtering (WHERE clause)
🤝 Contributing
Contributions welcome! Please check the issues page.
📄 License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
🙏 Acknowledgments
Built following the principles from the PRD for constraint-driven AI development.
Made with ⚡ and 🦀 by the SvDB team
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file srvdb-0.1.6.tar.gz.
File metadata
- Download URL: srvdb-0.1.6.tar.gz
- Upload date:
- Size: 5.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c26a03641e10727044c09d10d3d6cebcafc81cc1722be49ba65ff04c687b81ea
|
|
| MD5 |
f9e138e654a8ec5c4527495f3ae35125
|
|
| BLAKE2b-256 |
79f3cc7a9f4d7bcf52f8b13bf4449c9fdda2ae612cb2c4637544aa990d652577
|
File details
Details for the file srvdb-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: srvdb-0.1.6-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 688.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc989ea4420e880327402465720bf3a108fe4ad3a791c63c30028927ce2d511f
|
|
| MD5 |
19f267cce1cd09416f0e5dc565a23641
|
|
| BLAKE2b-256 |
69349493ae7bb2c45325d81ace8e1b26c5c358d2e3aeef8c76daa5fd0027979e
|