# saumyajha7/leetlab architecture

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

- Interactive diagram: https://gitdiagram.com/saumyajha7/leetlab
- Repository: https://github.com/saumyajha7/leetlab

## Overview

LeetLab is an Expo/React Native coding-practice app. The main path is authenticated browsing, problem detail, code editing and server-judged submission, ending in per-case verdicts; home and profile support that workflow. Supabase supplies sessions, profiles and problem data, while the server endpoint protects hidden test cases and calls the external judge. Edges are limited to README statements and shown imports/calls; several route implementations were not sampled, so their internal wiring is not inferred.

Main entry points: [`src/lib/supabase.ts`](https://github.com/saumyajha7/leetlab/blob/main/src/lib/supabase.ts) (Supabase client), [`src/app/api/submit+api.ts`](https://github.com/saumyajha7/leetlab/blob/main/src/app/api/submit%2Bapi.ts) (Submission API), [`src/app/(tabs)/index.tsx`](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/index.tsx) (Home dashboard), [`src/app/(tabs)/[problemId]/index.tsx`](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/index.tsx) (Problem detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Identity &amp; session"]
  node_auth_routes["Login and signup"]
  node_auth_ui["Auth screens"]
  node_google_auth["Google sign-in<br/>[useGoogleAuth.ts]"]
  node_session["Session state<br/>[useSessionStore.ts]"]
  node_profile_store["Profile state<br/>[useProfileStore.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_supabase[("Supabase Auth and Postgres")]
end

subgraph group_practice["Problem discovery"]
  node_home["Home dashboard<br/>[index.tsx]"]
  node_home_components["Home cards"]
  node_problem_list["Problem library<br/>[problems.tsx]"]
  node_problem_detail["Problem detail<br/>[index.tsx]"]
  node_problem_hook["Problem detail query<br/>[useProblem.ts]"]
  node_problem_store["Problem summaries"]
  node_problem_ui["Problem components"]
end

subgraph group_submission["Code submission"]
  node_editor["Code editor<br/>[codeEditor.tsx]"]
  node_editor_ui["Editor components"]
  node_submit_api["Submission API<br/>[submit+api.ts]"]
  node_judge["Judge execution<br/>[judge.ts]"]
  node_judge_service["CodeBox / Judge0"]
  node_result["Verdict screen<br/>[result.tsx]"]
  node_result_ui["Verdict components"]
end

subgraph group_support["App support"]
  node_profile_screen["Profile screen<br/>[profile.tsx]"]
  node_profile_ui["Profile components"]
  node_root["App entry and routing<br/>[_layout.tsx]"]
end

node_learner(("Learner"))

node_learner -->|"starts with"| node_auth_routes
node_auth_routes -.->|"renders"| node_auth_ui
node_auth_ui -.->|"invokes"| node_google_auth
node_google_auth -->|"signs in via"| node_supabase_client
node_supabase_client -->|"auth and queries"| node_supabase
node_root -->|"initializes"| node_session
node_session -->|"subscribes to auth"| node_supabase_client
node_session -->|"fetches or clears"| node_profile_store
node_home -->|"renders"| node_home_components
node_home -->|"reads and refreshes"| node_problem_store
node_home -->|"reads and refreshes"| node_profile_store
node_problem_store -->|"queries summaries"| node_supabase_client
node_problem_list -->|"uses"| node_problem_store
node_problem_list -->|"renders"| node_problem_ui
node_problem_detail -->|"loads problem"| node_problem_hook
node_problem_detail -->|"renders"| node_problem_ui
node_problem_hook -->|"queries detail"| node_supabase_client
node_problem_detail -->|"opens editor"| node_editor
node_editor -.->|"renders"| node_editor_ui
node_editor -->|"posts code"| node_submit_api
node_submit_api -->|"authenticates and fetches tests"| node_supabase
node_submit_api -->|"runs test cases"| node_judge
node_judge -->|"executes submissions"| node_judge_service
node_submit_api -->|"returns verdict data"| node_result
node_result -.->|"renders"| node_result_ui
node_profile_screen -->|"renders"| node_profile_ui
node_profile_screen -->|"uses profile"| node_profile_store
node_profile_ui -->|"signs out"| node_supabase_client

click node_auth_routes "https://github.com/saumyajha7/leetlab/tree/main/src/app/(auth)"
click node_auth_ui "https://github.com/saumyajha7/leetlab/tree/main/src/components/auth"
click node_google_auth "https://github.com/saumyajha7/leetlab/blob/main/src/hooks/useGoogleAuth.ts"
click node_session "https://github.com/saumyajha7/leetlab/blob/main/src/stores/useSessionStore.ts"
click node_profile_store "https://github.com/saumyajha7/leetlab/blob/main/src/stores/useProfileStore.ts"
click node_supabase_client "https://github.com/saumyajha7/leetlab/blob/main/src/lib/supabase.ts"
click node_home "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/index.tsx"
click node_home_components "https://github.com/saumyajha7/leetlab/tree/main/src/components/home"
click node_problem_list "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/problems.tsx"
click node_problem_detail "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/index.tsx"
click node_problem_hook "https://github.com/saumyajha7/leetlab/blob/main/src/hooks/useProblem.ts"
click node_problem_store "https://github.com/saumyajha7/leetlab/blob/main/src/stores/useProblemsStore.ts"
click node_problem_ui "https://github.com/saumyajha7/leetlab/tree/main/src/components/problems"
click node_editor "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/codeEditor.tsx"
click node_editor_ui "https://github.com/saumyajha7/leetlab/tree/main/src/components/editor"
click node_submit_api "https://github.com/saumyajha7/leetlab/blob/main/src/app/api/submit%2Bapi.ts"
click node_judge "https://github.com/saumyajha7/leetlab/blob/main/src/lib/judge.ts"
click node_result "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/result.tsx"
click node_result_ui "https://github.com/saumyajha7/leetlab/tree/main/src/components/result"
click node_profile_screen "https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/profile.tsx"
click node_profile_ui "https://github.com/saumyajha7/leetlab/tree/main/src/components/profile"
click node_root "https://github.com/saumyajha7/leetlab/blob/main/src/app/_layout.tsx"

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_routes,node_auth_ui,node_google_auth,node_session,node_profile_store,node_supabase_client,node_supabase toneBlue
class node_home,node_home_components,node_problem_list,node_problem_detail,node_problem_hook,node_problem_store,node_problem_ui toneAmber
class node_editor,node_editor_ui,node_submit_api,node_judge,node_judge_service,node_result,node_result_ui toneMint
class node_profile_screen,node_profile_ui,node_root toneRose
class node_learner toneIndigo
```

## Components

### Identity & session

- [Login and signup](https://github.com/saumyajha7/leetlab/tree/main/src/app/(auth)): `src/app/(auth)`
- [Auth screens](https://github.com/saumyajha7/leetlab/tree/main/src/components/auth): `src/components/auth`
- [Google sign-in](https://github.com/saumyajha7/leetlab/blob/main/src/hooks/useGoogleAuth.ts): `src/hooks/useGoogleAuth.ts`
- [Session state](https://github.com/saumyajha7/leetlab/blob/main/src/stores/useSessionStore.ts): `src/stores/useSessionStore.ts`
- [Profile state](https://github.com/saumyajha7/leetlab/blob/main/src/stores/useProfileStore.ts): `src/stores/useProfileStore.ts`
- [Supabase client](https://github.com/saumyajha7/leetlab/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Supabase Auth and Postgres**

### Problem discovery

- [Home dashboard](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Home cards](https://github.com/saumyajha7/leetlab/tree/main/src/components/home): `src/components/home`
- [Problem library](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/problems.tsx): `src/app/(tabs)/problems.tsx`
- [Problem detail](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/index.tsx): `src/app/(tabs)/[problemId]/index.tsx`
- [Problem detail query](https://github.com/saumyajha7/leetlab/blob/main/src/hooks/useProblem.ts): `src/hooks/useProblem.ts`
- [Problem summaries](https://github.com/saumyajha7/leetlab/blob/main/src/stores/useProblemsStore.ts): `src/stores/useProblemsStore.ts`
- [Problem components](https://github.com/saumyajha7/leetlab/tree/main/src/components/problems): `src/components/problems`

### Code submission

- [Code editor](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/codeEditor.tsx): `src/app/(tabs)/[problemId]/codeEditor.tsx`
- [Editor components](https://github.com/saumyajha7/leetlab/tree/main/src/components/editor): `src/components/editor`
- [Submission API](https://github.com/saumyajha7/leetlab/blob/main/src/app/api/submit%2Bapi.ts): `src/app/api/submit+api.ts`
- [Judge execution](https://github.com/saumyajha7/leetlab/blob/main/src/lib/judge.ts): `src/lib/judge.ts`
- **CodeBox / Judge0**
- [Verdict screen](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/%5BproblemId%5D/result.tsx): `src/app/(tabs)/[problemId]/result.tsx`
- [Verdict components](https://github.com/saumyajha7/leetlab/tree/main/src/components/result): `src/components/result`

### App support

- [Profile screen](https://github.com/saumyajha7/leetlab/blob/main/src/app/(tabs)/profile.tsx): `src/app/(tabs)/profile.tsx`
- [Profile components](https://github.com/saumyajha7/leetlab/tree/main/src/components/profile): `src/components/profile`
- [App entry and routing](https://github.com/saumyajha7/leetlab/blob/main/src/app/_layout.tsx): `src/app/_layout.tsx`

### Other components

- **Learner**

## Connections

- Learner → Login and signup: starts with
- Login and signup → Auth screens: renders (evidence: `src/app/(auth)/signup.tsx`)
- Auth screens → Google sign-in: invokes
- Google sign-in → Supabase client: signs in via (evidence: `src/hooks/useGoogleAuth.ts`)
- Supabase client → Supabase Auth and Postgres: auth and queries
- App entry and routing → Session state: initializes (evidence: `src/stores/useSessionStore.ts`)
- Session state → Supabase client: subscribes to auth (evidence: `src/stores/useSessionStore.ts`)
- Session state → Profile state: fetches or clears (evidence: `src/stores/useSessionStore.ts`)
- Home dashboard → Home cards: renders (evidence: `src/app/(tabs)/index.tsx`)
- Home dashboard → Problem summaries: reads and refreshes (evidence: `src/app/(tabs)/index.tsx`)
- Home dashboard → Profile state: reads and refreshes (evidence: `src/app/(tabs)/index.tsx`)
- Problem summaries → Supabase client: queries summaries (evidence: `src/stores/useProblemsStore.ts`)
- Problem library → Problem summaries: uses (evidence: `src/app/(tabs)/problems.tsx`)
- Problem library → Problem components: renders (evidence: `src/app/(tabs)/problems.tsx`)
- Problem detail → Problem detail query: loads problem (evidence: `src/app/(tabs)/[problemId]/index.tsx`)
- Problem detail → Problem components: renders (evidence: `src/app/(tabs)/[problemId]/index.tsx`)
- Problem detail query → Supabase client: queries detail (evidence: `src/hooks/useProblem.ts`)
- Problem detail → Code editor: opens editor
- Code editor → Editor components: renders
- Code editor → Submission API: posts code
- Submission API → Supabase Auth and Postgres: authenticates and fetches tests
- Submission API → Judge execution: runs test cases (evidence: `src/app/api/submit+api.ts`)
- Judge execution → CodeBox / Judge0: executes submissions (evidence: `src/lib/judge.ts`)
- Submission API → Verdict screen: returns verdict data
- Verdict screen → Verdict components: renders
- Profile screen → Profile components: renders
- Profile screen → Profile state: uses profile
- Profile components → Supabase client: signs out (evidence: `src/components/profile/SignOutButton.tsx`)
