# krish-mittal1/codearena architecture

> Architecture diagram of the GitHub repository krish-mittal1/codearena, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krish-mittal1/codearena
- Repository: https://github.com/krish-mittal1/codearena

## Overview

CodeArena is a competitive coding platform with individual practice and real-time 1v1 battles. Users authenticate in the frontend, browse problems or enter matchmaking, submit code, and receive judge results; battle outcomes also update ratings and history. The graph includes documented practice, company sets, OTP, AI feedback, statistics, and mock interviews. Some feature modules are unsampled, so their connections are based on README documentation; detailed internal call paths are shown only where the excerpts or source index support them.

Main entry points: [`backend/api/router.py`](https://github.com/krish-mittal1/codearena/blob/main/backend/api/router.py) (HTTP API), [`backend/services/match_service.py`](https://github.com/krish-mittal1/codearena/blob/main/backend/services/match_service.py) (Match lifecycle), [`backend/workers/judge_worker.py`](https://github.com/krish-mittal1/codearena/blob/main/backend/workers/judge_worker.py) (Judge worker), [`backend/services/matchmaking_service.py`](https://github.com/krish-mittal1/codearena/blob/main/backend/services/matchmaking_service.py) (Matchmaking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["Application shell<br/>[App.jsx]"]
  node_authui["Login and registration<br/>[Login.jsx]"]
  node_practiceui["Practice interface<br/>[Practice.jsx]"]
  node_battleui["Battle screen<br/>[Battle.jsx]"]
  node_dashboard["Profile and stats<br/>[Dashboard.jsx]"]
  node_authstate["Auth state<br/>[authStore.js]"]
  node_wsclient["WebSocket client"]
end

subgraph group_identity["Identity and API"]
  node_api["HTTP API<br/>[router.py]"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_otp["OTP login<br/>[otp_auth.py]"]
end

subgraph group_practice["Practice and judging"]
  node_practiceapi["Problem and practice APIs<br/>[practice.py]"]
  node_catalog["Problem catalog<br/>[problem_service.py]"]
  node_submission["Submission handling<br/>[submissions.py]"]
  node_judgeworker["Judge worker<br/>[judge_worker.py]"]
  node_judge["Verdict evaluation<br/>[judge_service.py]"]
  node_sandbox["Code sandbox<br/>[sandbox.py]"]
  node_ai["AI feedback<br/>[ai_service.py]"]
end

subgraph group_battle["Live battles"]
  node_matchmaking["Matchmaking"]
  node_matchservice["Match lifecycle<br/>[match_service.py]"]
  node_wsserver["WebSocket handlers<br/>[handlers.py]"]
  node_manager["Connection manager<br/>[manager.py]"]
end

subgraph group_data["State and integrations"]
  node_analytics["Ratings and statistics<br/>[rating_service.py]"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
  node_llm{{"External LLM"}}
  node_email{{"Email OTP service"}}
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_practiceui
node_app -->|"routes to"| node_battleui
node_user -->|"signs in"| node_authui
node_authui -->|"updates"| node_authstate
node_authstate -->|"requests"| node_api
node_api -->|"routes auth"| node_auth
node_api -->|"routes OTP"| node_otp
node_otp -->|"sends code"| node_email
node_practiceui -->|"requests problems"| node_api
node_api -->|"routes practice"| node_practiceapi
node_practiceapi -.->|"loads problems"| node_catalog
node_catalog -.->|"reads catalog"| node_postgres
node_practiceui -->|"submits code"| node_submission
node_api -->|"routes submissions"| node_submission
node_submission -->|"stores submission"| node_postgres
node_submission -->|"queues submission"| node_judgeworker
node_judgeworker -->|"executes code"| node_sandbox
node_judgeworker -->|"evaluates output"| node_judge
node_judgeworker -->|"saves verdict"| node_postgres
node_practiceui -.->|"requests feedback"| node_ai
node_ai -->|"gets analysis"| node_llm
node_user -->|"joins queue"| node_matchmaking
node_api -->|"routes matchmaking"| node_matchmaking
node_matchmaking -->|"uses queue"| node_redis
node_matchmaking -->|"creates match"| node_matchservice
node_matchservice -->|"persists match"| node_postgres
node_matchservice -->|"tracks active state"| node_redis
node_battleui -->|"connects live"| node_wsclient
node_wsclient -->|"sends events"| node_wsserver
node_wsserver -->|"dispatches events"| node_manager
node_matchmaking -->|"notifies players"| node_manager
node_judgeworker -->|"completes match"| node_matchservice
node_matchservice -->|"updates ratings"| node_analytics
node_matchservice -.->|"broadcasts results"| node_manager
node_dashboard -->|"loads stats"| node_api
node_api -.->|"serves statistics"| node_analytics
node_analytics -.->|"reads match history"| node_postgres

click node_app "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Login.jsx"
click node_practiceui "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Practice.jsx"
click node_battleui "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Battle.jsx"
click node_dashboard "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Dashboard.jsx"
click node_authstate "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/stores/authStore.js"
click node_wsclient "https://github.com/krish-mittal1/codearena/blob/main/frontend/src/ws/WebSocketManager.js"
click node_api "https://github.com/krish-mittal1/codearena/blob/main/backend/api/router.py"
click node_auth "https://github.com/krish-mittal1/codearena/blob/main/backend/services/auth_service.py"
click node_otp "https://github.com/krish-mittal1/codearena/blob/main/backend/api/otp_auth.py"
click node_practiceapi "https://github.com/krish-mittal1/codearena/blob/main/backend/api/practice.py"
click node_catalog "https://github.com/krish-mittal1/codearena/blob/main/backend/services/problem_service.py"
click node_submission "https://github.com/krish-mittal1/codearena/blob/main/backend/api/submissions.py"
click node_judgeworker "https://github.com/krish-mittal1/codearena/blob/main/backend/workers/judge_worker.py"
click node_judge "https://github.com/krish-mittal1/codearena/blob/main/backend/services/judge_service.py"
click node_sandbox "https://github.com/krish-mittal1/codearena/blob/main/backend/execution/sandbox.py"
click node_matchmaking "https://github.com/krish-mittal1/codearena/blob/main/backend/services/matchmaking_service.py"
click node_matchservice "https://github.com/krish-mittal1/codearena/blob/main/backend/services/match_service.py"
click node_wsserver "https://github.com/krish-mittal1/codearena/blob/main/backend/websocket/handlers.py"
click node_manager "https://github.com/krish-mittal1/codearena/blob/main/backend/websocket/manager.py"
click node_ai "https://github.com/krish-mittal1/codearena/blob/main/backend/services/ai_service.py"
click node_analytics "https://github.com/krish-mittal1/codearena/blob/main/backend/services/rating_service.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_authui,node_practiceui,node_battleui,node_dashboard,node_authstate,node_wsclient,node_user toneBlue
class node_api,node_auth,node_otp toneAmber
class node_practiceapi,node_catalog,node_submission,node_judgeworker,node_judge,node_sandbox,node_ai toneMint
class node_matchmaking,node_matchservice,node_wsserver,node_manager toneRose
class node_analytics,node_postgres,node_redis,node_llm,node_email toneIndigo
```

## Components

### Frontend experience

- [Application shell](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and registration](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Practice interface](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Practice.jsx): `frontend/src/pages/Practice.jsx`
- [Battle screen](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Battle.jsx): `frontend/src/pages/Battle.jsx`
- [Profile and stats](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Auth state](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/stores/authStore.js): `frontend/src/stores/authStore.js`
- [WebSocket client](https://github.com/krish-mittal1/codearena/blob/main/frontend/src/ws/WebSocketManager.js): `frontend/src/ws/WebSocketManager.js`

### Identity and API

- [HTTP API](https://github.com/krish-mittal1/codearena/blob/main/backend/api/router.py): `backend/api/router.py`
- [Authentication](https://github.com/krish-mittal1/codearena/blob/main/backend/services/auth_service.py): `backend/services/auth_service.py`
- [OTP login](https://github.com/krish-mittal1/codearena/blob/main/backend/api/otp_auth.py): `backend/api/otp_auth.py`

### Practice and judging

- [Problem and practice APIs](https://github.com/krish-mittal1/codearena/blob/main/backend/api/practice.py): `backend/api/practice.py`
- [Problem catalog](https://github.com/krish-mittal1/codearena/blob/main/backend/services/problem_service.py): `backend/services/problem_service.py`
- [Submission handling](https://github.com/krish-mittal1/codearena/blob/main/backend/api/submissions.py): `backend/api/submissions.py`
- [Judge worker](https://github.com/krish-mittal1/codearena/blob/main/backend/workers/judge_worker.py): `backend/workers/judge_worker.py`
- [Verdict evaluation](https://github.com/krish-mittal1/codearena/blob/main/backend/services/judge_service.py): `backend/services/judge_service.py`
- [Code sandbox](https://github.com/krish-mittal1/codearena/blob/main/backend/execution/sandbox.py): `backend/execution/sandbox.py`
- [AI feedback](https://github.com/krish-mittal1/codearena/blob/main/backend/services/ai_service.py): `backend/services/ai_service.py`

### Live battles

- [Matchmaking](https://github.com/krish-mittal1/codearena/blob/main/backend/services/matchmaking_service.py): `backend/services/matchmaking_service.py`
- [Match lifecycle](https://github.com/krish-mittal1/codearena/blob/main/backend/services/match_service.py): `backend/services/match_service.py`
- [WebSocket handlers](https://github.com/krish-mittal1/codearena/blob/main/backend/websocket/handlers.py): `backend/websocket/handlers.py`
- [Connection manager](https://github.com/krish-mittal1/codearena/blob/main/backend/websocket/manager.py): `backend/websocket/manager.py`

### State and integrations

- [Ratings and statistics](https://github.com/krish-mittal1/codearena/blob/main/backend/services/rating_service.py): `backend/services/rating_service.py`
- **PostgreSQL**
- **Redis**
- **External LLM**
- **Email OTP service**

### Other components

- **User**

## Connections

- User → Application shell: uses
- Application shell → Login and registration: routes to (evidence: `frontend/src/App.jsx`)
- Application shell → Practice interface: routes to (evidence: `frontend/src/App.jsx`)
- Application shell → Battle screen: routes to (evidence: `frontend/src/App.jsx`)
- User → Login and registration: signs in
- Login and registration → Auth state: updates (evidence: `frontend/src/App.jsx`)
- Auth state → HTTP API: requests
- HTTP API → Authentication: routes auth
- HTTP API → OTP login: routes OTP (evidence: `backend/api/router.py`)
- OTP login → Email OTP service: sends code
- Practice interface → HTTP API: requests problems
- HTTP API → Problem and practice APIs: routes practice (evidence: `backend/api/router.py`)
- Problem and practice APIs → Problem catalog: loads problems
- Problem catalog → PostgreSQL: reads catalog
- Practice interface → Submission handling: submits code
- HTTP API → Submission handling: routes submissions (evidence: `backend/api/router.py`)
- Submission handling → PostgreSQL: stores submission
- Submission handling → Judge worker: queues submission
- Judge worker → Code sandbox: executes code (evidence: `backend/workers/judge_worker.py`)
- Judge worker → Verdict evaluation: evaluates output (evidence: `backend/workers/judge_worker.py`)
- Judge worker → PostgreSQL: saves verdict
- Practice interface → AI feedback: requests feedback
- AI feedback → External LLM: gets analysis
- User → Matchmaking: joins queue
- HTTP API → Matchmaking: routes matchmaking (evidence: `backend/api/router.py`)
- Matchmaking → Redis: uses queue
- Matchmaking → Match lifecycle: creates match
- Match lifecycle → PostgreSQL: persists match
- Match lifecycle → Redis: tracks active state
- Battle screen → WebSocket client: connects live
- WebSocket client → WebSocket handlers: sends events
- WebSocket handlers → Connection manager: dispatches events (evidence: `backend/websocket/handlers.py`)
- Matchmaking → Connection manager: notifies players
- Judge worker → Match lifecycle: completes match (evidence: `backend/workers/judge_worker.py`)
- Match lifecycle → Ratings and statistics: updates ratings (evidence: `backend/services/match_service.py`)
- Match lifecycle → Connection manager: broadcasts results
- Profile and stats → HTTP API: loads stats
- HTTP API → Ratings and statistics: serves statistics
- Ratings and statistics → PostgreSQL: reads match history
