# rithubaran1995-eng/personal-study-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/rithubaran1995-eng/personal-study-assistant
- Repository: https://github.com/rithubaran1995-eng/personal-study-assistant

## Overview

Personal Study Assistant is a Streamlit app for indexing PDFs and asking questions grounded in their contents. Users upload PDFs, which are deduplicated, extracted, chunked, embedded, and indexed; questions are embedded and matched against active documents, then retrieved context is sent to Groq and answers are shown with source pages. The app also manages document deletion and conversation history. The source excerpts show the main orchestration and storage calls; distinct PDF, embedding, and vector-store stages are responsibilities implemented within the same RAG module, not separately sampled modules.

Main entry points: [`src/rag_pipeline.py`](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py) (RAG Pipeline), [`app.py`](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py) (Chat Orchestrator), [`src/database.py`](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/database.py) (SQLite Records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Study Interface"]
  node_streamlit["Study UI<br/>[app.py]"]
  node_chat["Chat Orchestrator<br/>[app.py]"]
  node_documents["Document Library<br/>[app.py]"]
end

subgraph group_ingestion["Document Ingestion"]
  node_pdf["PDF Extraction<br/>[rag_pipeline.py]"]
  node_dedup["Duplicate Check<br/>[rag_pipeline.py]"]
  node_chunking["Text Chunking<br/>[rag_pipeline.py]"]
  node_embeddings["Local Embeddings<br/>[rag_pipeline.py]"]
  node_vectorstore[("Vector Index<br/>[rag_pipeline.py]")]
end

subgraph group_retrieval["Grounded Answers"]
  node_rag["RAG Pipeline<br/>[rag_pipeline.py]"]
  node_retrievalsearch["Chunk Retrieval<br/>[rag_pipeline.py]"]
  node_groq["Groq AI"]
  node_citations["Source References<br/>[app.py]"]
end

subgraph group_persistence["Application Data"]
  node_sqlite[("SQLite Records<br/>[database.py]")]
  node_history["Conversation History<br/>[app.py]"]
end

node_learner(("Learner"))

node_learner -->|"uses"| node_streamlit
node_streamlit -->|"uploads PDFs"| node_rag
node_streamlit -->|"manages documents"| node_documents
node_documents -->|"lists and deletes"| node_rag
node_rag -->|"checks duplicates"| node_dedup
node_dedup -->|"looks up hash"| node_sqlite
node_rag -->|"extracts text"| node_pdf
node_pdf -->|"splits text"| node_chunking
node_rag -->|"embeds chunks"| node_embeddings
node_rag -->|"stores chunks"| node_vectorstore
node_rag -->|"registers documents"| node_sqlite
node_chat -->|"searches question"| node_rag
node_rag -->|"queries index"| node_retrievalsearch
node_retrievalsearch -->|"embeds query"| node_embeddings
node_retrievalsearch -->|"retrieves matches"| node_vectorstore
node_chat -->|"sends context"| node_groq
node_groq -->|"returns answer"| node_chat
node_chat -->|"adds source pages"| node_citations
node_chat -->|"saves messages"| node_history
node_history -->|"reads and writes"| node_sqlite
node_streamlit -->|"accepts questions"| node_chat
node_documents -->|"loads registry"| node_sqlite
node_history -->|"loads conversations"| node_sqlite

click node_streamlit "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py"
click node_chat "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py"
click node_pdf "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_dedup "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_chunking "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_embeddings "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_vectorstore "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_rag "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_retrievalsearch "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py"
click node_citations "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py"
click node_sqlite "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/database.py"
click node_documents "https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py"
click node_history "https://github.com/rithubaran1995-eng/personal-study-assistant/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,node_chat,node_documents toneBlue
class node_pdf,node_dedup,node_chunking,node_embeddings,node_vectorstore toneAmber
class node_rag,node_retrievalsearch,node_groq,node_citations toneMint
class node_sqlite,node_history toneRose
class node_learner toneIndigo
```

## Components

### Study Interface

- [Study UI](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py): `app.py`
- [Chat Orchestrator](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py): `app.py`
- [Document Library](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py): `app.py`

### Document Ingestion

- [PDF Extraction](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Duplicate Check](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Text Chunking](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Local Embeddings](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Vector Index](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`

### Grounded Answers

- [RAG Pipeline](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Chunk Retrieval](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- **Groq AI**
- [Source References](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py): `app.py`

### Application Data

- [SQLite Records](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/src/database.py): `src/database.py`
- [Conversation History](https://github.com/rithubaran1995-eng/personal-study-assistant/blob/main/app.py): `app.py`

### Other components

- **Learner**

## Connections

- Learner → Study UI: uses (evidence: `README.md`)
- Study UI → RAG Pipeline: uploads PDFs (evidence: `app.py`)
- Study UI → Document Library: manages documents (evidence: `app.py`)
- Document Library → RAG Pipeline: lists and deletes (evidence: `app.py`)
- RAG Pipeline → Duplicate Check: checks duplicates (evidence: `src/rag_pipeline.py`)
- Duplicate Check → SQLite Records: looks up hash (evidence: `src/rag_pipeline.py`)
- RAG Pipeline → PDF Extraction: extracts text (evidence: `src/rag_pipeline.py`)
- PDF Extraction → Text Chunking: splits text (evidence: `src/rag_pipeline.py`)
- RAG Pipeline → Local Embeddings: embeds chunks (evidence: `src/rag_pipeline.py`)
- RAG Pipeline → Vector Index: stores chunks (evidence: `src/rag_pipeline.py`)
- RAG Pipeline → SQLite Records: registers documents (evidence: `src/rag_pipeline.py`)
- Chat Orchestrator → RAG Pipeline: searches question (evidence: `app.py`)
- RAG Pipeline → Chunk Retrieval: queries index (evidence: `src/rag_pipeline.py`)
- Chunk Retrieval → Local Embeddings: embeds query (evidence: `src/rag_pipeline.py`)
- Chunk Retrieval → Vector Index: retrieves matches (evidence: `src/rag_pipeline.py`)
- Chat Orchestrator → Groq AI: sends context (evidence: `app.py`)
- Groq AI → Chat Orchestrator: returns answer (evidence: `app.py`)
- Chat Orchestrator → Source References: adds source pages (evidence: `app.py`)
- Chat Orchestrator → Conversation History: saves messages (evidence: `app.py`)
- Conversation History → SQLite Records: reads and writes (evidence: `app.py`)
- Study UI → Chat Orchestrator: accepts questions (evidence: `app.py`)
- Document Library → SQLite Records: loads registry (evidence: `app.py`)
- Conversation History → SQLite Records: loads conversations (evidence: `app.py`)
