async/await, @MainActor, Sendable, and Actor isolation) to eliminate data races and SQLITE_BUSY crashes.
Isolation Architecture
BoutiqueDBContainer: Annotated with@MainActor. You can store reference instances in your App State,@StateObject, or@Observablemodels.DatabaseActor: Isolated actor where all disk reads, SQL compilation, and writes take place.
Read vs Write Isolation Rules
db.read Closure
Provides a read-only
BoutiqueDBConnection. Safe to run concurrent reads simultaneously across threads.db.write Closure
Provides an exclusive write transaction. Automatically manages
BEGIN and COMMIT/ROLLBACK.ConcurrencyExample.swift
Best Practices for Concurrency
Do: Pass value-type models (
Sendable structs) in and out of db.read and db.write closures.
