Description
The current client-side caching strategy relies on localStorage, which is capped at ~5 MB and synchronous, causing jank when reading large invoice lists. Migrating to IndexedDB gives the app an asynchronous, quota-managed store that can hold much larger datasets and supports structured queries, enabling faster cold-start rendering.
Technical Context
New abstraction layer at src/lib/db/invoiceCache.ts wrapping the browser's indexedDB API (or the idb npm package for promise ergonomics). The useInvoices hook in src/hooks/useInvoices.ts is updated to read from IndexedDB first, then hydrate from the API and write back. A src/lib/db/schema.ts file defines the object store names, key paths, and index definitions. Cache invalidation is tied to the invoice updatedAt timestamp.
Acceptance Criteria
Description
The current client-side caching strategy relies on
localStorage, which is capped at ~5 MB and synchronous, causing jank when reading large invoice lists. Migrating to IndexedDB gives the app an asynchronous, quota-managed store that can hold much larger datasets and supports structured queries, enabling faster cold-start rendering.Technical Context
New abstraction layer at
src/lib/db/invoiceCache.tswrapping the browser'sindexedDBAPI (or theidbnpm package for promise ergonomics). TheuseInvoiceshook insrc/hooks/useInvoices.tsis updated to read from IndexedDB first, then hydrate from the API and write back. Asrc/lib/db/schema.tsfile defines the object store names, key paths, and index definitions. Cache invalidation is tied to the invoiceupdatedAttimestamp.Acceptance Criteria
invoiceswithidas the key path and an index onstatusupdatedAttimestamp