src/libs/localDatabase/ARCHITECTURE.md
The local database is a runtime-neutral persistence boundary. SWR cache persistence is its first consumer, but the database contract and adapters do not depend on SWR.
Repository / feature
│
▼
LocalDatabaseAdapter
┌────┴──────────────┐
▼ ▼
IndexedDB Electron IPC
│
▼
Drizzle query builder
│
▼
node:sqlite
| Layer | Responsibility |
|---|---|
src/libs/localDatabase | Runtime-neutral contract, adapter registration, IndexedDB adapter |
src/libs/swr/localDataCache.ts | SWR-specific repository and cache-key semantics |
apps/desktop/src/main/database | SQLite client, Drizzle schema, and migration execution |
LocalDatabaseSrv | Collection-scoped reads and writes expressed through Drizzle builders |
| Electron IPC | Serialization and process-boundary transport only |
BEGIN IMMEDIATE transaction.apps/desktop/src/main/database/schema.ts.pnpm run db:generate:local from apps/desktop.database/migrations/drizzle.During development, delete and regenerate the latest unreleased migration artifacts when the schema changes. Delete the local cache database when testing a replacement draft migration. After release, the migration becomes immutable and all changes require a new version.
indexedDBMigrations.ts.onupgradeneeded's active transaction.