This document describes the optional database backend features available in Terraphim AI.
By default, Terraphim AI uses lightweight, dependency-free storage backends:
- Memory: In-memory storage (no persistence)
- DashMap: Fast concurrent hash map storage
- ReDB: Pure Rust embedded database (default for persistence)
Heavy database backends like SQLite and RocksDB are now optional features to:
- Reduce compilation time for development
- Minimize binary size for lightweight deployments
- Avoid heavy native dependencies when not needed
services-dashmap: Fast in-memory concurrent storageservices-redb: Pure Rust embedded databaseservices-atomicserver: Atomic Server integration
services-sqlite: SQLite database supportservices-rocksdb: RocksDB database supportservices-redis: Redis backend supportfull-db: Enable all database backends
# Enable SQLite only
cargo build --features sqlite
# Enable RocksDB only
cargo build --features rocksdb
# Enable Redis only
cargo build --features redis
# Enable all database backends
cargo build --features full-db
# Enable with OpenRouter
cargo build --features "full-db,openrouter"# Enable SQLite support
cargo build --features sqlite
# Enable all database features
cargo build --features full-dbAdd to your Cargo.toml dependencies:
[dependencies]
terraphim_persistence = { path = "../crates/terraphim_persistence", features = ["services-sqlite", "services-rocksdb"] }When optional database features are disabled, the corresponding profiles in configuration files are commented out:
[profiles.memory]
type = "memory"
[profiles.redb]
type = "redb"
datadir = "/tmp/terraphim_redb"
[profiles.dashmap]
type = "dashmap"
root = "/tmp/terraphim_dashmap"Uncomment the desired profiles:
# Uncomment if SQLite feature is enabled
[profiles.sqlite]
type = "sqlite"
datadir = "/tmp/terraphim_sqlite"
# Uncomment if RocksDB feature is enabled
[profiles.rocksdb]
type = "rocksdb"
datadir = "/tmp/terraphim_rocksdb"| Backend | Speed | Memory Usage | Disk Usage | Dependencies |
|---|---|---|---|---|
| Memory | Fastest | High | None | None |
| DashMap | Very Fast | Medium | None | None |
| ReDB | Fast | Low | Low | None |
| SQLite | Medium | Low | Medium | libsqlite3-sys |
| RocksDB | Fast | Medium | Low | librocksdb-sys |
If you were previously relying on SQLite or RocksDB being available by default:
- Update build commands to include the required features
- Update configuration files to uncomment the database profiles
- Update CI/CD pipelines to build with appropriate features
# Fast builds without heavy databases
- name: Quick Build
run: cargo build
# Full build with all features
- name: Full Build
run: cargo build --features full-dbIf you see an error like:
Error: Unsupported scheme: sqlite
This means the SQLite feature is not enabled. Either:
- Remove SQLite profiles from your configuration, or
- Build with
--features sqlite
If you see:
Error: Profile 'rocksdb' not found
This means your configuration references a RocksDB profile but the feature isn't enabled. Either:
- Comment out RocksDB profiles in configuration files, or
- Build with
--features rocksdb
- Development: Use default features (ReDB/DashMap) for fast builds
- Production: Use ReDB for reliability, SQLite for compatibility, RocksDB for performance
- CI/CD: Test both with and without optional features
- Lightweight deployments: Use default features only