This project is a Next.js tournament dashboard backed by Supabase. It includes a secure admin area for managing teams, matches, score entry, and standings in real time.
The application expects a Supabase project with the following setup:
-
Create the database schema
- Run
scripts/001_create_tables.sqlin the Supabase SQL editor to provision all tournament tables. - The
teamstable must contain the columnsnameandcaptain. The script also enables row level security and policies that allow public reads while restricting writes to authenticated users.
- Run
-
Seed development data
- Execute
scripts/002_seed_data.sqlto populate sample teams, standings, matches, and players. Update or remove the seed script as needed for production.
- Execute
-
Provision admin profiles
- Run
scripts/003_create_admin_users.sql. This creates aprofilestable linked toauth.users, sets a defaultroleofadmin, and configures the trigger that inserts a profile whenever a new auth user is created. - Create admin accounts in Supabase Authentication (or through the
/auth/sign-uppage). Each admin must have a corresponding profile row withrole = 'admin'.
- Run
-
Environment variables
-
Add the Supabase project URL and anon key to
.env.local:NEXT_PUBLIC_SUPABASE_URL=your-project-url NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
-
Restart the Next.js dev server after updating environment variables.
-
Authenticated users with the admin role gain access to the /admin routes:
- Dashboard: overview of teams, matches, and quick links to common tasks.
- Teams: create, edit, and delete entries in the Supabase
teamstable. - Matches and Score Entry: manage match lifecycle and update live scores.
Middleware and server-side checks ensure only admin users can reach these pages. Non-admin users
are redirected to /auth/error?error=not-authorized.
Install dependencies and start the dev server:
npm install
npm run devRun linting before committing changes:
npm run lint