# rakeshvarma007/smart-study-buddy architecture

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

- Interactive diagram: https://gitdiagram.com/rakeshvarma007/smart-study-buddy
- Repository: https://github.com/rakeshvarma007/smart-study-buddy

## Overview

Smart Study Buddy is a Streamlit app for asking natural-language questions about an uploaded PDF and receiving answers with page references. The main flow extracts and chunks PDF pages, embeds them into a FAISS index, retrieves relevant chunks for a question, and generates an answer using a prompt that requests page citations. The README describes a distil GPT-2 model, but the sampled implementation loads Qwen2-1.5B-Instruct. All runtime components are in one file; the graph reflects that file’s visible calls.

Main entry points: [`smart-study-buddy.py`](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py) (Streamlit interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Study interface"]
  node_streamlit["Streamlit interface"]
  node_answer_sources["Answer and citations"]
end

subgraph group_documents["Document indexing"]
  node_pdf_processing["PDF processing"]
  node_text_splitter["Text chunking"]
  node_embeddings["Embedding model"]
  node_faiss[("FAISS index")]
end

subgraph group_qa["Question answering"]
  node_retriever["Retriever"]
  node_retrieval_chain["Retrieval chain"]
  node_prompt_combiner["Prompt and context"]
  node_llm["Language model"]
end

node_student(("Student"))

node_student -->|"uploads PDF"| node_streamlit
node_streamlit -->|"processes PDF"| node_pdf_processing
node_pdf_processing -->|"splits pages"| node_text_splitter
node_streamlit -->|"initializes"| node_embeddings
node_streamlit -->|"indexes chunks"| node_faiss
node_text_splitter -->|"provides chunks"| node_faiss
node_embeddings -->|"embeds chunks"| node_faiss
node_student -->|"asks question"| node_streamlit
node_faiss -->|"creates retriever"| node_retriever
node_retrieval_chain -->|"queries"| node_retriever
node_retrieval_chain -->|"passes context"| node_prompt_combiner
node_prompt_combiner -->|"generates answer"| node_llm
node_streamlit -->|"invokes"| node_retrieval_chain
node_retrieval_chain -->|"returns answer and context"| node_answer_sources
node_answer_sources -->|"shows answer and pages"| node_student

click node_streamlit "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_pdf_processing "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_text_splitter "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_embeddings "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_faiss "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_retriever "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_retrieval_chain "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_prompt_combiner "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_llm "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py"
click node_answer_sources "https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.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_streamlit,node_answer_sources toneBlue
class node_pdf_processing,node_text_splitter,node_embeddings,node_faiss toneAmber
class node_retriever,node_retrieval_chain,node_prompt_combiner,node_llm toneMint
class node_student toneIndigo
```

## Components

### Study interface

- [Streamlit interface](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Answer and citations](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`

### Document indexing

- [PDF processing](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Text chunking](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Embedding model](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [FAISS index](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`

### Question answering

- [Retriever](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Retrieval chain](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Prompt and context](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`
- [Language model](https://github.com/rakeshvarma007/smart-study-buddy/blob/main/smart-study-buddy.py): `smart-study-buddy.py`

### Other components

- **Student**

## Connections

- Student → Streamlit interface: uploads PDF (evidence: `smart-study-buddy.py`)
- Streamlit interface → PDF processing: processes PDF (evidence: `smart-study-buddy.py`)
- PDF processing → Text chunking: splits pages (evidence: `smart-study-buddy.py`)
- Streamlit interface → Embedding model: initializes (evidence: `smart-study-buddy.py`)
- Streamlit interface → FAISS index: indexes chunks (evidence: `smart-study-buddy.py`)
- Text chunking → FAISS index: provides chunks (evidence: `smart-study-buddy.py`)
- Embedding model → FAISS index: embeds chunks (evidence: `smart-study-buddy.py`)
- Student → Streamlit interface: asks question (evidence: `smart-study-buddy.py`)
- FAISS index → Retriever: creates retriever (evidence: `smart-study-buddy.py`)
- Retrieval chain → Retriever: queries (evidence: `smart-study-buddy.py`)
- Retrieval chain → Prompt and context: passes context (evidence: `smart-study-buddy.py`)
- Prompt and context → Language model: generates answer (evidence: `smart-study-buddy.py`)
- Streamlit interface → Retrieval chain: invokes (evidence: `smart-study-buddy.py`)
- Retrieval chain → Answer and citations: returns answer and context (evidence: `smart-study-buddy.py`)
- Answer and citations → Student: shows answer and pages (evidence: `smart-study-buddy.py`)
