A comprehensive sports team management platform with separate player and admin applications, built on a shared codebase.
matchday/
βββ apps/
β βββ player/ # Player-facing Next.js app (port 3000)
β βββ admin/ # Admin Next.js app (port 3001)
βββ packages/
β βββ database/ # Shared database types and schema
β βββ services/ # Shared business logic services
β βββ auth/ # Authentication utilities
β βββ shared/ # Common utilities and helpers
βββ supabase/ # Database migrations and config
βββ pnpm-workspace.yaml # Workspace configuration
- Team Management: Create and manage teams with detailed player rosters and statistics
- League Discovery: Browse and join leagues for organized play
- Player Dashboard: Comprehensive player profiles with performance analytics
- Match Recording: Post-match score recording and statistics tracking
- Achievement System: Player achievements and performance recognition
- Global Leaderboards: Track top performers across leagues and teams
- User Authentication: Secure authentication with user profiles and preferences
- Responsive Design: Optimized for desktop and mobile devices
- Node.js 18+
- pnpm 8+ (
npm install -g pnpm) - Supabase account
# Install all dependencies
pnpm install
# Start player app (port 3000)
pnpm dev:player
# Start admin app (port 3001)
pnpm dev:admin
# Run both apps simultaneously
pnpm devPlayer-facing features:
- Team management and player rosters
- League discovery and joining
- Match tracking and live scoring
- Player dashboards and statistics
- Achievement system
- Global leaderboards
Port: 3000
Environment: .env.local with NEXT_PUBLIC_SITE_URL=http://localhost:3000
Admin-facing features:
- League management and creation
- Team join request approval
- Match scheduling and management
- User role administration
- System oversight and analytics
Port: 3001
Environment: .env.local with NEXT_PUBLIC_SITE_URL=http://localhost:3001
Database types and schema definitions generated from Supabase. Provides type-safe access to:
- User profiles
- Leagues and seasons
- Teams and team members
- Matches and statistics
Shared business logic services:
- League service
- Team service
- Match service
- Season service
- Player service
- User service
- Stats service
- Analytics service
- Achievement service
Authentication and authorization utilities:
- JWT validation
- Role-based access control
- Session management
Common utilities and helpers:
- Tailwind class utilities (cn)
- Date formatters
- Environment validation
- Constants and configurations
# Development
pnpm dev # Run both apps in parallel
pnpm dev:player # Run player app only
pnpm dev:admin # Run admin app only
# Building
pnpm build # Build all apps and packages
pnpm build:player # Build player app
pnpm build:admin # Build admin app
pnpm build:packages # Build shared packages only
# Code Quality
pnpm lint # Lint both apps
pnpm type-check # Type-check both apps
pnpm test # Run player app tests
pnpm format # Format all code with Prettier
# Cleaning
pnpm clean # Remove all node_modules and build artifactsBoth apps share the same Supabase PostgreSQL database.
Database migrations are located in supabase/migrations/ and managed centrally.
# Apply migrations
npx supabase db push
# Create new migration
npx supabase migration new migration_nameWhen database schema changes:
- Update migrations in
supabase/migrations/ - Regenerate types in
packages/database/src/database.types.ts - Update service layer if needed
Both apps require environment variables for Supabase connection.
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_SITE_URL=http://localhost:3000NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
NEXT_PUBLIC_SITE_URL=http://localhost:3002- Framework: Next.js 15 with App Router
- Frontend: React 19, TypeScript 5
- Styling: Tailwind CSS v4
- Database: Supabase (PostgreSQL)
- Authentication: Supabase Auth
- State Management: React Query (TanStack Query)
- Monorepo: pnpm workspaces
- Testing: Jest, React Testing Library
- Database Types: Add to
packages/database/src/database.types.ts - Services: Add to
packages/services/src/ - Auth Logic: Add to
packages/auth/src/ - Utilities: Add to
packages/shared/src/
# Create new app directory
mkdir apps/new-app
# Add to workspace
# Update pnpm-workspace.yaml (already includes apps/*)
# Install workspace dependencies
cd apps/new-app
pnpm add @matchday/database@workspace:*
pnpm add @matchday/services@workspace:*// In any app
import { Database } from '@matchday/database';
import { LeagueService } from '@matchday/services';
import { validateSession } from '@matchday/auth';
import { cn, formatDate } from '@matchday/shared';Both apps can be deployed separately to Vercel:
# Deploy player app
cd apps/player
vercel
# Deploy admin app
cd apps/admin
vercel --prodConfigure environment variables in Vercel dashboard for each app.
The monorepo is compatible with:
- Netlify
- Railway
- AWS Amplify
- DigitalOcean App Platform
π¨ CRITICAL: If you've leaked Supabase keys, follow the KEY_ROTATION_CHECKLIST.md immediately.
For security best practices, RLS policies, and incident response procedures, see SECURITY.md.
- β
Keep
.env.localfiles OUT of git (already in.gitignore) - β Use LOCAL Supabase for development (not production)
- β Environment variables are validated on app startup
- β All database tables have Row Level Security (RLS) enabled
β οΈ Never commitSUPABASE_SERVICE_ROLE_KEY- it's server-side only
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Test both apps:
pnpm test && pnpm type-check - Commit:
git commit -m 'feat: add feature' - Push:
git push origin feature/your-feature - Open a pull request
MIT License - see LICENSE file for details
For issues and questions:
- Check existing issues on GitHub
- Create a new issue with detailed description
- Include error messages and reproduction steps