
Indie health app piles on three storage layers: zustand cache, indexeddb drudgery, and encrypted vault because one db meant bugs and data leaks galore
A recent article discusses the implementation of a local-first Progressive Web App (PWA) architecture for a health tracking application, Pain Tracker. The app utilizes three storage layers: a state cache, an offline database using IndexedDB, and an encrypted vault database. The state cache, implemented using Zustand, stores fast in-memory app state, while the offline database stores durable data that survives refresh and restart. The encrypted vault database stores sensitive payloads, ensuring confidentiality. The app's architecture is designed to prioritize security and privacy, with a clear separation of concerns between the different storage layers. The use of an encrypted vault database ensures that sensitive data is protected at rest, and the app's persistence flow is designed to prevent unauthorized access to sensitive data. The Pain Tracker project is open-source and available on GitHub, with a detailed documentation of the app's storage architecture and migration strategy.