# coffee1337/ai-python-mentor architecture

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

## Overview

AI Python Mentor is a full-stack learning platform: learners use the web app to study lessons, complete checks and Python exercises, receive feedback, and build progress toward career goals. The FastAPI modular monolith exposes learning, account, AI, practice, review, career, and project capabilities backed by PostgreSQL. User-code execution runs in a separate isolated Runner service; AI tutoring uses a gateway and lesson knowledge base. The README documents broader integrations and capabilities not fully shown in sampled source, so those links are cited to the README rather than inferred from filenames.

Main entry points: [`apps/api/app/main.py`](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/main.py) (FastAPI application), [`apps/web/app/learning/page.tsx`](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/learning/page.tsx) (Learning workspace), [`apps/api/app/learning.py`](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/learning.py) (Learning orchestration), [`apps/api/app/practice.py`](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/practice.py) (Python practice)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Learner experience"]
  node_webapp["Next.js app<br/>[page.tsx]"]
  node_learningui["Learning workspace<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_learning["Learning services"]
  node_learning_service["Learning orchestration<br/>[learning.py]"]
  node_curriculum["Curriculum and lessons<br/>[curriculum.py]"]
  node_assessment["Checks and assessment<br/>[assessment.py]"]
  node_practice["Python practice<br/>[practice.py]"]
  node_hints["Exercise hints<br/>[exercise_hints.py]"]
  node_reviews["Spaced reviews<br/>[reviews_api.py]"]
  node_mentor["AI mentor<br/>[mentor.py]"]
  node_knowledge["Lesson knowledge base<br/>[knowledge_base.py]"]
  node_career["Career matching<br/>[vacancies.py]"]
  node_projects["Project practice<br/>[projects.py]"]
end

subgraph group_platform["Platform services"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_accounts["Account services"]
  node_database[("PostgreSQL<br/>[session.py]")]
end

subgraph group_execution["Code execution"]
  node_runner_api["Runner dispatch<br/>[runner.py]"]
  node_runner_server["Isolated Runner<br/>[server.py]"]
  node_runner_execution["Execution engine<br/>[execution.py]"]
end

subgraph group_integrations["External integrations"]
  node_ai_gateway["LLM gateway<br/>[ai_gateway.py]"]
  node_ai_provider{{"AI provider"}}
  node_telegram{{"Telegram"}}
  node_email{{"Email delivery"}}
end

node_learner(("Learner"))
node_browser(("Browser"))

node_learner -->|"uses"| node_browser
node_browser -->|"opens"| node_webapp
node_webapp -->|"opens learning"| node_learningui
node_learningui -->|"requests data"| node_api_client
node_api_client -->|"calls"| node_api
node_api -->|"registers routes"| node_auth
node_api -->|"registers routes"| node_learning_service
node_api -->|"registers routes"| node_mentor
node_api -->|"registers routes"| node_practice
node_api -->|"registers routes"| node_assessment
node_api -->|"registers routes"| node_career
node_learning_service -->|"uses curriculum"| node_curriculum
node_learning_service -->|"uses hints"| node_hints
node_learning_service -->|"requests AI"| node_ai_gateway
node_learningui -->|"loads reviews"| node_reviews
node_learningui -->|"opens mentor chat"| node_mentor
node_learningui -->|"submits practice"| node_practice
node_mentor -->|"retrieves context"| node_knowledge
node_ai_gateway -->|"calls provider"| node_ai_provider
node_api -->|"persists data"| node_database
node_practice -->|"dispatches execution"| node_runner_api
node_runner_api -->|"submits jobs"| node_runner_server
node_runner_server -->|"runs code"| node_runner_execution
node_api -.->|"integrates"| node_telegram
node_api -.->|"sends notifications"| node_email
node_api -->|"uses account controls"| node_accounts
node_api -.->|"serves projects"| node_projects
node_api -->|"serves reviews"| node_reviews

click node_webapp "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/page.tsx"
click node_learningui "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/learning/page.tsx"
click node_api_client "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/lib/api.ts"
click node_api "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/main.py"
click node_auth "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/auth.py"
click node_accounts "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/account_services.py"
click node_learning_service "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/learning.py"
click node_curriculum "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/curriculum.py"
click node_assessment "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/assessment.py"
click node_practice "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/practice.py"
click node_hints "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/exercise_hints.py"
click node_reviews "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/reviews_api.py"
click node_mentor "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/mentor.py"
click node_knowledge "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/knowledge_base.py"
click node_career "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/vacancies.py"
click node_projects "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/projects.py"
click node_database "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/db/session.py"
click node_runner_api "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/runner.py"
click node_runner_server "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/runner/runner_worker/server.py"
click node_runner_execution "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/runner/runner_worker/execution.py"
click node_ai_gateway "https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/ai_gateway.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_learningui,node_api_client,node_browser toneBlue
class node_learning_service,node_curriculum,node_assessment,node_practice,node_hints,node_reviews,node_mentor,node_knowledge,node_career,node_projects toneAmber
class node_api,node_auth,node_accounts,node_database toneMint
class node_runner_api,node_runner_server,node_runner_execution toneRose
class node_ai_gateway,node_ai_provider,node_telegram,node_email,node_learner toneIndigo
```

## Components

### Learner experience

- [Next.js app](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Learning workspace](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/learning/page.tsx): `apps/web/app/learning/page.tsx`
- [API client](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/web/app/lib/api.ts): `apps/web/app/lib/api.ts`

### Learning services

- [Learning orchestration](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/learning.py): `apps/api/app/learning.py`
- [Curriculum and lessons](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/curriculum.py): `apps/api/app/curriculum.py`
- [Checks and assessment](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/assessment.py): `apps/api/app/assessment.py`
- [Python practice](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/practice.py): `apps/api/app/practice.py`
- [Exercise hints](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/exercise_hints.py): `apps/api/app/exercise_hints.py`
- [Spaced reviews](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/reviews_api.py): `apps/api/app/reviews_api.py`
- [AI mentor](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/mentor.py): `apps/api/app/mentor.py`
- [Lesson knowledge base](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/knowledge_base.py): `apps/api/app/knowledge_base.py`
- [Career matching](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/vacancies.py): `apps/api/app/vacancies.py`
- [Project practice](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/projects.py): `apps/api/app/projects.py`

### Platform services

- [FastAPI application](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/main.py): `apps/api/app/main.py`
- [Authentication](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/auth.py): `apps/api/app/auth.py`
- [Account services](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/account_services.py): `apps/api/app/account_services.py`
- [PostgreSQL](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/db/session.py): `apps/api/app/db/session.py`

### Code execution

- [Runner dispatch](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/runner.py): `apps/api/app/runner.py`
- [Isolated Runner](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/runner/runner_worker/server.py): `apps/runner/runner_worker/server.py`
- [Execution engine](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/runner/runner_worker/execution.py): `apps/runner/runner_worker/execution.py`

### External integrations

- [LLM gateway](https://github.com/coffee1337/ai-python-mentor/blob/main/apps/api/app/ai_gateway.py): `apps/api/app/ai_gateway.py`
- **AI provider**
- **Telegram**
- **Email delivery**

### Other components

- **Learner**
- **Browser**

## Connections

- Learner → Browser: uses
- Browser → Next.js app: opens
- Next.js app → Learning workspace: opens learning (evidence: `apps/web/app/learning/page.tsx`)
- Learning workspace → API client: requests data (evidence: `apps/web/app/learning/page.tsx`)
- API client → FastAPI application: calls
- FastAPI application → Authentication: registers routes (evidence: `apps/api/app/main.py`)
- FastAPI application → Learning orchestration: registers routes (evidence: `apps/api/app/main.py`)
- FastAPI application → AI mentor: registers routes (evidence: `apps/api/app/main.py`)
- FastAPI application → Python practice: registers routes (evidence: `apps/api/app/main.py`)
- FastAPI application → Checks and assessment: registers routes (evidence: `apps/api/app/main.py`)
- FastAPI application → Career matching: registers routes (evidence: `apps/api/app/main.py`)
- Learning orchestration → Curriculum and lessons: uses curriculum (evidence: `apps/api/app/learning.py`)
- Learning orchestration → Exercise hints: uses hints (evidence: `apps/api/app/learning.py`)
- Learning orchestration → LLM gateway: requests AI (evidence: `apps/api/app/learning.py`)
- Learning workspace → Spaced reviews: loads reviews (evidence: `apps/web/app/learning/page.tsx`)
- Learning workspace → AI mentor: opens mentor chat (evidence: `apps/web/app/learning/page.tsx`)
- Learning workspace → Python practice: submits practice (evidence: `apps/web/app/learning/page.tsx`)
- AI mentor → Lesson knowledge base: retrieves context
- LLM gateway → AI provider: calls provider
- FastAPI application → PostgreSQL: persists data (evidence: `apps/api/app/main.py`)
- Python practice → Runner dispatch: dispatches execution
- Runner dispatch → Isolated Runner: submits jobs
- Isolated Runner → Execution engine: runs code (evidence: `apps/runner/runner_worker/server.py`)
- FastAPI application → Telegram: integrates
- FastAPI application → Email delivery: sends notifications
- FastAPI application → Account services: uses account controls
- FastAPI application → Project practice: serves projects (evidence: `apps/api/app/main.py`)
- FastAPI application → Spaced reviews: serves reviews (evidence: `apps/api/app/main.py`)
