FORM is a Next.js app for logging body weight, calories, and measurements to estimate TDEE from real-world trend data.
Repository: https://github.com/HimashaHerath/Form
- Passwordless auth with Supabase magic links
- Onboarding flow for baseline settings
- Daily log tracking (weight + calories)
- Body measurement logging and body-fat estimation support
- Progress/history views with charts
- Import/export for user data
- Next.js 16 (App Router, Turbopack)
- React 19 + TypeScript
- Zustand for client state
- Supabase (Auth + Postgres via PostgREST)
- Tailwind CSS + Radix UI primitives
- Vitest + Testing Library
src/
app/ # routes (dashboard, log, history, body, settings, auth)
components/ # UI, layout, forms, charts
hooks/ # domain hooks (e.g. TDEE calculations)
lib/
storage/ # DataStore interface + local/supabase implementations
supabase/ # browser/server Supabase client helpers
store.ts # Zustand store and app hydration logic
types.ts # shared domain types
supabase/
schema.sql # required DB schema + RLS policies
- Node.js 20+ (Node 22.x recommended)
- npm
- A Supabase project
- Install dependencies:
npm install-
Create a Supabase project.
-
In Supabase SQL Editor, paste and run all SQL from
supabase/schema.sql. -
Configure Supabase Auth:
- Enable Email provider (magic link)
- Set Site URL to
http://localhost:3000 - Add Redirect URL:
http://localhost:3000/auth/callback
- Create
.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://<your-project-ref>.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-key>- Start the app:
npm run devOpen http://localhost:3000.
npm run devstarts local development servernpm run buildcreates production buildnpm run startruns production servernpm run teststarts Vitest in watch modenpm run test:runruns tests once (CI style)npm run lintruns ESLint
The app relies on three Supabase tables in public:
settingsday_logsbody_logs
Row Level Security policies are required so authenticated users can only access their own rows. The provided supabase/schema.sql file creates tables, indexes, RLS policies, and grants.
- Create a feature branch from
main. - Keep changes focused and scoped.
- Run checks before opening a PR:
npm run build
npm run test:run
npm run lint- Include a clear PR description:
- What changed
- Why it changed
- Screenshots/GIFs for UI changes
- Any schema/env updates
- If your work changes DB shape or auth behavior, update:
supabase/schema.sql- this README
-
404on/rest/v1/settings:supabase/schema.sqlwas not applied to the current Supabase project. -
406on/rest/v1/settings: Usually means querying a single row that does not exist yet; ensure you are on latest code and restart dev server. -
Auth redirects keep sending you to
/auth: VerifyNEXT_PUBLIC_SUPABASE_URL,NEXT_PUBLIC_SUPABASE_ANON_KEY, and callback URL configuration. -
ESLint CLI crashes with
Cannot find module '../package.json': Reinstall dependencies:
rm -rf node_modules package-lock.json
npm install- Do not commit
.env.local. - Use only the public anon key on the client.
- Service-role keys must never be exposed in frontend code.