Complete guide to getting your local development environment ready.
- Go to supabase.com and sign in
- Click New project
- Choose your organisation, give the project a name, set a database password (save it somewhere safe), and pick the region closest to you
- Wait for the project to finish provisioning (~1 minute)
The public.users table, app_role enum, RLS policies, and auth
triggers all need to be created before the app can run.
The migration SQL is saved in the repo at
supabase/migrations/01_users_table.sql.
Option A — Supabase Dashboard SQL Editor (easiest)
- In your project dashboard go to SQL Editor
- Click New query
- Paste the contents of
supabase/migrations/01_users_table.sql - Click Run
Option B — Supabase CLI
supabase login
supabase link --project-ref <your-project-ref>
supabase db push- In your Supabase project go to Settings → API
- Copy the following values — you will need them for your
.envfiles:
| Key | Where to find it | Used in |
|---|---|---|
| Project URL | Settings → API → Project URL | client/.env + server/.env |
| Anon / public key | Settings → API → Project API keys → anon public |
client/.env |
| Service role key | Settings → API → Project API keys → service_role |
server/.env only — never expose to the browser |
The service role key bypasses Row Level Security. Keep it in
server/.envonly and never commit it or send it to the client.
cp server/.env.example server/.env
cp client/.env.example client/.envserver/.env:
NODE_ENV=development
SERVER_PORT=3000
SUPABASE_URL=https://<your-project-ref>.supabase.co
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>
CORS_ALLOWED_ORIGINS=http://localhost:5173client/.env:
VITE_SUPABASE_URL=https://<your-project-ref>.supabase.co
VITE_SUPABASE_ANON_KEY=<your-anon-key>To create the four default test accounts (Bryan, Odin, Damon, Boss), run the seed script after your schema is applied:
cd server
npm run db:seedThis uses the Supabase Admin API to create auth users and insert
public.users rows via the handle_new_user DB trigger. Roles that
differ from the default USER are patched in a follow-up UPDATE.
| Username | Role | Password |
|---|---|---|
| Bryan | USER | testpass123 |
| Odin | ADMIN | testpass123 |
| Damon | USER | testpass123 |
| Boss | SUPER_ADMIN | testpass123 |
Running the script a second time is safe — existing users are detected and skipped rather than duplicated.
# From the project root
npm run install:all# From the project root
npm run devOr in VS Code: Terminal → Run Task → 🚀 Dev: Start All
| Problem | Fix |
|---|---|
Missing Supabase environment variables error on server start |
Check that SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are set in server/.env |
Missing Supabase environment variables error in browser |
Check that VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY are set in client/.env |
| Login returns "Invalid login credentials" | The user may not exist yet — run the seed script or sign up manually via the /sign-up page |
| User row missing after signup | Check that the handle_new_user trigger is applied — re-run the migration SQL if needed |
| Seeded user cannot log in | Confirm email_confirm: true was set during seed — check the user in Supabase Dashboard → Authentication → Users |
| CORS error in browser | Ensure CORS_ALLOWED_ORIGINS in server/.env matches your Vite dev server URL (default: http://localhost:5173) |
| Role not updating after promote/demote | Verify your SUPER_ADMIN RLS policy allows UPDATE on the role column for that role |