# ali-haris/litai architecture

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

- Interactive diagram: https://gitdiagram.com/ali-haris/litai
- Repository: https://github.com/ali-haris/litai

## Overview

LitAI is a teacher-and-student AI literacy platform. Teachers create topics and AI-generated quizzes, manage student enrollment, and review performance; students take timed quizzes, see results and progress, and use the Prompt Lab for prompt feedback. The React app routes users to role-specific views, while FastAPI exposes the corresponding domain endpoints. Supabase provides authentication and persistent records, and Gemini supports quiz generation, learning paths, and prompt evaluation. Some frontend-to-backend request wiring and several page implementations were not excerpted, so those links are omitted rather than inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/ali-haris/litai/blob/main/frontend/src/App.tsx) (App routing), [`backend/core/auth.py`](https://github.com/ali-haris/litai/blob/main/backend/core/auth.py) (Authentication and profiles), [`frontend/src/lib/supabase.ts`](https://github.com/ali-haris/litai/blob/main/frontend/src/lib/supabase.ts) (Supabase client), [`backend/main.py`](https://github.com/ali-haris/litai/blob/main/backend/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_landing["Landing and signup entry<br/>[Landing.tsx]"]
  node_authui["Authentication views"]
  node_guard["Role access guard<br/>[ProtectedRoute.tsx]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
end

subgraph group_teacher["Teacher workflows"]
  node_teacher_topics["Topic management<br/>[TopicsList.tsx]"]
  node_teacher_quiz["Quiz authoring and review<br/>[QuizCreate.tsx]"]
  node_teacher_roster["Roster and student analytics<br/>[StudentDetail.tsx]"]
  node_teacher_dash["Teacher dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_student["Student learning"]
  node_student_quizzes["Quiz selection and start<br/>[QuizzesList.tsx]"]
  node_quiz_window["Timed quiz viewport<br/>[QuizWindow.tsx]"]
  node_quiz_result["Quiz results<br/>[QuizResult.tsx]"]
  node_student_progress["Progress analytics<br/>[Progress.tsx]"]
  node_prompt_ui["Prompt Lab<br/>[PromptLab.tsx]"]
end

subgraph group_backend["Backend services"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth["Authentication and profiles<br/>[auth.py]"]
  node_topics_api["Topic endpoints<br/>[topics.py]"]
  node_quizzes_api["Quiz generation and analytics<br/>[quizzes.py]"]
  node_student_api["Student quiz attempts<br/>[student_quizzes.py]"]
  node_teacher_api["Teacher student services"]
  node_prompt_api["Prompt evaluation endpoint<br/>[prompt_lab.py]"]
  node_users_api["User endpoints<br/>[users.py]"]
  node_ai["Gemini AI operations<br/>[ai.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_domain["Domain schemas"]
  node_models["Pydantic domain schemas"]
end

node_user(("Teacher or student"))
node_db[("Supabase PostgreSQL")]
node_gemini{{"Google Gemini"}}

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_authui
node_app -->|"protects routes"| node_guard
node_app -->|"routes to"| node_teacher_topics
node_app -->|"routes to"| node_teacher_quiz
node_app -->|"routes to"| node_teacher_roster
node_app -->|"routes to"| node_teacher_dash
node_app -->|"routes to"| node_student_quizzes
node_app -->|"routes to"| node_quiz_window
node_app -->|"routes to"| node_quiz_result
node_app -->|"routes to"| node_student_progress
node_app -->|"routes to"| node_prompt_ui
node_authui -->|"uses"| node_supabase_client
node_teacher_topics -->|"uses"| node_supabase_client
node_teacher_quiz -->|"uses"| node_supabase_client
node_teacher_roster -->|"uses"| node_supabase_client
node_student_quizzes -.->|"uses"| node_supabase_client
node_quiz_window -->|"uses"| node_supabase_client
node_quiz_result -->|"uses"| node_supabase_client
node_student_progress -->|"uses"| node_supabase_client
node_prompt_ui -->|"uses"| node_supabase_client
node_api -->|"depends on"| node_auth
node_api -->|"registers"| node_users_api
node_api -->|"registers"| node_topics_api
node_api -->|"registers"| node_quizzes_api
node_api -->|"registers"| node_student_api
node_api -->|"registers"| node_teacher_api
node_api -->|"registers"| node_prompt_api
node_auth -->|"reads settings"| node_config
node_auth -->|"validates and reads profiles"| node_db
node_topics_api -->|"uses role checks"| node_auth
node_topics_api -->|"uses schemas"| node_models
node_quizzes_api -->|"uses role checks"| node_auth
node_quizzes_api -->|"uses schemas"| node_models
node_quizzes_api -->|"reads and writes"| node_db
node_quizzes_api -->|"generates questions"| node_ai
node_student_api -->|"uses role checks"| node_auth
node_student_api -->|"uses schemas"| node_models
node_teacher_api -->|"uses role checks"| node_auth
node_teacher_api -->|"creates learning paths"| node_ai
node_prompt_api -->|"uses role checks"| node_auth
node_prompt_api -->|"evaluates prompts"| node_ai
node_users_api -->|"uses role checks"| node_auth
node_ai -->|"reads settings"| node_config
node_ai -->|"requests generation"| node_gemini
node_quizzes_api -->|"reads topic context"| node_db

click node_app "https://github.com/ali-haris/litai/blob/main/frontend/src/App.tsx"
click node_landing "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/Landing.tsx"
click node_authui "https://github.com/ali-haris/litai/tree/main/frontend/src/pages/auth"
click node_guard "https://github.com/ali-haris/litai/blob/main/frontend/src/components/ProtectedRoute.tsx"
click node_supabase_client "https://github.com/ali-haris/litai/blob/main/frontend/src/lib/supabase.ts"
click node_teacher_topics "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/TopicsList.tsx"
click node_teacher_quiz "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/QuizCreate.tsx"
click node_teacher_roster "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/StudentDetail.tsx"
click node_teacher_dash "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/Dashboard.tsx"
click node_student_quizzes "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizzesList.tsx"
click node_quiz_window "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizWindow.tsx"
click node_quiz_result "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizResult.tsx"
click node_student_progress "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/Progress.tsx"
click node_prompt_ui "https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/PromptLab.tsx"
click node_api "https://github.com/ali-haris/litai/blob/main/backend/main.py"
click node_auth "https://github.com/ali-haris/litai/blob/main/backend/core/auth.py"
click node_topics_api "https://github.com/ali-haris/litai/blob/main/backend/routers/topics.py"
click node_quizzes_api "https://github.com/ali-haris/litai/blob/main/backend/routers/quizzes.py"
click node_student_api "https://github.com/ali-haris/litai/blob/main/backend/routers/student_quizzes.py"
click node_teacher_api "https://github.com/ali-haris/litai/blob/main/backend/routers/teacher_students.py"
click node_prompt_api "https://github.com/ali-haris/litai/blob/main/backend/routers/prompt_lab.py"
click node_users_api "https://github.com/ali-haris/litai/blob/main/backend/routers/users.py"
click node_ai "https://github.com/ali-haris/litai/blob/main/backend/core/ai.py"
click node_config "https://github.com/ali-haris/litai/blob/main/backend/core/config.py"
click node_models "https://github.com/ali-haris/litai/tree/main/backend/models"

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_app,node_landing,node_authui,node_guard,node_supabase_client toneBlue
class node_teacher_topics,node_teacher_quiz,node_teacher_roster,node_teacher_dash,node_db toneAmber
class node_student_quizzes,node_quiz_window,node_quiz_result,node_student_progress,node_prompt_ui toneMint
class node_api,node_auth,node_topics_api,node_quizzes_api,node_student_api,node_teacher_api,node_prompt_api,node_users_api,node_ai,node_config toneRose
class node_models,node_user,node_gemini toneIndigo
```

## Components

### Frontend experience

- [App routing](https://github.com/ali-haris/litai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Landing and signup entry](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/Landing.tsx): `frontend/src/pages/Landing.tsx`
- [Authentication views](https://github.com/ali-haris/litai/tree/main/frontend/src/pages/auth): `frontend/src/pages/auth`
- [Role access guard](https://github.com/ali-haris/litai/blob/main/frontend/src/components/ProtectedRoute.tsx): `frontend/src/components/ProtectedRoute.tsx`
- [Supabase client](https://github.com/ali-haris/litai/blob/main/frontend/src/lib/supabase.ts): `frontend/src/lib/supabase.ts`

### Teacher workflows

- [Topic management](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/TopicsList.tsx): `frontend/src/pages/teacher/TopicsList.tsx`
- [Quiz authoring and review](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/QuizCreate.tsx): `frontend/src/pages/teacher/QuizCreate.tsx`
- [Roster and student analytics](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/StudentDetail.tsx): `frontend/src/pages/teacher/StudentDetail.tsx`
- [Teacher dashboard](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/teacher/Dashboard.tsx): `frontend/src/pages/teacher/Dashboard.tsx`

### Student learning

- [Quiz selection and start](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizzesList.tsx): `frontend/src/pages/student/QuizzesList.tsx`
- [Timed quiz viewport](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizWindow.tsx): `frontend/src/pages/student/QuizWindow.tsx`
- [Quiz results](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/QuizResult.tsx): `frontend/src/pages/student/QuizResult.tsx`
- [Progress analytics](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/Progress.tsx): `frontend/src/pages/student/Progress.tsx`
- [Prompt Lab](https://github.com/ali-haris/litai/blob/main/frontend/src/pages/student/PromptLab.tsx): `frontend/src/pages/student/PromptLab.tsx`

### Backend services

- [FastAPI application](https://github.com/ali-haris/litai/blob/main/backend/main.py): `backend/main.py`
- [Authentication and profiles](https://github.com/ali-haris/litai/blob/main/backend/core/auth.py): `backend/core/auth.py`
- [Topic endpoints](https://github.com/ali-haris/litai/blob/main/backend/routers/topics.py): `backend/routers/topics.py`
- [Quiz generation and analytics](https://github.com/ali-haris/litai/blob/main/backend/routers/quizzes.py): `backend/routers/quizzes.py`
- [Student quiz attempts](https://github.com/ali-haris/litai/blob/main/backend/routers/student_quizzes.py): `backend/routers/student_quizzes.py`
- [Teacher student services](https://github.com/ali-haris/litai/blob/main/backend/routers/teacher_students.py): `backend/routers/teacher_students.py`
- [Prompt evaluation endpoint](https://github.com/ali-haris/litai/blob/main/backend/routers/prompt_lab.py): `backend/routers/prompt_lab.py`
- [User endpoints](https://github.com/ali-haris/litai/blob/main/backend/routers/users.py): `backend/routers/users.py`
- [Gemini AI operations](https://github.com/ali-haris/litai/blob/main/backend/core/ai.py): `backend/core/ai.py`
- [Runtime configuration](https://github.com/ali-haris/litai/blob/main/backend/core/config.py): `backend/core/config.py`

### Domain schemas

- [Pydantic domain schemas](https://github.com/ali-haris/litai/tree/main/backend/models): `backend/models`

### Other components

- **Teacher or student**
- **Supabase PostgreSQL**
- **Google Gemini**

## Connections

- Teacher or student → App routing: opens (evidence: `frontend/src/App.tsx`)
- App routing → Landing and signup entry: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Authentication views: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Role access guard: protects routes (evidence: `frontend/src/App.tsx`)
- App routing → Topic management: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Quiz authoring and review: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Roster and student analytics: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Teacher dashboard: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Quiz selection and start: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Timed quiz viewport: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Quiz results: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Progress analytics: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Prompt Lab: routes to (evidence: `frontend/src/App.tsx`)
- Authentication views → Supabase client: uses (evidence: `frontend/src/pages/auth/Login.tsx`)
- Topic management → Supabase client: uses (evidence: `frontend/src/pages/teacher/TopicsList.tsx`)
- Quiz authoring and review → Supabase client: uses (evidence: `frontend/src/pages/teacher/QuizCreate.tsx`)
- Roster and student analytics → Supabase client: uses (evidence: `frontend/src/pages/teacher/StudentDetail.tsx`)
- Quiz selection and start → Supabase client: uses
- Timed quiz viewport → Supabase client: uses (evidence: `frontend/src/pages/student/QuizWindow.tsx`)
- Quiz results → Supabase client: uses (evidence: `frontend/src/pages/student/QuizResult.tsx`)
- Progress analytics → Supabase client: uses (evidence: `frontend/src/pages/student/Progress.tsx`)
- Prompt Lab → Supabase client: uses (evidence: `frontend/src/pages/student/PromptLab.tsx`)
- FastAPI application → Authentication and profiles: depends on (evidence: `backend/main.py`)
- FastAPI application → User endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Topic endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Quiz generation and analytics: registers (evidence: `backend/main.py`)
- FastAPI application → Student quiz attempts: registers (evidence: `backend/main.py`)
- FastAPI application → Teacher student services: registers (evidence: `backend/main.py`)
- FastAPI application → Prompt evaluation endpoint: registers (evidence: `backend/main.py`)
- Authentication and profiles → Runtime configuration: reads settings (evidence: `backend/core/auth.py`)
- Authentication and profiles → Supabase PostgreSQL: validates and reads profiles (evidence: `backend/core/auth.py`)
- Topic endpoints → Authentication and profiles: uses role checks (evidence: `backend/routers/topics.py`)
- Topic endpoints → Pydantic domain schemas: uses schemas (evidence: `backend/routers/topics.py`)
- Quiz generation and analytics → Authentication and profiles: uses role checks (evidence: `backend/routers/quizzes.py`)
- Quiz generation and analytics → Pydantic domain schemas: uses schemas (evidence: `backend/routers/quizzes.py`)
- Quiz generation and analytics → Supabase PostgreSQL: reads and writes (evidence: `backend/routers/quizzes.py`)
- Quiz generation and analytics → Gemini AI operations: generates questions (evidence: `backend/routers/quizzes.py`)
- Student quiz attempts → Authentication and profiles: uses role checks (evidence: `backend/routers/student_quizzes.py`)
- Student quiz attempts → Pydantic domain schemas: uses schemas (evidence: `backend/routers/student_quizzes.py`)
- Teacher student services → Authentication and profiles: uses role checks (evidence: `backend/routers/teacher_students.py`)
- Teacher student services → Gemini AI operations: creates learning paths (evidence: `backend/routers/teacher_students.py`)
- Prompt evaluation endpoint → Authentication and profiles: uses role checks (evidence: `backend/routers/prompt_lab.py`)
- Prompt evaluation endpoint → Gemini AI operations: evaluates prompts (evidence: `backend/routers/prompt_lab.py`)
- User endpoints → Authentication and profiles: uses role checks (evidence: `backend/routers/users.py`)
- Gemini AI operations → Runtime configuration: reads settings (evidence: `backend/core/ai.py`)
- Gemini AI operations → Google Gemini: requests generation (evidence: `backend/core/ai.py`)
- Quiz generation and analytics → Supabase PostgreSQL: reads topic context (evidence: `backend/routers/quizzes.py`)
