Browser Storage as the Financial Vault
May 8, 2026By Pocket Portfoliotechnical

#local-first#storage#firebase#engineering
Sovereign Engineering Β· Part 5
Guest: localPortfolioStore.ts
const STORAGE_KEY_TRADES = 'pocket-portfolio-local-trades';
Trades JSON + metadata; quota estimated vs 5MB budget β fail closed when over threshold.
Auth: useTrades β TradeService.getTrades(uid, forceServerFetch)
Cloud is authoritative for signed-in users; UI still filters healed IDs from localStorage.
Prefs: portfolioStore persist + partialize
Only chart view, time range, sectors, benchmarks β not full positions blob.
Logout: useAuth β clearIndexedDbPersistence + terminate(db)
Clears Firestore client cache (IndexedDB), not βthe vaultβ for guests.
Read the Sovereign Intelligence book or try Pocket Portfolio.