# nvhbmt/bcn-judge architecture

> Architecture diagram of the GitHub repository nvhbmt/bcn-judge, 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/nvhbmt/bcn-judge
- Repository: https://github.com/nvhbmt/bcn-judge

## Overview

BCN Judge is an internal programming-exercise platform: mentors publish courses and problems, members solve them in a browser, and submissions are judged against testcases; weekly contests and leaderboards extend that core workflow. The graph includes the documented admin, mentor, Discord, and realtime capabilities alongside the main solve-and-judge path. Several server subsystems are represented by their exact source directories because their implementation was not excerpted; relationships for those branches rely on README descriptions rather than sampled calls.

Main entry points: [`src/pages/workspace/WorkspacePage.tsx`](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/workspace/WorkspacePage.tsx) (Problem workspace), [`server/src/routes/member`](https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/member) (Member API), [`server/src/worker.ts`](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/worker.ts) (Judge worker), [`server/src/db/pool.ts`](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/db/pool.ts) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Member application"]
  node_webapp["Role-based app<br/>[App.tsx]"]
  node_workspace["Problem workspace<br/>[WorkspacePage.tsx]"]
  node_editor["Code editor<br/>[CodeEditor.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_submission_stream["Result stream client"]
end

subgraph group_authoring["Course and contest authoring"]
  node_course_authoring["Course authoring"]
  node_problem_authoring["Problem authoring"]
  node_contest_authoring["Contest authoring"]
  node_admin_tools["Administration<br/>[AdminPage.tsx]"]
end

subgraph group_backend["API and identity"]
  node_auth_routes["Account authentication<br/>[routes.ts]"]
  node_discord_auth["Discord authentication<br/>[discordRoutes.ts]"]
  node_member_routes["Member API"]
  node_mentor_routes["Mentor API"]
  node_admin_routes["Admin API"]
  node_database[("PostgreSQL<br/>[pool.ts]")]
end

subgraph group_judge["Automated judging"]
  node_submission_queue["Submission queue<br/>[queue.ts]"]
  node_judge_worker["Judge worker<br/>[worker.ts]"]
  node_sandbox["Sandbox runner<br/>[sandbox.ts]"]
  node_verdict["Verdict evaluation<br/>[verdict.ts]"]
end

subgraph group_insights["Progress and live results"]
  node_contest_board["Contest standings<br/>[standings.ts]"]
  node_live_results["Live submission updates<br/>[sse.ts]"]
end

node_member(("Member"))
node_mentor(("Mentor"))
node_admin(("Admin"))
node_discord{{"Discord"}}

node_member -->|"uses"| node_webapp
node_mentor -->|"authors courses"| node_course_authoring
node_mentor -->|"authors problems"| node_problem_authoring
node_mentor -->|"authors contests"| node_contest_authoring
node_admin -->|"manages platform"| node_admin_tools
node_webapp -->|"routes to"| node_workspace
node_workspace -.->|"edits code"| node_editor
node_workspace -.->|"requests data"| node_api_client
node_course_authoring -->|"loads and saves"| node_api_client
node_member -->|"solves exercises"| node_workspace
node_workspace -->|"submits code"| node_member_routes
node_member_routes -->|"enqueues submission"| node_submission_queue
node_submission_queue -->|"dispatches work"| node_judge_worker
node_judge_worker -.->|"runs program"| node_sandbox
node_judge_worker -.->|"evaluates results"| node_verdict
node_verdict -.->|"publishes verdict"| node_live_results
node_submission_stream -->|"polls submission"| node_member_routes
node_submission_stream -.->|"opens SSE stream"| node_live_results
node_workspace -.->|"tracks submission"| node_submission_stream
node_contest_authoring -.->|"manages contests"| node_mentor_routes
node_member_routes -->|"serves standings"| node_contest_board
node_course_authoring -->|"manages course content"| node_mentor_routes
node_admin_tools -.->|"administers platform"| node_admin_routes
node_webapp -->|"bootstraps account"| node_auth_routes
node_auth_routes -->|"reads and updates users"| node_database
node_discord_auth -->|"authenticates with"| node_discord
node_discord_auth -->|"creates session"| node_auth_routes
node_judge_worker -.->|"stores judgment"| node_database
node_member_routes -.->|"reads platform data"| node_database
node_mentor_routes -.->|"persists authored content"| node_database

click node_webapp "https://github.com/nvhbmt/bcn-judge/blob/main/src/App.tsx"
click node_workspace "https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/workspace/WorkspacePage.tsx"
click node_editor "https://github.com/nvhbmt/bcn-judge/blob/main/src/components/editor/CodeEditor.tsx"
click node_api_client "https://github.com/nvhbmt/bcn-judge/blob/main/src/lib/api.ts"
click node_course_authoring "https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/course/CourseContentPage.tsx"
click node_problem_authoring "https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/problem/ProblemEditorPage.tsx"
click node_contest_authoring "https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/contest/ContestEditorPage.tsx"
click node_admin_tools "https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/AdminPage.tsx"
click node_auth_routes "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/auth/routes.ts"
click node_discord_auth "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/auth/discordRoutes.ts"
click node_member_routes "https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/member"
click node_mentor_routes "https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/mentor"
click node_admin_routes "https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/admin"
click node_database "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/db/pool.ts"
click node_submission_queue "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/queue.ts"
click node_judge_worker "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/worker.ts"
click node_sandbox "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/sandbox.ts"
click node_verdict "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/verdict.ts"
click node_contest_board "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/contest/standings.ts"
click node_live_results "https://github.com/nvhbmt/bcn-judge/blob/main/server/src/realtime/sse.ts"
click node_submission_stream "https://github.com/nvhbmt/bcn-judge/blob/main/src/hooks/useSubmissionStream.ts"

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_webapp,node_workspace,node_editor,node_api_client,node_submission_stream toneBlue
class node_course_authoring,node_problem_authoring,node_contest_authoring,node_admin_tools toneAmber
class node_auth_routes,node_discord_auth,node_member_routes,node_mentor_routes,node_admin_routes,node_database toneMint
class node_submission_queue,node_judge_worker,node_sandbox,node_verdict toneRose
class node_contest_board,node_live_results,node_member,node_mentor,node_admin,node_discord toneIndigo
```

## Components

### Member application

- [Role-based app](https://github.com/nvhbmt/bcn-judge/blob/main/src/App.tsx): `src/App.tsx`
- [Problem workspace](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/workspace/WorkspacePage.tsx): `src/pages/workspace/WorkspacePage.tsx`
- [Code editor](https://github.com/nvhbmt/bcn-judge/blob/main/src/components/editor/CodeEditor.tsx): `src/components/editor/CodeEditor.tsx`
- [API client](https://github.com/nvhbmt/bcn-judge/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Result stream client](https://github.com/nvhbmt/bcn-judge/blob/main/src/hooks/useSubmissionStream.ts): `src/hooks/useSubmissionStream.ts`

### Course and contest authoring

- [Course authoring](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/course/CourseContentPage.tsx): `src/pages/mentor/course/CourseContentPage.tsx`
- [Problem authoring](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/problem/ProblemEditorPage.tsx): `src/pages/mentor/problem/ProblemEditorPage.tsx`
- [Contest authoring](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/mentor/contest/ContestEditorPage.tsx): `src/pages/mentor/contest/ContestEditorPage.tsx`
- [Administration](https://github.com/nvhbmt/bcn-judge/blob/main/src/pages/AdminPage.tsx): `src/pages/AdminPage.tsx`

### API and identity

- [Account authentication](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/auth/routes.ts): `server/src/auth/routes.ts`
- [Discord authentication](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/auth/discordRoutes.ts): `server/src/auth/discordRoutes.ts`
- [Member API](https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/member): `server/src/routes/member`
- [Mentor API](https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/mentor): `server/src/routes/mentor`
- [Admin API](https://github.com/nvhbmt/bcn-judge/tree/main/server/src/routes/admin): `server/src/routes/admin`
- [PostgreSQL](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/db/pool.ts): `server/src/db/pool.ts`

### Automated judging

- [Submission queue](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/queue.ts): `server/src/judge/queue.ts`
- [Judge worker](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/worker.ts): `server/src/worker.ts`
- [Sandbox runner](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/sandbox.ts): `server/src/judge/sandbox.ts`
- [Verdict evaluation](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/judge/verdict.ts): `server/src/judge/verdict.ts`

### Progress and live results

- [Contest standings](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/contest/standings.ts): `server/src/contest/standings.ts`
- [Live submission updates](https://github.com/nvhbmt/bcn-judge/blob/main/server/src/realtime/sse.ts): `server/src/realtime/sse.ts`

### Other components

- **Member**
- **Mentor**
- **Admin**
- **Discord**

## Connections

- Member → Role-based app: uses (evidence: `README.md`)
- Mentor → Course authoring: authors courses (evidence: `README.md`)
- Mentor → Problem authoring: authors problems (evidence: `README.md`)
- Mentor → Contest authoring: authors contests (evidence: `README.md`)
- Admin → Administration: manages platform (evidence: `README.md`)
- Role-based app → Problem workspace: routes to (evidence: `src/App.tsx`)
- Problem workspace → Code editor: edits code
- Problem workspace → API client: requests data
- Course authoring → API client: loads and saves
- Member → Problem workspace: solves exercises (evidence: `README.md`)
- Problem workspace → Member API: submits code (evidence: `README.md`)
- Member API → Submission queue: enqueues submission (evidence: `README.md`)
- Submission queue → Judge worker: dispatches work (evidence: `README.md`)
- Judge worker → Sandbox runner: runs program
- Judge worker → Verdict evaluation: evaluates results
- Verdict evaluation → Live submission updates: publishes verdict
- Result stream client → Member API: polls submission (evidence: `src/hooks/useSubmissionStream.ts`)
- Result stream client → Live submission updates: opens SSE stream
- Problem workspace → Result stream client: tracks submission
- Contest authoring → Mentor API: manages contests
- Member API → Contest standings: serves standings (evidence: `README.md`)
- Course authoring → Mentor API: manages course content
- Administration → Admin API: administers platform
- Role-based app → Account authentication: bootstraps account
- Account authentication → PostgreSQL: reads and updates users (evidence: `server/src/auth/routes.ts`)
- Discord authentication → Discord: authenticates with (evidence: `server/src/auth/discordRoutes.ts`)
- Discord authentication → Account authentication: creates session (evidence: `server/src/auth/discordRoutes.ts`)
- Judge worker → PostgreSQL: stores judgment
- Member API → PostgreSQL: reads platform data
- Mentor API → PostgreSQL: persists authored content
