# barmanji/leetcode-clone architecture

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

- Interactive diagram: https://gitdiagram.com/barmanji/leetcode-clone
- Repository: https://github.com/barmanji/leetcode-clone

## Overview

CodeLeet is a browser-based coding practice platform. Users browse problems, open a workspace, edit code, run it against test cases or submit it, then review execution results and submission history; accepted submissions update solved status. Separate capabilities support Clerk authentication and onboarding, admin problem creation, playlists, and user profiles. The graph distinguishes workspace UI, server actions, persistence, and Judge0 execution. Some subsystem links use README descriptions because their implementation files were not sampled; uncertain details are omitted.

Main entry points: [`modules/problems/actions/index.ts`](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/actions/index.ts) (Problem actions), [`app/problem/[id]/page.tsx`](https://github.com/barmanji/leetcode-clone/blob/main/app/problem/%5Bid%5D/page.tsx) (Problem workspace), [`modules/auth/actions/index.ts`](https://github.com/barmanji/leetcode-clone/blob/main/modules/auth/actions/index.ts) (User onboarding), [`lib/db.ts`](https://github.com/barmanji/leetcode-clone/blob/main/lib/db.ts) (PostgreSQL data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and navigation"]
  node_auth_ui["Sign-in UI<br/>[page.tsx]"]
  node_onboarding["User onboarding<br/>[index.ts]"]
  node_navbar["Navigation<br/>[navbar.tsx]"]
end

subgraph group_problems["Problem experience"]
  node_problem_list["Problem catalog<br/>[page.tsx]"]
  node_workspace["Problem workspace<br/>[page.tsx]"]
  node_editor["Code editor panel"]
  node_results["Results and history<br/>[result-panel.tsx]"]
  node_editor_hook["Editor workflow<br/>[use-editor.ts]"]
  node_submission_history["Submission history"]
  node_admin_form["Problem authoring<br/>[index.tsx]"]
end

subgraph group_execution["Execution and persistence"]
  node_problem_actions["Problem actions<br/>[index.ts]"]
  node_judge0["Judge0 service<br/>[judge0.ts]"]
  node_database[("PostgreSQL data<br/>[db.ts]")]
  node_admin_api["Problem creation API<br/>[route.ts]"]
end

subgraph group_collections["Profiles and playlists"]
  node_playlist_api["Playlist APIs"]
  node_playlist_ui["Playlist management<br/>[playlist-list.tsx]"]
  node_profile["User profile<br/>[page.tsx]"]
end

subgraph group_shared["Shared domain"]
  node_sample_problems["Sample problem data<br/>[sample-problem.ts]"]
  node_problem_types["Problem domain types<br/>[problem.ts]"]
  node_action_types["Action and result types<br/>[actions.ts]"]
end

node_browser(("Browser user"))

node_browser -->|"authenticates"| node_auth_ui
node_auth_ui -.->|"returns session"| node_onboarding
node_browser -->|"browses"| node_problem_list
node_problem_list -->|"loads problems"| node_problem_actions
node_browser -->|"opens problem"| node_workspace
node_workspace -->|"renders"| node_editor
node_workspace -->|"renders"| node_results
node_workspace -->|"uses workflow"| node_editor_hook
node_editor_hook -->|"runs or submits"| node_problem_actions
node_problem_actions -->|"executes batches"| node_judge0
node_problem_actions -->|"reads and writes"| node_database
node_problem_actions -->|"gets current user"| node_onboarding
node_problem_actions -->|"returns execution results"| node_results
node_problem_actions -->|"loads submissions"| node_submission_history
node_browser -->|"creates problem"| node_admin_form
node_admin_form -->|"posts problem"| node_admin_api
node_admin_api -->|"validates test cases"| node_judge0
node_admin_api -->|"saves problem"| node_database
node_browser -->|"manages playlists"| node_playlist_ui
node_playlist_ui -.->|"uses playlist APIs"| node_playlist_api
node_playlist_api -->|"reads and writes"| node_database
node_browser -->|"views profile"| node_profile
node_profile -->|"loads user data"| node_onboarding
node_onboarding -->|"upserts and queries"| node_database
node_problem_actions -->|"uses result types"| node_action_types
node_problem_actions -->|"uses domain types"| node_problem_types
node_admin_form -->|"uses defaults"| node_sample_problems

click node_auth_ui "https://github.com/barmanji/leetcode-clone/blob/main/app/(auth)/sign-in/%5B%5B...sign-in%5D%5D/page.tsx"
click node_onboarding "https://github.com/barmanji/leetcode-clone/blob/main/modules/auth/actions/index.ts"
click node_navbar "https://github.com/barmanji/leetcode-clone/blob/main/modules/home/components/navbar.tsx"
click node_problem_list "https://github.com/barmanji/leetcode-clone/blob/main/app/(root)/problems/page.tsx"
click node_workspace "https://github.com/barmanji/leetcode-clone/blob/main/app/problem/%5Bid%5D/page.tsx"
click node_editor "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/code-editor-panel.tsx"
click node_results "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/result-panel.tsx"
click node_editor_hook "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/hooks/use-editor.ts"
click node_problem_actions "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/actions/index.ts"
click node_judge0 "https://github.com/barmanji/leetcode-clone/blob/main/lib/judge0.ts"
click node_database "https://github.com/barmanji/leetcode-clone/blob/main/lib/db.ts"
click node_submission_history "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/submission-history.tsx"
click node_admin_form "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/create-problem-form/index.tsx"
click node_admin_api "https://github.com/barmanji/leetcode-clone/blob/main/app/api/create-problem/route.ts"
click node_playlist_api "https://github.com/barmanji/leetcode-clone/tree/main/app/api/playlist"
click node_playlist_ui "https://github.com/barmanji/leetcode-clone/blob/main/modules/playlists/components/playlist-list.tsx"
click node_profile "https://github.com/barmanji/leetcode-clone/blob/main/app/(root)/profile/page.tsx"
click node_sample_problems "https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/constant/sample-problem.ts"
click node_problem_types "https://github.com/barmanji/leetcode-clone/blob/main/modules/types/problem.ts"
click node_action_types "https://github.com/barmanji/leetcode-clone/blob/main/modules/types/actions.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_auth_ui,node_onboarding,node_navbar,node_browser toneBlue
class node_problem_list,node_workspace,node_editor,node_results,node_editor_hook,node_submission_history,node_admin_form toneAmber
class node_problem_actions,node_judge0,node_database,node_admin_api toneMint
class node_playlist_api,node_playlist_ui,node_profile toneRose
class node_sample_problems,node_problem_types,node_action_types toneIndigo
```

## Components

### Identity and navigation

- [Sign-in UI](https://github.com/barmanji/leetcode-clone/blob/main/app/(auth)/sign-in/%5B%5B...sign-in%5D%5D/page.tsx): `app/(auth)/sign-in/[[...sign-in]]/page.tsx`
- [User onboarding](https://github.com/barmanji/leetcode-clone/blob/main/modules/auth/actions/index.ts): `modules/auth/actions/index.ts`
- [Navigation](https://github.com/barmanji/leetcode-clone/blob/main/modules/home/components/navbar.tsx): `modules/home/components/navbar.tsx`

### Problem experience

- [Problem catalog](https://github.com/barmanji/leetcode-clone/blob/main/app/(root)/problems/page.tsx): `app/(root)/problems/page.tsx`
- [Problem workspace](https://github.com/barmanji/leetcode-clone/blob/main/app/problem/%5Bid%5D/page.tsx): `app/problem/[id]/page.tsx`
- [Code editor panel](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/code-editor-panel.tsx): `modules/problems/components/problem-page-specific-utility/code-editor-panel.tsx`
- [Results and history](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/result-panel.tsx): `modules/problems/components/problem-page-specific-utility/result-panel.tsx`
- [Editor workflow](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/hooks/use-editor.ts): `modules/problems/hooks/use-editor.ts`
- [Submission history](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/problem-page-specific-utility/submission-history.tsx): `modules/problems/components/problem-page-specific-utility/submission-history.tsx`
- [Problem authoring](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/components/create-problem-form/index.tsx): `modules/problems/components/create-problem-form/index.tsx`

### Execution and persistence

- [Problem actions](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/actions/index.ts): `modules/problems/actions/index.ts`
- [Judge0 service](https://github.com/barmanji/leetcode-clone/blob/main/lib/judge0.ts): `lib/judge0.ts`
- [PostgreSQL data](https://github.com/barmanji/leetcode-clone/blob/main/lib/db.ts): `lib/db.ts`
- [Problem creation API](https://github.com/barmanji/leetcode-clone/blob/main/app/api/create-problem/route.ts): `app/api/create-problem/route.ts`

### Profiles and playlists

- [Playlist APIs](https://github.com/barmanji/leetcode-clone/tree/main/app/api/playlist): `app/api/playlist`
- [Playlist management](https://github.com/barmanji/leetcode-clone/blob/main/modules/playlists/components/playlist-list.tsx): `modules/playlists/components/playlist-list.tsx`
- [User profile](https://github.com/barmanji/leetcode-clone/blob/main/app/(root)/profile/page.tsx): `app/(root)/profile/page.tsx`

### Shared domain

- [Sample problem data](https://github.com/barmanji/leetcode-clone/blob/main/modules/problems/constant/sample-problem.ts): `modules/problems/constant/sample-problem.ts`
- [Problem domain types](https://github.com/barmanji/leetcode-clone/blob/main/modules/types/problem.ts): `modules/types/problem.ts`
- [Action and result types](https://github.com/barmanji/leetcode-clone/blob/main/modules/types/actions.ts): `modules/types/actions.ts`

### Other components

- **Browser user**

## Connections

- Browser user → Sign-in UI: authenticates
- Sign-in UI → User onboarding: returns session
- Browser user → Problem catalog: browses
- Problem catalog → Problem actions: loads problems (evidence: `app/(root)/problems/page.tsx`)
- Browser user → Problem workspace: opens problem
- Problem workspace → Code editor panel: renders (evidence: `app/problem/[id]/page.tsx`)
- Problem workspace → Results and history: renders (evidence: `app/problem/[id]/page.tsx`)
- Problem workspace → Editor workflow: uses workflow (evidence: `app/problem/[id]/page.tsx`)
- Editor workflow → Problem actions: runs or submits
- Problem actions → Judge0 service: executes batches (evidence: `modules/problems/actions/index.ts`)
- Problem actions → PostgreSQL data: reads and writes (evidence: `modules/problems/actions/index.ts`)
- Problem actions → User onboarding: gets current user (evidence: `modules/problems/actions/index.ts`)
- Problem actions → Results and history: returns execution results
- Problem actions → Submission history: loads submissions
- Browser user → Problem authoring: creates problem
- Problem authoring → Problem creation API: posts problem
- Problem creation API → Judge0 service: validates test cases (evidence: `app/api/create-problem/route.ts`)
- Problem creation API → PostgreSQL data: saves problem (evidence: `app/api/create-problem/route.ts`)
- Browser user → Playlist management: manages playlists
- Playlist management → Playlist APIs: uses playlist APIs
- Playlist APIs → PostgreSQL data: reads and writes (evidence: `app/api/playlist/get-and-create-playlist/route.ts`)
- Browser user → User profile: views profile
- User profile → User onboarding: loads user data (evidence: `app/(root)/profile/page.tsx`)
- User onboarding → PostgreSQL data: upserts and queries (evidence: `modules/auth/actions/index.ts`)
- Problem actions → Action and result types: uses result types (evidence: `modules/problems/actions/index.ts`)
- Problem actions → Problem domain types: uses domain types (evidence: `modules/problems/actions/index.ts`)
- Problem authoring → Sample problem data: uses defaults
