# haricrazy1432-bot/ragchatbot architecture

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

- Interactive diagram: https://gitdiagram.com/haricrazy1432-bot/ragchatbot
- Repository: https://github.com/haricrazy1432-bot/ragchatbot

## Overview

StudyMate AI is a Streamlit study assistant that accepts PDFs, builds an in-memory searchable index, and answers document-grounded questions with conversation history. The main workflow runs in app.py: upload and extract a PDF, chunk and embed its text, create a Chroma store, retrieve relevant chunks for a question, then send context and history to Groq and display the answer. The README gives no further capabilities; all implementation components below share the single source file, so edges reflect calls visible there.

Main entry points: [`app.py`](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py) (Streamlit interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Study interface"]
  node_streamlit_ui["Streamlit interface<br/>[app.py]"]
end

subgraph group_indexing["Document indexing"]
  node_pdf_extract["PDF extraction<br/>[app.py]"]
  node_text_chunking["Text chunking<br/>[app.py]"]
  node_embedding_model["Embedding model<br/>[app.py]"]
  node_chroma_index[("Chroma index<br/>[app.py]")]
end

subgraph group_qa["Question answering"]
  node_retrieval["Chunk retrieval<br/>[app.py]"]
  node_history_tools["History formatting<br/>[app.py]"]
  node_prompt_builder["Prompt construction<br/>[app.py]"]
  node_llm_chain["LLM chain<br/>[app.py]"]
end

node_user(("Learner"))
node_groq{{"Groq model service"}}

node_user -->|"uses"| node_streamlit_ui
node_streamlit_ui -->|"extracts PDF"| node_pdf_extract
node_streamlit_ui -->|"chunks text"| node_text_chunking
node_streamlit_ui -->|"initializes"| node_embedding_model
node_streamlit_ui -->|"builds index"| node_chroma_index
node_chroma_index -->|"embeds chunks"| node_embedding_model
node_streamlit_ui -->|"queries index"| node_retrieval
node_retrieval -->|"retrieves chunks"| node_chroma_index
node_streamlit_ui -->|"formats history"| node_history_tools
node_streamlit_ui -->|"assembles prompt"| node_prompt_builder
node_streamlit_ui -->|"runs chain"| node_llm_chain
node_llm_chain -->|"requests answer"| node_groq
node_streamlit_ui -->|"displays answer"| node_user

click node_streamlit_ui "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_pdf_extract "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_text_chunking "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_embedding_model "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_chroma_index "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_retrieval "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_history_tools "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_prompt_builder "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py"
click node_llm_chain "https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.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_ui toneBlue
class node_pdf_extract,node_text_chunking,node_embedding_model,node_chroma_index toneAmber
class node_retrieval,node_history_tools,node_prompt_builder,node_llm_chain toneMint
class node_user,node_groq toneIndigo
```

## Components

### Study interface

- [Streamlit interface](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`

### Document indexing

- [PDF extraction](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [Text chunking](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [Embedding model](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [Chroma index](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`

### Question answering

- [Chunk retrieval](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [History formatting](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [Prompt construction](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`
- [LLM chain](https://github.com/haricrazy1432-bot/ragchatbot/blob/main/app.py): `app.py`

### Other components

- **Learner**
- **Groq model service**

## Connections

- Learner → Streamlit interface: uses (evidence: `app.py`)
- Streamlit interface → PDF extraction: extracts PDF (evidence: `app.py`)
- Streamlit interface → Text chunking: chunks text (evidence: `app.py`)
- Streamlit interface → Embedding model: initializes (evidence: `app.py`)
- Streamlit interface → Chroma index: builds index (evidence: `app.py`)
- Chroma index → Embedding model: embeds chunks (evidence: `app.py`)
- Streamlit interface → Chunk retrieval: queries index (evidence: `app.py`)
- Chunk retrieval → Chroma index: retrieves chunks (evidence: `app.py`)
- Streamlit interface → History formatting: formats history (evidence: `app.py`)
- Streamlit interface → Prompt construction: assembles prompt (evidence: `app.py`)
- Streamlit interface → LLM chain: runs chain (evidence: `app.py`)
- LLM chain → Groq model service: requests answer (evidence: `app.py`)
- Streamlit interface → Learner: displays answer (evidence: `app.py`)
