# astroelaa/codementor-ai architecture

> Architecture diagram of the GitHub repository astroelaa/codementor-ai, 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/astroelaa/codementor-ai
- Repository: https://github.com/astroelaa/codementor-ai

## Overview

CodeMentor AI is a Socratic debugging mentor: a student submits buggy Python or JavaScript, receives guiding questions, spends a limited hint budget, and can explain the fix to complete a session. The React workspace uses a typed API client to reach FastAPI; the mentor routes coordinate LLM feedback and persisted session progress. Separate paths support accounts, sample snippets, and the landing and legal pages. The README documents database and provider behavior; unsampled modules are included where their role is clear, but their internal calls are not inferred.

Main entry points: [`backend/app/routers/mentor.py`](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/routers/mentor.py) (Mentor routes), [`backend/app/llm/manager.py`](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/manager.py) (Provider manager), [`frontend/src/main.tsx`](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/main.tsx) (React app), [`backend/app/main.py`](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["React app<br/>[main.tsx]"]
  node_workspace["Mentor workspace<br/>[Workspace.tsx]"]
  node_authui["Auth screens<br/>[Login.tsx]"]
  node_authstate["Auth state<br/>[auth.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
  node_landing["Landing page<br/>[Landing.tsx]"]
end

subgraph group_api["API and accounts"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_authroutes["Auth routes<br/>[auth.py]"]
end

subgraph group_mentor["Mentor workflow"]
  node_mentoroutes["Mentor routes<br/>[mentor.py]"]
  node_snippets["Sample snippets<br/>[snippets.py]"]
  node_detection["Language detection<br/>[detect.py]"]
  node_mentorlogic["Mentor feedback<br/>[mentor.py]"]
  node_prompts["Socratic prompts<br/>[mentor_prompts.py]"]
end

subgraph group_llm["Language models"]
  node_llmmanager["Provider manager<br/>[manager.py]"]
  node_groq["Groq provider<br/>[groq_sdk.py]"]
  node_gemini["Gemini provider<br/>[gemini.py]"]
  node_openai["OpenAI provider<br/>[openai_provider.py]"]
  node_anthropic["Anthropic provider<br/>[anthropic.py]"]
end

subgraph group_state["Persistence and progress"]
  node_progress["Progress and badges<br/>[progress.py]"]
  node_database[("SQL database<br/>[database.py]")]
  node_models["Session and user models<br/>[models.py]"]
end

node_student(("Student"))
node_provider_services{{"LLM services"}}

node_student -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_workspace
node_webapp -->|"routes to"| node_authui
node_student -->|"visits"| node_landing
node_workspace -->|"requests"| node_apiclient
node_authui -->|"uses"| node_authstate
node_authstate -->|"calls"| node_apiclient
node_apiclient -->|"sends API requests"| node_fastapi
node_fastapi -->|"registers"| node_authroutes
node_fastapi -->|"registers"| node_mentoroutes
node_mentoroutes -->|"serves samples"| node_snippets
node_mentoroutes -->|"uses"| node_detection
node_mentoroutes -->|"uses"| node_mentorlogic
node_mentoroutes -->|"builds prompts"| node_prompts
node_mentoroutes -->|"updates progress"| node_progress
node_mentoroutes -->|"requests completions"| node_llmmanager
node_llmmanager -->|"dispatches"| node_groq
node_llmmanager -->|"dispatches"| node_gemini
node_llmmanager -->|"dispatches"| node_openai
node_llmmanager -->|"dispatches"| node_anthropic
node_groq -.->|"calls provider"| node_provider_services
node_gemini -.->|"calls provider"| node_provider_services
node_openai -.->|"calls provider"| node_provider_services
node_anthropic -.->|"calls provider"| node_provider_services
node_authroutes -.->|"reads and writes"| node_database
node_mentoroutes -.->|"reads and writes"| node_database
node_models -->|"maps records"| node_database

click node_webapp "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/main.tsx"
click node_workspace "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Workspace.tsx"
click node_authui "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Login.tsx"
click node_authstate "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/lib/auth.tsx"
click node_apiclient "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/lib/api.ts"
click node_landing "https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Landing.tsx"
click node_fastapi "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/routers/auth.py"
click node_mentoroutes "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/routers/mentor.py"
click node_snippets "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/snippets.py"
click node_detection "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/detect.py"
click node_mentorlogic "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/mentor.py"
click node_prompts "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/mentor_prompts.py"
click node_progress "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/progress.py"
click node_llmmanager "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/manager.py"
click node_groq "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/groq_sdk.py"
click node_gemini "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/gemini.py"
click node_openai "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/openai_provider.py"
click node_anthropic "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/anthropic.py"
click node_database "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/database.py"
click node_models "https://github.com/astroelaa/codementor-ai/blob/main/backend/app/models.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_webapp,node_workspace,node_authui,node_authstate,node_apiclient,node_landing toneBlue
class node_fastapi,node_authroutes toneAmber
class node_mentoroutes,node_snippets,node_detection,node_mentorlogic,node_prompts toneMint
class node_llmmanager,node_groq,node_gemini,node_openai,node_anthropic toneRose
class node_progress,node_database,node_models,node_student,node_provider_services toneIndigo
```

## Components

### Web experience

- [React app](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Mentor workspace](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Workspace.tsx): `frontend/src/pages/Workspace.tsx`
- [Auth screens](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Login.tsx): `frontend/src/pages/Login.tsx`
- [Auth state](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/lib/auth.tsx): `frontend/src/lib/auth.tsx`
- [API client](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Landing page](https://github.com/astroelaa/codementor-ai/blob/main/frontend/src/pages/Landing.tsx): `frontend/src/pages/Landing.tsx`

### API and accounts

- [FastAPI app](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Auth routes](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`

### Mentor workflow

- [Mentor routes](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/routers/mentor.py): `backend/app/routers/mentor.py`
- [Sample snippets](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/snippets.py): `backend/app/services/snippets.py`
- [Language detection](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/detect.py): `backend/app/services/detect.py`
- [Mentor feedback](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/mentor.py): `backend/app/services/mentor.py`
- [Socratic prompts](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/mentor_prompts.py): `backend/app/mentor_prompts.py`

### Language models

- [Provider manager](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/manager.py): `backend/app/llm/manager.py`
- [Groq provider](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/groq_sdk.py): `backend/app/llm/groq_sdk.py`
- [Gemini provider](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/gemini.py): `backend/app/llm/gemini.py`
- [OpenAI provider](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/openai_provider.py): `backend/app/llm/openai_provider.py`
- [Anthropic provider](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/llm/anthropic.py): `backend/app/llm/anthropic.py`

### Persistence and progress

- [Progress and badges](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/services/progress.py): `backend/app/services/progress.py`
- [SQL database](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/database.py): `backend/app/database.py`
- [Session and user models](https://github.com/astroelaa/codementor-ai/blob/main/backend/app/models.py): `backend/app/models.py`

### Other components

- **Student**
- **LLM services**

## Connections

- Student → React app: uses (evidence: `README.md`)
- React app → Mentor workspace: routes to (evidence: `frontend/src/main.tsx`)
- React app → Auth screens: routes to (evidence: `frontend/src/main.tsx`)
- Student → Landing page: visits
- Mentor workspace → API client: requests (evidence: `frontend/src/pages/Workspace.tsx`)
- Auth screens → Auth state: uses (evidence: `frontend/src/pages/Login.tsx`)
- Auth state → API client: calls (evidence: `frontend/src/lib/auth.tsx`)
- API client → FastAPI app: sends API requests (evidence: `README.md`)
- FastAPI app → Auth routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Mentor routes: registers (evidence: `backend/app/main.py`)
- Mentor routes → Sample snippets: serves samples
- Mentor routes → Language detection: uses (evidence: `backend/app/routers/mentor.py`)
- Mentor routes → Mentor feedback: uses (evidence: `backend/app/routers/mentor.py`)
- Mentor routes → Socratic prompts: builds prompts (evidence: `backend/app/routers/mentor.py`)
- Mentor routes → Progress and badges: updates progress (evidence: `backend/app/routers/mentor.py`)
- Mentor routes → Provider manager: requests completions (evidence: `backend/app/routers/mentor.py`)
- Provider manager → Groq provider: dispatches (evidence: `backend/app/llm/manager.py`)
- Provider manager → Gemini provider: dispatches (evidence: `backend/app/llm/manager.py`)
- Provider manager → OpenAI provider: dispatches (evidence: `backend/app/llm/manager.py`)
- Provider manager → Anthropic provider: dispatches (evidence: `backend/app/llm/manager.py`)
- Groq provider → LLM services: calls provider (evidence: `README.md`)
- Gemini provider → LLM services: calls provider (evidence: `README.md`)
- OpenAI provider → LLM services: calls provider (evidence: `README.md`)
- Anthropic provider → LLM services: calls provider (evidence: `README.md`)
- Auth routes → SQL database: reads and writes
- Mentor routes → SQL database: reads and writes
- Session and user models → SQL database: maps records (evidence: `backend/app/models.py`)
