# muhammadfahd/ai-mentor architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadfahd/ai-mentor
- Repository: https://github.com/muhammadfahd/ai-mentor

## Overview

AI Mentor is an MVP for asking learning questions, receiving AI explanations, and tracking topics. The documented workflow runs from the user-facing Next.js app to a FastAPI chat endpoint, which calls AI generation and saves progress; the response returns through the API to the app. The README also describes a three-interaction history display, but frontend source is not included in the supplied excerpts, so its implementation and data flow cannot be verified. Edges reflect the shown backend calls or documented architecture.

Main entry points: [`backend/main.py`](https://github.com/muhammadfahd/ai-mentor/blob/main/backend/main.py) (Chat endpoint), [`backend/ai_logic.py`](https://github.com/muhammadfahd/ai-mentor/blob/main/backend/ai_logic.py) (AI and progress logic), [`frontend`](https://github.com/muhammadfahd/ai-mentor/tree/main/frontend) (Chat and history UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Learning interface"]
  node_learning_ui["Chat and history UI"]
end

subgraph group_backend["Chat API"]
  node_chat_api["Chat endpoint<br/>[main.py]"]
end

subgraph group_services["AI and persistence"]
  node_ai_logic["AI and progress logic<br/>[ai_logic.py]"]
end

node_learner(("Learner"))
node_groq["Groq LLaMA"]
node_supabase[("Supabase progress")]

node_learner -->|"asks questions"| node_learning_ui
node_learning_ui -->|"sends chat"| node_chat_api
node_chat_api -->|"calls ask_ai"| node_ai_logic
node_ai_logic -->|"generates response"| node_groq
node_chat_api -->|"calls save_progress"| node_ai_logic
node_ai_logic -->|"saves topic"| node_supabase
node_chat_api -->|"returns response"| node_learning_ui

click node_learning_ui "https://github.com/muhammadfahd/ai-mentor/tree/main/frontend"
click node_chat_api "https://github.com/muhammadfahd/ai-mentor/blob/main/backend/main.py"
click node_ai_logic "https://github.com/muhammadfahd/ai-mentor/blob/main/backend/ai_logic.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_learning_ui toneBlue
class node_chat_api,node_supabase toneAmber
class node_ai_logic toneMint
class node_learner,node_groq toneIndigo
```

## Components

### Learning interface

- [Chat and history UI](https://github.com/muhammadfahd/ai-mentor/tree/main/frontend): `frontend`

### Chat API

- [Chat endpoint](https://github.com/muhammadfahd/ai-mentor/blob/main/backend/main.py): `backend/main.py`

### AI and persistence

- [AI and progress logic](https://github.com/muhammadfahd/ai-mentor/blob/main/backend/ai_logic.py): `backend/ai_logic.py`

### Other components

- **Learner**
- **Groq LLaMA**
- **Supabase progress**

## Connections

- Learner → Chat and history UI: asks questions (evidence: `README.md`)
- Chat and history UI → Chat endpoint: sends chat (evidence: `README.md`)
- Chat endpoint → AI and progress logic: calls ask_ai (evidence: `backend/main.py`)
- AI and progress logic → Groq LLaMA: generates response (evidence: `backend/ai_logic.py`)
- Chat endpoint → AI and progress logic: calls save_progress (evidence: `backend/main.py`)
- AI and progress logic → Supabase progress: saves topic (evidence: `backend/ai_logic.py`)
- Chat endpoint → Chat and history UI: returns response (evidence: `README.md`)
