Database Backend Features
This document describes the optional database backend features available in Terraphim AI.
Overview
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
Available Features
Default Features
services-dashmap: Fast in-memory concurrent storageservices-redb: Pure Rust embedded databaseservices-atomicserver: Atomic Server integration
Optional Features
services-sqlite: SQLite database supportservices-rocksdb: RocksDB database supportservices-redis: Redis backend supportfull-db: Enable all database backends
Enabling Optional Features
For the Server
# Enable SQLite only
# Enable RocksDB only
# Enable Redis only
# Enable all database backends
# Enable with OpenRouter
For the Desktop App
# Enable SQLite support
# Enable all database features
Cargo.toml Configuration
Add to your Cargo.toml dependencies:
[dependencies]
terraphim_persistence = { path = "../crates/terraphim_persistence", features = ["services-sqlite", "services-rocksdb"] }Configuration Files
When optional database features are disabled, the corresponding profiles in configuration files are commented out:
Default Configuration (ReDB)
[profiles.memory]
type = "memory"
[profiles.redb]
type = "redb"
datadir = "/tmp/terraphim_redb"
[profiles.dashmap]
type = "dashmap"
root = "/tmp/terraphim_dashmap"With Optional Backends Enabled
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"Performance Characteristics
| 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 |
Migration Guide
From Full Dependencies to Optional
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
Example CI Configuration
# Fast builds without heavy databases
- name: Quick Build
run: cargo build
# Full build with all features
- name: Full Build
run: cargo build --features full-dbTroubleshooting
"Scheme not supported" Error
If you see an error like:
Error: Unsupported scheme: sqliteThis means the SQLite feature is not enabled. Either:
- Remove SQLite profiles from your configuration, or
- Build with
--features sqlite
"Profile not found" Error
If you see:
Error: Profile 'rocksdb' not foundThis 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
Recommendations
- 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