Developers implemented a hybrid storage system for user favorites, transitioning from browser-based localStorage to a cloud-based PostgreSQL database via Supabase. This approach maintains a guest mode for non-authenticated users while enabling cross-device synchronization for registered accounts.
The system uses a unified hook to manage state, abstracting the storage source. For guests, data resides in localStorage. For authenticated users, the application utilizes Supabase Auth and a public.favorites table, protected by Row Level Security (RLS) policies that restrict access to user-specific rows.
Upon the first login, the application performs a one-way migration of local favorites to the cloud. It identifies missing records by comparing local IDs with existing cloud entries and executes an insert operation. A migration flag is stored in localStorage to prevent redundant data processing on subsequent sessions.
The architecture employs optimistic UI updates, where the interface reflects changes immediately before confirming the database transaction. If a Supabase operation fails, the application reverts the state to the previous version. The system currently supports Magic Link and Google OAuth for authentication.




