A competitive coding battle platform where two users race to solve Codeforces problems in a private timed room.
BattleForces/
├── backend/ # Node.js + Express + MongoDB
│ ├── server.js
│ ├── .env
│ └── src/
│ ├── models/ Battle.js
│ ├── routes/ battleRoutes.js, profileRoutes.js
│ ├── controllers/ battleController.js, profileController.js
│ └── services/ codeforcesService.js
└── frontend/ # React + Vite + Tailwind CSS v4
└── src/
├── pages/ Home.jsx, BattleRoom.jsx, Profile.jsx
├── components/ Navbar.jsx, Timer.jsx
├── api.js
└── index.css
- Node.js 18+
- MongoDB running locally (
mongodb://localhost:27017)
cd BattleForces/backend
npm install
node server.jsBackend runs at http://localhost:5000
cd BattleForces/frontend
npm install
npm run devFrontend runs at http://localhost:5173
| Method | Route | Description |
|---|---|---|
POST |
/battle/create |
Create a new battle room |
POST |
/battle/join |
Join a room by roomId |
POST |
/battle/start |
Host starts the battle |
POST |
/battle/validate |
Validate a CF submission |
GET |
/battle/:roomId |
Get battle room state |
GET |
/profile/compare?handle1=&handle2= |
Compare two CF profiles |
POST /battle/create
{
"handle": "tourist",
"minRating": 1000,
"maxRating": 1600,
"problemCount": 3,
"duration": 60
}- Host goes to the homepage, fills out settings, and clicks Create Battle Room
- Host shares the join link with the opponent
- Opponent joins using the link or Room ID and enters their CF handle
- Host clicks Start Battle → problems are fetched from Codeforces API
- Both players solve problems on Codeforces.com
- Click Validate after submitting a solution — backend checks your CF submissions
- Timer counts down. Most problems solved wins (tiebreak: total time)
PORT=5000
MONGO_URI=mongodb://localhost:27017/battleforces- Polling interval: 5 seconds (no WebSockets needed)
- Validation checks submissions from Codeforces API: verdict=OK + problem match + submission after battle start
- Profile comparison uses live Codeforces API data with rating history chart