CodeArena is a full-stack coding platform for:
- solving curated DSA problems,
- validating code execution with Judge0,
- tracking solved problems, points, tiers, and rankings,
- and doing real-time collaborative coding in rooms.
- User signs up or logs in.
- User opens Problems table and picks a problem.
- User writes code in the workspace editor.
- User runs code (Judge0 execution).
- User submits solution (validated against test cases).
- If all test cases pass, backend marks problem solved and awards points.
- Profile and Rankings update based on points and tier.
- User creates/joins room from Home.
- Socket connection joins room.
- Code edits broadcast to other connected clients.
- Participants see synced code in real time.
flowchart TD
A[User Opens CodeArena] --> B{Authenticated?}
B -- No --> C[Login or Signup]
C --> D[Receive JWT Token]
D --> E[Open Problems Table]
B -- Yes --> E
E --> F[Select Problem]
F --> G[Open Workspace]
G --> H[Write Code]
H --> I[Execute via Judge0]
I --> J{All Test Cases Pass?}
J -- No --> K[Show Wrong Answer with Case Details]
K --> H
J -- Yes --> L[Submit to Backend]
L --> M[Mark Problem Solved]
M --> N[Update Points and Tier]
N --> O[Reflect in Profile and Rankings]
flowchart LR
A[Signup Request] --> B[POST /auth/signup]
B --> C[Hash Password and Store User]
C --> D[JWT Returned]
D --> E[Token Stored in localStorage]
E --> F[Protected Route Access]
F --> G{Token Valid?}
G -- Yes --> H[Allow Route]
G -- No --> I[Redirect to Login]
flowchart TD
A[User Clicks Submit] --> B[Load problem testCases]
B --> C{TestCases available?}
C -- No --> D[Fallback to execution result]
C -- Yes --> E[Run each test case via Judge0]
E --> F[Compare stdout with expected output]
F --> G{Mismatch or Runtime Error?}
G -- Yes --> H[Return per-case diagnostics]
H --> I[Display Input, Expected, Actual, Error]
G -- No --> J[All cases pass]
J --> K[PATCH /api/problems/:problemId/solve]
K --> L{Already solved?}
L -- Yes --> M[Show solved info]
L -- No --> N[Award points and update tier]
sequenceDiagram
participant U1 as User 1
participant FE1 as Frontend 1
participant WS as Socket Server
participant FE2 as Frontend 2
participant U2 as User 2
U1->>FE1: Join room
FE1->>WS: ACTIONS.JOIN(roomId, username)
U2->>FE2: Join same room
FE2->>WS: ACTIONS.JOIN(roomId, username)
WS-->>FE1: ACTIONS.JOINED(clients)
WS-->>FE2: ACTIONS.JOINED(clients)
U1->>FE1: Type code
FE1->>WS: ACTIONS.CODE_CHANGE(code)
WS-->>FE2: ACTIONS.CODE_CHANGE(code)
U2->>FE2: Leave room
FE2->>WS: disconnect
WS-->>FE1: ACTIONS.DISCONNECTED(user)
- React + React Router
- Tailwind/CSS utility styling
- Code editors:
- Monaco (problem workspace)
- CodeMirror (collab room editor)
- API via Axios client with centralized base URL
- Socket client via socket.io-client
- Express API + Socket.IO server
- MongoDB via Mongoose
- JWT auth for protected routes
- Problem seed/update on server start
- Judge0 CE via RapidAPI
- Frontend submits source code + stdin
- Polls result token until completion
POST /auth/signupstores user (hashed password).POST /auth/loginverifies credentials and returns JWT.- Frontend stores token in localStorage.
- Protected API calls attach
Authorization: Bearer <token>.
GET /api/problemsreturns list with solved status per user.GET /api/problems/:idreturns full detail including examples, constraints, and testCases.
- User clicks Submit.
- Frontend validates code exists and API key exists.
- Frontend runs all test cases through Judge0.
- Frontend compares normalized stdout with expected output per case.
- If all pass -> call
PATCH /api/problems/:problemId/solve. - Backend prevents double-solve and awards points/tier update.
backend/: API + socket server + DB modelsfrontend/: React app, pages, components, services
Key areas:
backend/src/server.js: main API/socket bootstrap and routesbackend/models/:User,Problemfrontend/src/components/Workspace/: problem solve workspacefrontend/src/pages/EditorPage.jsx: realtime room editorfrontend/src/services/httpClient.jsx: base API client
REACT_APP_API_BASE_URL=http://localhost:5000REACT_APP_API_URL=http://localhost:5000/apiREACT_APP_SOCKET_URL=http://localhost:5000REACT_APP_JUDGE0_API_KEY=<your_rapidapi_key>
MONGO_URL=<your_mongodb_connection_string>JWT_SECRET=<your_jwt_secret>CORS_ORIGINS=http://localhost:3000,https://your-frontend-domainPORT=5000
- Node.js 18+
- npm
- MongoDB (Atlas or local)
- Backend dependencies
cd backendnpm install
- Frontend dependencies
cd ../frontendnpm install
- Start backend
cd backendnpm run dev
- Start frontend
cd frontendnpm start
- Open app at
http://localhost:3000
Before merge/deploy:
frontendbuild passes (npm run build).- Backend boots without crash and connects DB.
- Auth routes work: signup/login/protected calls.
- Problem list and problem detail APIs return expected fields.
- Submit flow validates testcases and updates points only once.
- Socket room join/sync/disconnect behavior works.
- Complete API response normalization.
- Add consistent error contracts from backend.
- Add loading/error/empty states across pages.
- Admin panel to create/edit problems + test cases.
- Version test cases and freeze accepted snapshots.
- Add hidden/public test case separation.
- Move execution orchestration to backend for secure keys.
- Add language-specific starter code and templates.
- Add per-test performance metrics and verdict table.
- Persist room sessions.
- Presence indicators and reconnect handling.
- Theme preference persistence per user.
- Add backend route tests and frontend component tests.
- Add CI for lint/build/test checks.
- Containerize backend/frontend for one-command deployment.
- Judge0 key is currently consumed from frontend env; production-grade setup should proxy Judge0 through backend.
- Problem seed data is in server bootstrap; long term this should move to migration scripts/admin CMS.
- Some pages still rely on basic toasts for UX messaging and can be refined further.
- Add backend
POST /api/submissions/validateso frontend never touches Judge0 key. - Add problem authoring UI for test case management.
- Add submission history table per user/problem.
- Add robust role-based access (admin/problem-setter/user).
If you want, I can also generate:
- a dedicated
backend/README.md(API-focused), and - a dedicated
frontend/README.md(UI/component-focused) with diagrams and endpoint tables.