A simple, beginner-friendly full-stack web application for tournament registration and live scoreboard display. Built with Next.js and Firebase.
- Team Registration: Web form to register teams with player names and email
- Live Scoreboard: Real-time score updates using Firebase listeners
- Unity Integration: REST API endpoints for game integration
- Auto Team Numbering: Teams are automatically assigned sequential numbers
- Unique IDs: Each team gets a unique 5-character alphanumeric ID
- Secure: Firebase security rules prevent unauthorized data modification
- Frontend: Next.js (React)
- Backend: Firebase Firestore
- Hosting: Vercel
- Real-time Updates: Firebase real-time listeners
- API: Next.js API routes
tournament-scoreboard/
├── components/
│ └── Layout.tsx # Shared layout component
├── lib/
│ ├── firebase.ts # Firebase configuration
│ └── firestore.ts # Database operations
├── pages/
│ ├── api/
│ │ ├── register.ts # POST /api/register
│ │ ├── update-score.ts # POST /api/update-score
│ │ └── scoreboard.ts # GET /api/scoreboard
│ ├── _app.tsx # Next.js app wrapper
│ ├── index.tsx # Registration page
│ └── scoreboard.tsx # Live scoreboard page
├── styles/
│ └── globals.css # Global styles
├── firestore.rules # Firebase security rules
└── .env.local.example # Environment variables template
npm install- Go to Firebase Console
- Create a new project
- Enable Firestore Database
- Get your config values from Project Settings > General > Your apps
- Copy
.env.local.exampleto.env.localand fill in your values:
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789
NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789:web:abcdefghijklmnop- Go to Firebase Console > Firestore Database > Rules
- Copy the contents of
firestore.rulesand paste them - Click "Publish"
npm run devVisit http://localhost:3000 to see your app!
- Push your code to GitHub
- Go to Vercel
- Import your GitHub repository
- Add your environment variables in Vercel settings
- Deploy!
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodYour Unity game can use these API endpoints:
POST /api/register
Content-Type: application/json
{
"player1": "Alice",
"player2": "Bob",
"email": "team@example.com"
}Response:
{
"success": true,
"data": {
"teamNumber": 1,
"uid": "qK234",
"player1": "Alice",
"player2": "Bob",
"email": "team@example.com",
"score": 0
}
}POST /api/update-score
Content-Type: application/json
{
"uid": "qK234",
"scoreIncrement": 100
}GET /api/scoreboardTeams are stored in Firestore with this structure:
{
"teamNumber": 1,
"uid": "qK234",
"player1": "Alice",
"player2": "Bob",
"email": "team@example.com",
"score": 0,
"createdAt": "2024-01-15T10:30:00Z"
}- Firebase security rules prevent unauthorized writes
- Only score updates are allowed after team registration
- Score increments are limited to prevent abuse
- Email validation on registration
- All API endpoints include proper error handling
This is a beginner-friendly project! Feel free to:
- Add new features
- Improve the UI/UX
- Fix bugs
- Add tests
- Improve documentation
MIT License - feel free to use this project for your tournaments!