- Renamed Event import to EventModel to avoid conflict with global DOM Event interface - Updated type assertion to use EventModel[]
EuchreCamp
A comprehensive tournament management and partnership analytics system for the card game Euchre.
Overview
EuchreCamp is a full-stack web application built with Next.js 14+ and TypeScript that provides:
- Tournament Management: Create and manage round-robin, single elimination, double elimination, and Swiss-style tournaments
- Partnership Analytics: Track partnership performance, win rates, and Elo changes between players
- Player Profiles: Display individual player statistics and partnership breakdowns
- Admin Dashboard: Centralized management interface for tournaments, players, and matches
- Authentication & Authorization: Role-based access control with player, tournament_admin, and club_admin roles
- Home Page: Public-facing landing page showing top players, recent tournaments, and club information
Tech Stack
- Framework: Next.js 14+ (App Router)
- Language: TypeScript
- Database: Prisma ORM with SQLite
- Styling: Tailwind CSS
- Authentication: Better Auth
- Form Handling: React Hook Form + Zod validation
- CSV Parsing: PapaParse
- Unit Testing: Vitest
- Acceptance Testing: Playwright
Project Structure
euchre_camp/
├── src/
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── auth/ # Authentication pages
│ │ ├── admin/ # Admin pages
│ │ ├── players/ # Player pages
│ │ ├── rankings/ # Rankings page
│ │ └── components/ # Shared components
│ ├── lib/ # Utilities and configuration
│ │ ├── auth.ts # Better Auth configuration
│ │ ├── prisma.ts # Prisma client
│ │ ├── permissions.ts # Authorization functions
│ │ └── elo-utils.ts # Elo calculation utilities
│ └── __tests__/ # Vitest and Playwright tests
├── prisma/ # Prisma schema and migrations
├── docs/ # Documentation
├── scripts/ # Utility scripts
└── public/ # Static assets
Features Implemented
Epic 1: Authentication & User Management
- User registration with email confirmation
- Login with credentials
- Password reset flow
- Session management with Better Auth
- Role-based access control (player, tournament_admin, club_admin)
Epic 2: Player Profile & Analytics
- Player profile page with statistics
- Partnership performance table
- Win rate and Elo display
- Direct player stats (gamesPlayed, wins, losses)
Epic 3: Rankings & Public Data
- Player rankings page
- Sortable rankings table
- Public player profiles
- Home page with top 10 players, recent tournament, club president
Epic 4: Tournament Management
- Create tournaments
- Manage participants
- Create teams
- View tournament details
Epic 5: Match Recording & CSV Import
- Record match results via API
- CSV upload for batch processing
- Automatic Elo calculation
- Partnership tracking
Getting Started
Prerequisites
- Node.js 20+
- npm or yarn
- SQLite3 (default) or PostgreSQL (optional)
For SQLite (default):
- No additional setup required
For PostgreSQL:
- PostgreSQL 12+ installed and running
- Create a database for EuchreCamp
Installation
-
Clone the repository
git clone <repository-url> cd euchre_camp -
Install dependencies
npm install -
Set up environment variables
cp .env.example .env # Edit .env to configure your database -
Set up the database
For SQLite (default):
npx prisma migrate deploy npx prisma generateFor PostgreSQL:
# Set up PostgreSQL database npm run db:setup-postgres # Or manually: npx prisma migrate deploy npx prisma generate -
Start the development server
npm run dev
Environment Variables
Create a .env file:
# Database Configuration
DATABASE_PROVIDER=sqlite # or "postgresql"
DATABASE_URL="file:./dev.db"
# Better Auth
BETTER_AUTH_SECRET="your-secret-key-here"
BETTER_AUTH_URL="http://localhost:3000"
Using PostgreSQL:
DATABASE_PROVIDER=postgresql
DATABASE_URL="postgresql://username:password@localhost:5432/euchre_camp"
DATABASE_SHADOW_URL="postgresql://username:password@localhost:5432/euchre_camp_shadow"
Usage
Creating a Tournament
- Navigate to
/admin/tournaments - Click "Create Tournament"
- Fill in tournament details
Uploading Match Results via CSV
- Navigate to
/admin/matches/upload - Select a tournament
- Upload CSV file with Euchre format
Viewing Player Profiles
Navigate to /players/[id]/profile to see statistics, partnerships, and recent games.
Home Page
Visit / to see:
- Top 10 players by Elo rating
- Most recent tournament with full match list
- Club president information
API Endpoints
Tournaments
GET /api/tournaments- List all tournamentsPOST /api/tournaments- Create new tournament
Matches
GET /api/matches- List matchesPOST /api/matches/upload- Upload CSV with match results
Authentication
POST /api/auth/sign-up/email- Register new accountPOST /api/auth/sign-in/email- Login with email/passwordPOST /api/auth/sign-out- Logout
Users
GET /api/users/[id]/role- Get user role
Development
# Development mode
npm run dev
# Production build
npm run build
npm start
# Run unit tests
npm run test
# Run acceptance tests
npm run test:acceptance
Database Commands
# Switch between SQLite and PostgreSQL
npm run db:switch sqlite
npm run db:switch postgresql
# Set up PostgreSQL database
npm run db:setup-postgres
# Seed database with sample data
npm run db:seed
Admin User Creation
To create an admin user, use the provided scripts:
Option 1: Using Better Auth API (Recommended)
node scripts/create-admin-via-api.js
This creates the admin user david@dhg.lol with password adminadmin using Better Auth's internal API.
Option 2: Direct Database Creation
node scripts/create-admin-better-auth.js
This creates the admin user david@dhg.lol with password admin directly in the database.
List All Users:
node scripts/list-users.js
Update Admin Password:
node scripts/update-admin-password.js
This updates the admin password to adminadmin.
Note: All scripts currently create the user david@dhg.lol. If you need to create a different admin user, you can modify the email in the script or use Better Auth's CLI.
User Stories
User stories are organized into epics in docs/USER_STORIES.md:
- Authentication & User Management
- Player Profile & Analytics
- Rankings & Public Data
- Tournament Management
- Match Recording & CSV Import
- Club Administration
- Mobile Responsiveness
- Data Management & Export
Docker Deployment
This application can be run using Docker and Docker Compose. See DOCKER.md for detailed instructions.
Quick Start:
# Start all services (PostgreSQL + Next.js app)
docker-compose up -d
# Access the application
# http://localhost:3000
Development Mode:
# Start with hot reload
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
License
MIT License