A Next.js + TypeScript + Supabase application for organizing social tennis matches with automatic player rotation and match generation.
npm install- Create a new project at supabase.com
- Copy your project URL and anon key
- Create
.env.local:
cp .env.local.example .env.local- Add your Supabase credentials to
.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key- Go to your Supabase project dashboard
- Navigate to SQL Editor
- Copy and paste the contents of
supabase-migration.sql - Run the migration
This will create all tables, indexes, RLS policies, and sample court data.
npm run devOpen http://localhost:3000 in your browser.
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Home page
│ └── globals.css # Global styles
│
├── lib/ # Core business logic
│ ├── types.ts # Core type definitions
│ ├── supabase/ # Supabase clients
│ │ ├── client.ts # Client-side
│ │ └── server.ts # Server-side
│ ├── utils/ # Utility functions
│ │ ├── grade-utils.ts # Grade conversions
│ │ ├── court-utils.ts # Court filtering
│ │ └── player-utils.ts # Player selection
│ └── match-generation/ # Match generation algorithms
│ ├── index.ts # Main orchestrator
│ ├── player-rotation.ts # AB-smart rotation
│ ├── perfect-16.ts # Perfect 16 scenario
│ ├── same-sex-matches.ts # Same-sex doubles
│ └── mixed-matches.ts # Mixed doubles
│
├── components/ # React components (to be added)
├── database-types.ts # TypeScript types for database
├── supabase-migration.sql # Database schema
└── database-schema.md # Schema documentation
- Court selection (grass/hard courts)
- Player registration with grades (2, 2A, 2B, 3, 3A)
- Gender-based matching (M/F)
- Multiple set support (1-6 sets per session)
- Same-sex and mixed doubles formats
- Player rotation algorithm (AB-smart)
- Perfect 16 special scenario
- Manual match creation
- Sit-out tracking (PSO - Previously Sat Out)
- NHC (No Hard Court) preference
- User authentication (Supabase Auth)
- Event management UI
- Real-time match updates
- Player history tracking
- Repeat partner/opponent detection
- Grade balancing optimization
- Mobile-responsive design
- Print/export functionality
AB-Smart Rotation: Ensures players get different partners/opponents across sets by splitting players into two groups (A and B) and rotating them at different rates.
Perfect 16: Special algorithm for exactly 16 players of the same gender and grade, ensuring optimal rotation over 5 sets.
Grade System:
- Grade 2 (highest)
- Grade 2A
- Grade 2B
- Grade 3
- Grade 3A (lowest)
See database-schema.md for complete documentation.
Key tables:
profiles- User accounts (Supabase Auth)players- Player master listevents- Tennis sessionscourts- Court definitionsmatches- Generated matchesmatch_players- Player assignments
- Database Schema - Complete schema documentation
- Refactoring Guide - Migration from original code
- Database Types - TypeScript definitions
# Run tests (to be added)
npm test
# Type checking
npx tsc --noEmit
# Linting
npm run lint- Push your code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
The app can be deployed to any platform that supports Next.js:
- Netlify
- Railway
- AWS Amplify
- Self-hosted
The original HTML/JS application had 125+ functions. These have been consolidated into:
- ~40 focused, testable functions
- Type-safe TypeScript
- Separated UI from business logic
- Modular architecture
See REFACTORING-GUIDE.md for detailed mapping.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Private project - All rights reserved
For issues or questions, contact: Paul Oen 0438 374 643