Math-Royale is a high-stakes competitive programming and mathematical showdown platform. It features a dynamic, multi-round tournament structure with real-time scoring and elimination mechanics.
- ⚔️ 1v1 Tug of War: Real-time competitive matching where solving speed and accuracy shift the score balance.
- 📉 Dynamic Advancement: Automated stage-based progression (Stage A → B → C) with configurable elimination thresholds.
- 🔒 NextAuth Integration: Secure team authentication via Google with custom JWT session handling.
- 📊 Real-time Leaderboards: Global and round-specific rankings to track the best mathematicians and coders in the tournament.
- 🛠️ CLI Admin Tools: Comprehensive command-line interface for managing teams, matches, and tournament progression.
Copy the example environment file and fill in your secrets:
cp .env.local.example .env.local| Variable | Description |
|---|---|
MONGODB_URI |
Your MongoDB connection string. |
GOOGLE_CLIENT_ID |
Google Cloud Console OAuth Client ID. |
GOOGLE_CLIENT_SECRET |
Google Cloud Console OAuth Client Secret. |
NEXTAUTH_SECRET |
A unique, random secret for session encryption. |
NEXTAUTH_URL |
The canonical URL of your site (Production). |
Install dependencies and start the local survival server:
npm install
npm run devVisit http://localhost:3000 to see the arena.
This repository includes a GitHub Actions workflow for Azure App Service deployment:
.github/workflows/deploy-azure-webapp.yml
Use Azure Portal or Azure CLI to create:
- Resource Group
- Linux App Service Plan
- Web App (Node.js 20)
In the Web App Configuration (General settings), set Startup Command to:
node server.jsIn App Service -> Settings -> Environment variables, add at least:
NODE_ENV=productionMONGODB_URI=...GOOGLE_CLIENT_ID=...GOOGLE_CLIENT_SECRET=...NEXTAUTH_SECRET=...NEXTAUTH_URL=https://<your-webapp-name>.azurewebsites.net
In GitHub -> Settings -> Secrets and variables -> Actions, add:
AZURE_WEBAPP_NAME(example:math-royale-prod)AZURE_WEBAPP_PUBLISH_PROFILE(download from App Service -> Get publish profile)
Push to main (or run the workflow manually). The workflow builds Next.js standalone output and deploys it to Azure.
Managing the tournament is handled via scripts in the scripts/ directory.
- Seed Content:
npm run seed-round2 - Initialize:
npm run initialize-tournament-multi(Setup Stage A) - Advance:
npm run advance-round-multi A(Move A → B)
For a complete guide on running the tournament, see: 👉 Tournament Guide (Admin Manual) 👉 Scripts Documentation (CLI Reference)
- Framework: Next.js (App Router)
- Database: MongoDB via Mongoose
- Authentication: NextAuth.js
- Styling: Vanilla CSS + Tailwind-inspired utilities
- Animations: Framer Motion
This project is intended for tournament organization. All rights reserved by the event coordinators.