BlazeDB: Swift Native Embedded Storage Engine (open source)
I posted about BlazeDB here a while back when it was still an experiment. It's come a long way since then and I'm open sourcing it.
The basic idea: you define a struct, conform it to BlazeStorable, and store it. Queries use KeyPaths, everything is encrypted at rest, and writes go through a WAL so committed data survives crashes.
let db = try BlazeDBClient.open(named: "myapp", password: "your-password")
let counters = db.typed(Counter.self)
try counters.insert(Counter(name: "Alice", count: 10))
try counters.insert(Counter(name: "Bob", count: 20))
let results = try counters.query()
.where(\.count, greaterThan: 15)
.all()
It's schemaless by default so you don't have to define anything upfront. But there's also a raw record layer if you want to work with dynamic data directly:
let record = BlazeDataRecord([
"name": .string("Alice"),
"age": .int(30)
])
try db.insert(record)
let results = try db.query()
.where("status", equals: .string("open"))
.orderBy("created_at", descending: true)
.limit(10)
.execute()
.records
One of the things I'm most happy with is the SwiftUI integration. There's a @BlazeQuery property wrapper that observes the database and re-runs your query when data changes. Your views just stay in sync:
struct RecordList: View {
@BlazeQuery(db: db, limit: 100) var results: [BlazeDataRecord]
var body: some View {
List(results, id: \.id) { record in
Text(record.description)
}
}
}
Changes get batched over a 50ms window so it's not re-querying on every single write.
I built this for my own developer tools and personal projects. I use CoreData at work and it's fine, but for my own stuff I kept wanting something with less setup. And I like SQLite but I got tired of writing SQL in Swift. I just wanted to define a struct, store it, query it with KeyPaths, and have encryption on by default so I don't have to think about it.
Everything is AES-256-GCM encrypted at the page level, and the WAL stores only encrypted frames. Getting that working on macOS was straightforward. CryptoKit handles it. Linux was a different story. swift-crypto, endianness differences, platform assumptions that break once you're off Apple hardware. I got the core engine running there, but honestly it hasn't seen the same real-world testing that macOS has. That's still a work in progress.
I put a lot of effort into the testing to make sure the durability claims actually hold up: chaos tests, concurrency tests with a couple hundred simultaneous writers, crash recovery validation. I didn't want to put "crash safe" in the README and just hope it's true.
Where I'd like to take this eventually is using BlazeDB as a shared storage layer across client and server, all in Swift. There's early Vapor integration in the repo already. The idea is you could use the same engine and same models in your iOS app and your Vapor backend for personal tools, single-user apps, local-first stuff. Not trying to build a Postgres competitor. But for something like a single-user app with a Swift backend where you want the same storage on both sides and everything encrypted, that's the use case I care about.
The repo also has migrations if you need them, CLI tooling for inspecting and diagnosing databases, and docs covering the architecture and benchmarks.
macOS 15+, iOS 15+, Linux. Swift 6 concurrency compliant.