CodeBattle Arena is a competitive programming platform designed for live coding competitions targeting college students. The platform provides secure code execution, real-time judging, live leaderboards, and comprehensive anti-cheating measures. Built as a full-stack web application, it supports multi-language code submissions (Python and JavaScript) with instant feedback and automated test case validation.
The system is architected to host fair, engaging coding events with features like tab-switching detection, paste prevention, submission history tracking, and real-time competitive rankings. The platform emphasizes both security (containerized code execution) and user experience (Monaco editor integration, modern dark-themed UI).
-
⚡ Live Code Judging: Get instant feedback on your solutions with a secure, sandboxed execution engine for both Python and JavaScript.
-
🛡️ Secure Authentication: A complete user registration and login system using secure, session-based authentication with Passport.js.
-
🏆 Competitive Leaderboard: See how you stack up against your peers with a real-time leaderboard that ranks users by problems solved and speed.
-
📝 Personal Submission History: Track all your past attempts, review your code, and see your progress on a personal submissions page.
-
🚫 Robust Anti-Cheating: Ensures the integrity of competitions with built-in tab-switching detection and disabled pasting in the code editor.
-
💻 Modern IDE Experience: A sleek, dark-themed UI featuring the integrated Monaco Editor (the engine behind VS Code) for a professional coding environment.
-
🎮 Contest Mode: Full contest lifecycle management with scheduled lobbies, active countdowns, and dynamic UI based on the contest state.
-
📊 Admin Analytics: Comprehensive admin dashboards for creating problems, scheduling contests, and viewing detailed past contest stats including winners and participation metrics.
The project is a full-stack TypeScript monorepo with a clear separation of concerns.
Technology
Frontend
React 18, TypeScript, Vite, Tailwind CSS, Shadcn/ui, TanStack Query, Monaco Editor
Backend
Node.js, Express.js, TypeScript, Passport.js, Zod
Database
MongoDB (hosted on MongoDB Atlas), Mongoose ORM
Code Judge
Node.js child_process API for sandboxed execution
Dev Tools
tsx for live server reloading, drizzle-kit for migrations
Follow these steps to get a local copy of CodeBattle Arena up and running on your machine.
-
Node.js: v18 or higher.
-
Git: For cloning the repository.
-
MongoDB Atlas Account: You will need a free cluster from MongoDB Atlas or a local MongoDB instance.
git clone https://github.com/dipankarchettri/CodeBattle-Arena.git
cd CodeBattleArena
This is a monorepo, so all dependencies are managed from the root package.json.
npm install
The server requires a database connection string and a session secret to run.
-
Create a .env file in the root of the project directory.
-
Add your MongoDB connection string and a session secret.
# Get this from your MongoDB Atlas dashboard
MONGODB_URI="mongodb+srv://user:password@cluster0.mongodb.net/codebattle?retryWrites=true&w=majority"
# Generate a long, random string for this
SESSION_SECRET="your-super-long-and-random-session-secret"-
Get Your MONGODB_URI:
-
Log in to your MongoDB Atlas account and go to your cluster.
-
Click Connect, then Connect your application.
-
Copy the connection string and replace the username and password with your database user credentials.
-
-
Generate Your SESSION_SECRET:
-
Run
openssl rand -base64 32in your terminal. -
Copy the output and paste it into your .env file.
-
The backend will automatically seed problems on first startup if the database is empty, so no manual database push is required!
You are now ready to start the development server! This single command will start both the backend server and the frontend Vite server concurrently.
npm run dev
Your application should now be running!
-
Backend API: http://localhost:5000
-
Frontend App: http://localhost:5173 (This is the URL to open in your browser)
The project is organized as a monorepo with three main directories:
client/# React frontend application (Vite, Shadcn)server/# Express.js backend API (Node.js, Drizzle)shared/# Shared code, primarily the Drizzle database schema.env# Local environment secrets (DO NOT COMMIT)package.json# Root dependencies and scripts
- Team Competitions: Allow users to form teams and compete together.
- Multi-language Support for Judge: Expand from Node.js child_process to Dockerized environments for safe execution of C++, Java, and more.