Review request

Habit tracker for my students, does this Next.js + Supabase setup look sane?

Solved · 10 views · asked by rosa_m · edited

Repo or live app

github.com/rosam/streaks

I teach and built this so my students can track daily practice streaks. Cursor and I got the data model to a point where it works, but I copy-pasted a lot of Supabase examples and I'm not sure the table structure makes sense long-term.

Comment

1 answer

Marked as helpful by the asker
mira_dev · edited

The schema is fine for the size you're at. One thing that will bite you: streaks has a current_streak column you update from the client on every check-in. That will drift out of sync the moment two devices check in close together.

Compute it instead with a Postgres function that counts consecutive days from checkins, called from a trigger after insert. Slightly more setup, never wrong.

Comment