Two developers. One problem. Real-time. May the best code win.
CodeDuel is a real-time competitive coding platform where two developers enter a shared room, receive the same problem simultaneously, write their solutions in a live code editor, and compete on correctness and speed. Think LeetCode — but head-to-head, live, with a friend or a stranger.
- Room system — create a room, share a link, opponent joins instantly
- Real-time sync — both players see the problem at the same time via WebSockets
- Live code editor — syntax-highlighted, language-aware editor in the browser
- Test case evaluation — submit code, get results against hidden test cases
- Winner determination — based on test cases passed + time taken
- Problem library — curated set of problems across Easy / Medium / Hard
- Leaderboard — global rankings by wins, problems solved, fastest times
- Match history — review past duels, see opponent's solution after match ends
- User auth — register, login, profile with stats
┌────────────────────────────────────────────────────────────────┐
│ CodeDuel │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ React/HTML │ │ FastAPI │ │ Code Runner │ │
│ │ Frontend │◄───►│ Backend │────►│ (Sandbox) │ │
│ │ + Editor │ │ REST + WS │ │ │ │
│ └─────────────┘ └──────┬───────┘ └────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ PostgreSQL │ │
│ │ users|rooms| │ │
│ │ problems|results│ │
│ └─────────────────┘ │
└────────────────────────────────────────────────────────────────┘
| Layer | Technology |
|---|---|
| Backend | FastAPI (Python) |
| Real-time | WebSockets |
| Database | PostgreSQL + SQLAlchemy |
| Auth | JWT |
| Frontend | HTML / CSS / JavaScript (CodeMirror editor) |
| Code Execution | Subprocess sandbox (Python problems) |
| Containerization | Docker + Docker Compose |
| Deployment | Render / Railway |
| CI/CD | GitHub Actions |
1. Player A creates a room → gets a shareable room code
2. Player B joins with the room code
3. Both players see the problem at the same time (WebSocket broadcast)
4. Players write their solution in the live editor
5. Either player submits → code runs against test cases
6. Results shown: test cases passed / failed + time taken
7. Winner declared when both submit or timer runs out
8. Match archived — both can review each other's solution
POST /auth/register
POST /auth/login
GET /problems List all problems (with difficulty filter)
GET /problems/{id} Get problem details
POST /rooms Create a new duel room
GET /rooms/{code} Get room state
POST /rooms/{code}/submit Submit solution for evaluation
GET /leaderboard Global rankings
GET /users/{id}/history Match history for a user
WS /ws/rooms/{code} WebSocket connection for real-time room sync
users (id, username, email, password_hash, wins, losses, created_at)
problems (id, title, description, difficulty, test_cases_json, created_at)
rooms (id, code, problem_id, player1_id, player2_id, status, created_at)
results (id, room_id, user_id, code, test_cases_passed, time_taken_ms, submitted_at)git clone https://github.com/LakshmiPrakash-codes/codeduel
cd codeduel
docker-compose up --build
# App at http://localhost:3000
# API at http://localhost:8000
# Docs at http://localhost:8000/docsI wanted to build something that's genuinely fun to use, technically challenging, and demonstrates real engineering — not just CRUD. CodeDuel forced me to learn WebSockets for real-time bidirectional communication, design a room state machine, sandbox code execution safely, and think about the full product experience end to end. This is the project I'm most proud of.
- Room system + WebSocket sync
- Problem library + test case runner
- Leaderboard + match history
- Spectator mode — watch live duels
- Tournament brackets (4/8 players)
- Multiple language support (JavaScript, C++)
- ELO-based matchmaking
📋 Planned — development starts after DevLog CLI and OpenStatus are complete.
Lakshmi Prakash Nagati LinkedIn · GitHub · nlp.jobmail@gmail.com