# shreshth1805/ai-tutor architecture

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

## Overview

EduSmart AI Tutor is a Streamlit learning assistant with two paths: document-based study and general tutoring. In study mode, uploaded files are extracted, embedded in a FAISS index, retrieved for a conversational QA chain, and used for chat, summaries, quizzes, and flashcards. General questions are routed by keyword or arithmetic symbols to research, Wikipedia, calculator, or the default LLM path. The README also describes contextual learning and tool capabilities. The sampled LLM implementation uses Hugging Face, despite the README describing Groq; unsampled behavior and integrations are not inferred.

Main entry points: [`app.py`](https://github.com/shreshth1805/ai-tutor/blob/main/app.py) (Streamlit app), [`src/tutor.py`](https://github.com/shreshth1805/ai-tutor/blob/main/src/tutor.py) (Conversational QA), [`src/tools.py`](https://github.com/shreshth1805/ai-tutor/blob/main/src/tools.py) (Tool definitions), [`src/llm.py`](https://github.com/shreshth1805/ai-tutor/blob/main/src/llm.py) (LLM client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Student interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_study["Document learning"]
  node_loader["File extraction<br/>[doc_loader.py]"]
  node_indexer["Chunk and index<br/>[vecor_store.py]"]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
  node_faiss[("FAISS index<br/>[vecor_store.py]")]
  node_retriever["Document retriever<br/>[vecor_store.py]"]
  node_qa["Conversational QA<br/>[tutor.py]"]
end

subgraph group_tutor["Tutor and routing"]
  node_memory["Chat memory<br/>[memory.py]"]
  node_agent["Question router<br/>[agents.py]"]
  node_prompts["Tutor prompt<br/>[prompts.py]"]
end

subgraph group_integrations["Models and tools"]
  node_llm["LLM client<br/>[llm.py]"]
  node_config["API configuration<br/>[config.py]"]
  node_tools["Tool definitions<br/>[tools.py]"]
end

node_student(("Student"))
node_wikipedia{{"Wikipedia"}}
node_arxiv{{"ArXiv"}}
node_calculator{{"Calculator"}}
node_hf{{"Hugging Face endpoint"}}

node_student -->|"uses"| node_app
node_app -->|"loads upload"| node_loader
node_app -->|"builds index"| node_indexer
node_indexer -->|"creates embeddings"| node_embeddings
node_indexer -->|"stores vectors"| node_faiss
node_app -->|"creates retriever"| node_retriever
node_app -->|"creates QA chain"| node_qa
node_app -->|"invokes for study"| node_qa
node_qa -->|"retrieves context"| node_retriever
node_qa -->|"uses memory"| node_memory
node_qa -->|"uses model"| node_llm
node_app -->|"routes general query"| node_agent
node_agent -->|"dispatches tools"| node_tools
node_agent -->|"answers default query"| node_llm
node_tools -.->|"queries"| node_wikipedia
node_tools -.->|"searches"| node_arxiv
node_tools -->|"evaluates expression"| node_calculator
node_llm -->|"reads token"| node_config
node_llm -->|"calls endpoint"| node_hf

click node_app "https://github.com/shreshth1805/ai-tutor/blob/main/app.py"
click node_loader "https://github.com/shreshth1805/ai-tutor/blob/main/src/doc_loader.py"
click node_indexer "https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py"
click node_embeddings "https://github.com/shreshth1805/ai-tutor/blob/main/src/embeddings.py"
click node_faiss "https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py"
click node_retriever "https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py"
click node_qa "https://github.com/shreshth1805/ai-tutor/blob/main/src/tutor.py"
click node_memory "https://github.com/shreshth1805/ai-tutor/blob/main/src/memory.py"
click node_agent "https://github.com/shreshth1805/ai-tutor/blob/main/src/agents.py"
click node_prompts "https://github.com/shreshth1805/ai-tutor/blob/main/src/prompts.py"
click node_llm "https://github.com/shreshth1805/ai-tutor/blob/main/src/llm.py"
click node_config "https://github.com/shreshth1805/ai-tutor/blob/main/src/config.py"
click node_tools "https://github.com/shreshth1805/ai-tutor/blob/main/src/tools.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_app toneBlue
class node_loader,node_indexer,node_embeddings,node_faiss,node_retriever,node_qa toneAmber
class node_memory,node_agent,node_prompts toneMint
class node_llm,node_config,node_tools toneRose
class node_student,node_wikipedia,node_arxiv,node_calculator,node_hf toneIndigo
```

## Components

### Student interface

- [Streamlit app](https://github.com/shreshth1805/ai-tutor/blob/main/app.py): `app.py`

### Document learning

- [File extraction](https://github.com/shreshth1805/ai-tutor/blob/main/src/doc_loader.py): `src/doc_loader.py`
- [Chunk and index](https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py): `src/vecor_store.py`
- [Text embeddings](https://github.com/shreshth1805/ai-tutor/blob/main/src/embeddings.py): `src/embeddings.py`
- [FAISS index](https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py): `src/vecor_store.py`
- [Document retriever](https://github.com/shreshth1805/ai-tutor/blob/main/src/vecor_store.py): `src/vecor_store.py`
- [Conversational QA](https://github.com/shreshth1805/ai-tutor/blob/main/src/tutor.py): `src/tutor.py`

### Tutor and routing

- [Chat memory](https://github.com/shreshth1805/ai-tutor/blob/main/src/memory.py): `src/memory.py`
- [Question router](https://github.com/shreshth1805/ai-tutor/blob/main/src/agents.py): `src/agents.py`
- [Tutor prompt](https://github.com/shreshth1805/ai-tutor/blob/main/src/prompts.py): `src/prompts.py`

### Models and tools

- [LLM client](https://github.com/shreshth1805/ai-tutor/blob/main/src/llm.py): `src/llm.py`
- [API configuration](https://github.com/shreshth1805/ai-tutor/blob/main/src/config.py): `src/config.py`
- [Tool definitions](https://github.com/shreshth1805/ai-tutor/blob/main/src/tools.py): `src/tools.py`

### Other components

- **Student**
- **Wikipedia**
- **ArXiv**
- **Calculator**
- **Hugging Face endpoint**

## Connections

- Student → Streamlit app: uses (evidence: `README.md`)
- Streamlit app → File extraction: loads upload (evidence: `app.py`)
- Streamlit app → Chunk and index: builds index (evidence: `app.py`)
- Chunk and index → Text embeddings: creates embeddings (evidence: `src/vecor_store.py`)
- Chunk and index → FAISS index: stores vectors (evidence: `src/vecor_store.py`)
- Streamlit app → Document retriever: creates retriever (evidence: `app.py`)
- Streamlit app → Conversational QA: creates QA chain (evidence: `app.py`)
- Streamlit app → Conversational QA: invokes for study (evidence: `app.py`)
- Conversational QA → Document retriever: retrieves context (evidence: `src/tutor.py`)
- Conversational QA → Chat memory: uses memory (evidence: `src/tutor.py`)
- Conversational QA → LLM client: uses model (evidence: `src/tutor.py`)
- Streamlit app → Question router: routes general query (evidence: `app.py`)
- Question router → Tool definitions: dispatches tools (evidence: `src/agents.py`)
- Question router → LLM client: answers default query (evidence: `src/agents.py`)
- Tool definitions → Wikipedia: queries (evidence: `README.md`)
- Tool definitions → ArXiv: searches (evidence: `README.md`)
- Tool definitions → Calculator: evaluates expression (evidence: `src/tools.py`)
- LLM client → API configuration: reads token (evidence: `src/llm.py`)
- LLM client → Hugging Face endpoint: calls endpoint (evidence: `src/llm.py`)
