PhoenixDB
ACID embedded database β Rust core, Dart/Flutter FFI
Read the full case studyKey Facts & Overview
PhoenixDB is an ACID-compliant embedded database engine written in Rust and exposed to Dart/Flutter through a zero-overhead dart:ffi layer. Use it as a key/value store, as typed preferences, for HNSW vector similarity search, or through a small optional SQL front end. It ships B+Tree storage, MVCC transactions, a write-ahead log, and runtime-dispatched SIMD kernels.
- βΊFeature flags: sql, encryption, json, metrics, full β opt into what you need.
- βΊFlutter apps need no Rust toolchain; Android ships prebuilt binaries.
- βΊAsync API runs every call on a worker isolate so the UI never blocks.
- βΊSecurity: FFI guardrails, handle tagging, constant-time compares, panic containment.
Core Architectural Features
Installation
flutter pub add phoenixdb
# Or in pubspec.yaml:
# dependencies:
# phoenixdb: ^4.1.1
# Use `flutter pub`, not `dart pub`:
# PhoenixDB is an FFI plugin, so pub.dev requires the Flutter SDK bound.Usage
import 'package:phoenixdb/phoenixdb.dart';
// Synchronous key/value
final db = PhoenixDatabase.open('data.pdb');
db.insert(utf8Key('hello'), utf8Value('world'));
print(utf8Decode(db.getOrThrow(utf8Key('hello')))); // world
db.transaction((txn) {
db.insert(utf8Key('a'), utf8Value('1'), txnId: txn);
db.insert(utf8Key('b'), utf8Value('2'), txnId: txn);
});
db.close();
// Asynchronous (recommended for Flutter)
final adb = await AsyncPhoenixDB.open('data.pdb');
await adb.insert(utf8Key('k'), utf8Value('v'));
final value = await adb.get(utf8Key('k'));
await adb.close();API Reference
PhoenixDatabase.open(path)Open (or create) a synchronous key/value database.
AsyncPhoenixDB.open(path)Open an async database backed by a worker isolate.
PhoenixPrefs.open(path)Typed shared_preferences-style facade over the same store.
PhoenixVectorDB.open(path, dimensions, metric)Open an HNSW vector index for local-first semantic search.
db.query('SQL...')Run SQL when built with the sql feature; returns rows / scalar / asMaps.
db.transaction((txn) { ... })Run a block inside an ACID transaction with a txn id.