Provide a concise description of:
- The problem being addressed: Traditional competitive programming can feel isolated and lack immediate engagement. BattleCode addresses this by adding real-time 1v1 mechanics and gamified elements.
- Why it is relevant: It provides an interactive environment for developers to test their skills in a head-to-head competitive format, making coding practice more dynamic and social.
- What this project aims to achieve: This project provides the frontend for the BattleCode Arena, enabling participants to solve challenges, manage matches, and track leaderboard status in a highly themed, responsive environment.
The BattleCode frontend is a modern Next.js 16 application built with a focus on real-time interactivity and secure competitive environments.
- Authentication: Integrated with Supabase Auth (Google OAuth) and a custom
AuthContextto verify sessions against a backend API. - Real-time Engine: Uses Socket.IO (
SocketContext) to handle live match status, matchmaking cycles, and the event-driven leaderboard. - Problem Solving Environment: A custom coding interface using Monaco Editor that handles code submission and provides real-time test verification via Judge0 integration.
- Security & Integrity: The
SecureWrappercomponent enforces fullscreen mode and monitors for tab-switching or developer tool usage to maintain fair play.
- Session Management: Auth state is managed via Supabase SSR and Next.js middleware, ensuring protected routes are properly gated.
- Live Updates: The backend pushes round-specific state updates (Round 0-3) over WebSockets, which are consumed by round-specific lobbies and dashboards.
- Execution: User code is sent to the backend proxy, executed via Judge0, and the results are returned to the
CodePagefor immediate display.
| Layer | Technology Used |
|---|---|
| Frontend | Next.js 16 (App Router), React 19, TypeScript |
| Backend | Node.js / Express (Separate Repository) |
| Database | Supabase (PostgreSQL), Redis (for session/round state) |
| Layout / UI | Tailwind CSS 4, Framer Motion |
| Other Tools | Monaco Editor, Socket.IO Client, Chart.js, Lucide React |
src/
├── app/ # Next.js App Router routes and page layouts
│ ├── (main)/ # Protected routes (Dashboard, Rounds 0-3, Admin)
│ ├── api/ # API routes (Auth callback, Session management)
│ └── globals.css # Global design tokens and tailwind configuration
├── components/ # Reusable UI components
│ ├── shared/ # Core features (SecureWrapper, CodePage, Lobbies)
│ └── editor/ # Monaco editor wrappers
├── contexts/ # Application-wide state (Auth, Socket, Round)
├── lib/ # Initialization logic (Supabase, Socket instance)
├── types/ # TypeScript interfaces for questions and round state
└── utils/ # Helper functions for Supabase and general logicgit clone https://github.com/IEEECS-VIT/battlecode-frontend.git
cd battlecode-frontendnpm installCreate a .env.local file in the root directory and define the required variables.
Refer to the Environment Variables section below for the list of required keys.
npm run devdocker build -t battlecode-frontend .docker run -p 3000:3000 battlecode-frontendThis repository uses custom Git hooks to enforce commit standards and branch discipline.
After cloning the repository, run the following command once:
git config core.hooksPath .hooksThis enables:
- Commit message validation
- Blocking direct pushes to
main
| Variable Name | Description |
|---|---|
| NEXT_PUBLIC_SUPABASE_URL | Supabase project URL |
| NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase public anonymous key |
| NEXT_PUBLIC_SOCKET_URL | WebSocket server URL (Socket.IO) |
| NEXT_PUBLIC_API_URL | Backend API server URL |
The project is optimized for deployment on the Vercel Platform.
Build Steps:
- Configure environment variables in the Vercel dashboard.
- Run
npm run buildto generate the production optimized bundle. - Deploy the resulting
.nextoutput.
Currently, unit testing is in the planning phase. To run linting checks:
npm run lint- 🟢 In Development
- IEEE Computer Society, VIT — Event organization
- Judge0 — Code execution engine
- Supabase — Authentication and database
- Vercel — Hosting platform