A mobile-first habit tracker: swipe-to-log habits, real streaks computed from actual history, and an Apple Fitness–style calendar heatmap per habit. Built with React, Vite, TypeScript, and Supabase (Postgres + Auth).
- Database: open your Supabase project's SQL Editor and run
supabase/migrations/0001_init.sql. This creates thehabitsandhabit_completionstables with row-level security scoped to each signed-in user. - Env vars: copy
.env.exampleto.envand fill in your Supabase project URL and anon key (Project Settings → API):VITE_SUPABASE_URL=https://your-project.supabase.co VITE_SUPABASE_ANON_KEY=your-anon-key - Install & run:
npm install npm run dev
A workflow (.github/workflows/deploy.yml) builds and deploys this repo to
GitHub Pages automatically on every push to main. One-time setup:
-
Enable Pages: repo → Settings → Pages → set Source to GitHub Actions.
-
Add config: repo → Settings → Secrets and variables → Actions → Variables tab → New repository variable, and add both:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEY
These are added as variables, not secrets, because the Supabase anon key is designed to be public in client-side bundles — actual data access is protected by the row-level security policies in the migration, not by hiding this key.
-
Push to
main(or re-run the workflow from the Actions tab) — the site will be live athttps://<your-username>.github.io/habit-tracker/.
npm run dev— start the dev servernpm run build— typecheck + production build todist/npm run test— run the streak/calendar math unit testsnpm run lint— lint
- Auth: Supabase email/password. Sign-up collects a name (stored as user metadata) and, depending on your project's email confirmation setting, either logs the user in immediately or shows a "check your email" screen.
- Onboarding: shown whenever a signed-in user has zero habits — fully custom habit name, icon, and daily target.
- Track tab: swipe a habit card right to log a completion, left to undo. Completed habits sort to the bottom.
- Streaks tab: per-habit and "all habits" streaks are computed from real
daily completion counts (
src/lib/streaks.ts), not mocked — seestreaks.test.tsfor the behavior under test. Tapping a habit opens a month calendar heatmap with real fill data and month navigation. - Manage tab: edit, delete, reorder, and adjust targets for habits.