Choose a Storage Strategy

Start with the data, not the database.

Decision Tree

flowchart TD
    start["What owns the data?"] --> userData{"User-owned durable data?"}
    userData -->|No| cache["Use cache or preferences"]
    userData -->|Yes| platform{"Runtime?"}
    platform -->|Android| room["Room over SQLite"]
    platform -->|Browser| indexeddb["IndexedDB or OPFS"]
    platform -->|Desktop or CLI| sqlite["SQLite or files"]
    sqlite --> fileNeed{"Human-editable files matter?"}
    fileNeed -->|Yes| files["Markdown JSON JSONL plus derived index"]
    fileNeed -->|No| sqliteDb["SQLite DB"]
    room --> privateData{"Private data?"}
    indexeddb --> privateData
    sqliteDb --> privateData
    files --> privateData
    privateData -->|Yes| keys["Add key storage and encrypted backup design"]
    privateData -->|No| backup["Add export and restore"]

Practical Defaults

ProductDefault
Android finance trackerRoom, CSV export, app lock, optional encrypted backup
Offline PWAIndexedDB through Dexie, service worker cache, export/import, quota UX
Tauri desktop toolSQLite in app data path, Stronghold/keychain for secrets, app-document export
Local AI assistantSQLite sessions, JSONL transcripts, Markdown memory, FTS/vector derived indexes
Document vaultfile/attachment store plus manifest, encrypted backup, SQLite metadata index

Questions To Answer

  1. Is the data source-of-truth or cache?
  2. Must the user inspect/edit it outside the app?
  3. What is the restore path after device loss?
  4. How large can it get?
  5. Does it need relational queries?
  6. Does it need multi-device sync or just backup?
  7. What is the threat model?

If you cannot answer 3 and 7, do not claim the app is safe for private local-first data.