So I've been building On Your Mind (https://on-your-mind.pages.dev), an anonymous thought-sharing app where AI matches you with strangers thinking similar things in real time. The matching piece uses BGE-small embeddings and pgvector cosine similarity on the backend, but honestly the frontend work around it was the interesting challenge.
The 'Matches' page shows you your semantic thought twins, people you've never met whose thoughts land in the same vector space as yours. Sounds simple to display. It wasn't.
The problem: match scores update as new thoughts come in, embeddings resolve asynchronously, and the UI needed to feel alive without hammering the database. I went through three different approaches with useEffect and Supabase realtime subscriptions before landing on something that didn't either over-fetch or feel stale.
What finally clicked was treating the match results as derived state rather than fetched state, keeping a local embedding cache in a ref and only triggering re-renders when similarity scores crossed a meaningful threshold. Obvious in hindsight, but it took some pain to get there.
The TikTok-style swipe feed had similar quirks around gesture handling and keeping scroll position stable during background updates.
Curious if anyone else has built realtime semantic similarity features in React and how you handled the state synchronization side of it. Did you find Zustand or Jotai made this cleaner, or did you stick with vanilla hooks?