# yesh-is-here2/teachai architecture

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

- Interactive diagram: https://gitdiagram.com/yesh-is-here2/teachai
- Repository: https://github.com/yesh-is-here2/teachai

## Overview

TeachAI is a Python tutoring app: learners can add notes, ask questions answered with retrieved note context, or request a structured lesson. The web app calls a FastAPI backend; the backend handles guest identity, note ingestion, retrieval, and lesson generation, with SQLite persistence and an in-memory vector index. The graph follows documented capabilities and excerpted calls; unsampled UI and backend details are not expanded beyond README evidence.

Main entry points: [`backend/main.py`](https://github.com/yesh-is-here2/teachai/blob/main/backend/main.py) (FastAPI routes), [`mobile_app/app/page.tsx`](https://github.com/yesh-is-here2/teachai/blob/main/mobile_app/app/page.tsx) (Tutor interface), [`backend/db/crud.py`](https://github.com/yesh-is-here2/teachai/blob/main/backend/db/crud.py) (User and notes CRUD), [`backend/services/llm.py`](https://github.com/yesh-is-here2/teachai/blob/main/backend/services/llm.py) (Embeddings and answers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Tutor interface<br/>[page.tsx]"]
end

subgraph group_api["Backend API"]
  node_api_service["FastAPI routes<br/>[main.py]"]
end

subgraph group_rag["Notes and retrieval"]
  node_chunking["Text chunking<br/>[chunking.py]"]
  node_vector["Vector search<br/>[vectorstore.py]"]
end

subgraph group_data["Persistence and AI"]
  node_crud["User and notes CRUD<br/>[crud.py]"]
  node_schema["Relational schema<br/>[models.py]"]
  node_sqlite[("SQLite database<br/>[database.py]")]
  node_llm["Embeddings and answers<br/>[llm.py]"]
end

node_learner(("Learner"))
node_openai{{"OpenAI API"}}

node_learner -->|"uses"| node_web
node_web -->|"asks"| node_api_service
node_web -->|"requests lessons"| node_api_service
node_web -.->|"submits notes"| node_api_service
node_api_service -->|"checks and stores"| node_crud
node_crud -->|"queries and creates"| node_schema
node_api_service -->|"opens sessions"| node_sqlite
node_schema -->|"uses base"| node_sqlite
node_api_service -->|"chunks notes"| node_chunking
node_api_service -->|"embeds text"| node_llm
node_api_service -->|"adds and searches"| node_vector
node_api_service -->|"loads chunks"| node_crud
node_api_service -->|"generates responses"| node_llm
node_llm -->|"calls"| node_openai

click node_web "https://github.com/yesh-is-here2/teachai/blob/main/mobile_app/app/page.tsx"
click node_api_service "https://github.com/yesh-is-here2/teachai/blob/main/backend/main.py"
click node_chunking "https://github.com/yesh-is-here2/teachai/blob/main/backend/rag/chunking.py"
click node_vector "https://github.com/yesh-is-here2/teachai/blob/main/backend/rag/vectorstore.py"
click node_crud "https://github.com/yesh-is-here2/teachai/blob/main/backend/db/crud.py"
click node_schema "https://github.com/yesh-is-here2/teachai/blob/main/backend/db/models.py"
click node_sqlite "https://github.com/yesh-is-here2/teachai/blob/main/backend/db/database.py"
click node_llm "https://github.com/yesh-is-here2/teachai/blob/main/backend/services/llm.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_web toneBlue
class node_api_service toneAmber
class node_chunking,node_vector,node_openai toneMint
class node_crud,node_schema,node_sqlite,node_llm toneRose
class node_learner toneIndigo
```

## Components

### Web client

- [Tutor interface](https://github.com/yesh-is-here2/teachai/blob/main/mobile_app/app/page.tsx): `mobile_app/app/page.tsx`

### Backend API

- [FastAPI routes](https://github.com/yesh-is-here2/teachai/blob/main/backend/main.py): `backend/main.py`

### Notes and retrieval

- [Text chunking](https://github.com/yesh-is-here2/teachai/blob/main/backend/rag/chunking.py): `backend/rag/chunking.py`
- [Vector search](https://github.com/yesh-is-here2/teachai/blob/main/backend/rag/vectorstore.py): `backend/rag/vectorstore.py`

### Persistence and AI

- [User and notes CRUD](https://github.com/yesh-is-here2/teachai/blob/main/backend/db/crud.py): `backend/db/crud.py`
- [Relational schema](https://github.com/yesh-is-here2/teachai/blob/main/backend/db/models.py): `backend/db/models.py`
- [SQLite database](https://github.com/yesh-is-here2/teachai/blob/main/backend/db/database.py): `backend/db/database.py`
- [Embeddings and answers](https://github.com/yesh-is-here2/teachai/blob/main/backend/services/llm.py): `backend/services/llm.py`

### Other components

- **Learner**
- **OpenAI API**

## Connections

- Learner → Tutor interface: uses (evidence: `README.md`)
- Tutor interface → FastAPI routes: asks (evidence: `mobile_app/app/page.tsx`)
- Tutor interface → FastAPI routes: requests lessons (evidence: `mobile_app/app/page.tsx`)
- Tutor interface → FastAPI routes: submits notes (evidence: `README.md`)
- FastAPI routes → User and notes CRUD: checks and stores (evidence: `backend/main.py`)
- User and notes CRUD → Relational schema: queries and creates (evidence: `backend/db/crud.py`)
- FastAPI routes → SQLite database: opens sessions (evidence: `backend/main.py`)
- Relational schema → SQLite database: uses base (evidence: `backend/db/models.py`)
- FastAPI routes → Text chunking: chunks notes (evidence: `backend/main.py`)
- FastAPI routes → Embeddings and answers: embeds text (evidence: `backend/main.py`)
- FastAPI routes → Vector search: adds and searches (evidence: `backend/main.py`)
- FastAPI routes → User and notes CRUD: loads chunks (evidence: `backend/main.py`)
- FastAPI routes → Embeddings and answers: generates responses (evidence: `backend/main.py`)
- Embeddings and answers → OpenAI API: calls (evidence: `backend/services/llm.py`)
