# ayushsaini9156/studypal architecture

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

- Interactive diagram: https://gitdiagram.com/ayushsaini9156/studypal
- Repository: https://github.com/ayushsaini9156/studypal

## Overview

Studypal is a Python-based, document-centric assistant built around Class 12 Biology study material. The repository is organized more like a content ingestion + retrieval system than a general web app.

1. **Primary purpose**
   The core function appears to be turning biology PDFs into a searchable knowledge base for question answering or chatbot-style study help.

2. **Source content boundary**
   The repository keeps the original source corpus in `data_original/class_12/biology/` and a smaller working set in `data/class_12/biology/`. This separation suggests a raw-vs-processed split, where the original PDFs are preserved and the `data/` tree is used for curated or transformed inputs.

3. **Document ingestion layer**
   `src/vectorize_book.py` is the main signal for PDF-to-index processing. It likely extracts text from biology books, chunks content, and prepares embeddings or other searchable representations.

4. **Additional ingestion path**
   `src/vectorize_scripts.py` indicates a second vectorization path for non-book content, likely scripts or transcript-like text sources. This suggests the system can ingest more than just PDFs.

5. **External media acquisition**
   `src/get_yt_video.py` points to YouTube as an external content source. Architecturally, this is a separate utility that likely downloads or prepares video-derived study material before it enters the same vectorization pipeline.

6. **Runtime application**
   `src/main.py` is the execution entry point. It likely loads the prepared knowledge base, accepts user queries, and routes them through retrieval plus response generation.

7. **Shared chatbot logic**
   `src/chatbot_utility.py` likely holds reusable functions for prompt construction, retrieval formatting, conversation state, or response post-processing. This is the main shared boundary between ingestion artifacts and the interactive assistant.

8. **Configuration and environment**
   `src/env_template` suggests the application relies on environment variables for runtime configuration, likely including model/provider credentials or paths to persisted artifacts. `requirements.txt` defines the Python dependency set that supports PDF handling, embedding/vectorization, and chatbot runtime behavior.

9. **Offline vs online split**
   The architecture has a clear two-stage flow:
   - **Offline batch processing**: PDFs or other media are ingested, transformed, and vectorized.
   - **Online query time**: `main.py` uses the prebuilt index to answer questions interactively.
   This is the main boundary to show in a diagram.

10. **Data flow summary**
   Raw study material enters from `data_original/` or external sources like YouTube, is normalized into `data/` or intermediate text, then passed through vectorization scripts, and finally consumed by the main chatbot runtime.

11. **What is not present**
   There is no sign of a separate database service, frontend application, or microservice layout. The repository looks like a compact Python monolith with utility scripts, data assets, and a runtime entry point.

12. **Best diagram framing**
   Draw three boxes: **content sources** (`data_original`, YouTube), **processing/indexing utilities** (`vectorize_book.py`, `vectorize_scripts.py`, `get_yt_video.py`), and **assistant runtime** (`main.py` + `chatbot_utility.py`). The key artifact flowing between them is the processed vector/index representation of the biology corpus.

Main entry points: [`src/vectorize_book.py`](https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_book.py) (Book vectorizer), [`src/vectorize_scripts.py`](https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_scripts.py) (Script vectorizer), [`src/main.py`](https://github.com/ayushsaini9156/studypal/blob/main/src/main.py) (Main app), [`requirements.txt`](https://github.com/ayushsaini9156/studypal/blob/main/requirements.txt) (Dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sources["Content sources"]
  node_data_original_bio[("Raw biology PDFs<br/>source corpus")]
  node_data_bio[("Working biology PDFs<br/>curated corpus")]
  node_yt_source(("YouTube input<br/>external source<br/>[get_yt_video.py]"))
end

subgraph group_processing["Ingestion pipeline"]
  node_vectorize_book["Book vectorizer<br/>pdf ingestion<br/>[vectorize_book.py]"]
  node_vectorize_scripts["Script vectorizer<br/>text ingestion"]
  node_get_yt_video["Video fetcher<br/>media acquisition<br/>[get_yt_video.py]"]
  node_index_artifact[("Vector index<br/>retrieval artifact")]
end

subgraph group_runtime["Assistant runtime"]
  node_main_runtime["Main app<br/>query entrypoint<br/>[main.py]"]
  node_chatbot_utility["Chatbot utils<br/>shared logic<br/>[chatbot_utility.py]"]
  node_env_template["Env template<br/>config template"]
  node_requirements["Dependencies<br/>python deps<br/>[requirements.txt]"]
end

subgraph group_data["Corpus storage"]
  node_biology_corpus[("Biology corpus<br/>study content")]
end

node_data_original_bio -->|"source PDFs"| node_vectorize_book
node_data_bio -->|"working PDFs"| node_vectorize_book
node_yt_source -->|"fetch"| node_get_yt_video
node_get_yt_video -->|"transcript/text"| node_vectorize_scripts
node_vectorize_book -->|"build index"| node_index_artifact
node_vectorize_scripts -->|"build index"| node_index_artifact
node_index_artifact -->|"retrieve"| node_main_runtime
node_chatbot_utility -->|"shared helpers"| node_main_runtime
node_env_template -->|"configure"| node_main_runtime
node_requirements -.->|"supports"| node_vectorize_book
node_requirements -.->|"supports"| node_vectorize_scripts
node_requirements -.->|"supports"| node_main_runtime
node_biology_corpus -.->|"stored as"| node_data_original_bio
node_biology_corpus -.->|"curated as"| node_data_bio
node_vectorize_book -.->|"formats context"| node_chatbot_utility
node_vectorize_scripts -.->|"formats context"| node_chatbot_utility

click node_data_original_bio "https://github.com/ayushsaini9156/studypal/tree/main/data_original/class_12/biology"
click node_data_bio "https://github.com/ayushsaini9156/studypal/tree/main/data/class_12/biology"
click node_yt_source "https://github.com/ayushsaini9156/studypal/blob/main/src/get_yt_video.py"
click node_vectorize_book "https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_book.py"
click node_vectorize_scripts "https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_scripts.py"
click node_get_yt_video "https://github.com/ayushsaini9156/studypal/blob/main/src/get_yt_video.py"
click node_main_runtime "https://github.com/ayushsaini9156/studypal/blob/main/src/main.py"
click node_chatbot_utility "https://github.com/ayushsaini9156/studypal/blob/main/src/chatbot_utility.py"
click node_env_template "https://github.com/ayushsaini9156/studypal/tree/main/src/env_template"
click node_requirements "https://github.com/ayushsaini9156/studypal/blob/main/requirements.txt"

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_data_original_bio,node_data_bio,node_yt_source toneBlue
class node_vectorize_book,node_vectorize_scripts,node_get_yt_video,node_index_artifact toneAmber
class node_main_runtime,node_chatbot_utility,node_env_template,node_requirements toneMint
class node_biology_corpus toneRose
```

## Components

### Content sources

Raw and curated study material inputs.

- [Raw biology PDFs](https://github.com/ayushsaini9156/studypal/tree/main/data_original/class_12/biology): source corpus · Preserved original Class 12 Biology PDFs. · `data_original/class_12/biology`
- [Working biology PDFs](https://github.com/ayushsaini9156/studypal/tree/main/data/class_12/biology): curated corpus · Smaller working set used for processing and experimentation. · `data/class_12/biology`
- [YouTube input](https://github.com/ayushsaini9156/studypal/blob/main/src/get_yt_video.py): external source · Video-based study material acquired from YouTube. · `src/get_yt_video.py`

### Ingestion pipeline

Utilities that extract, normalize, and vectorize content.

- [Book vectorizer](https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_book.py): pdf ingestion · Extracts and chunks biology PDFs for indexing. · `src/vectorize_book.py`
- [Script vectorizer](https://github.com/ayushsaini9156/studypal/blob/main/src/vectorize_scripts.py): text ingestion · Processes non-book or script-like study content into the same retrieval format. · `src/vectorize_scripts.py`
- [Video fetcher](https://github.com/ayushsaini9156/studypal/blob/main/src/get_yt_video.py): media acquisition · Downloads or prepares YouTube-derived material before ingestion. · `src/get_yt_video.py`
- **Vector index**: retrieval artifact · Persisted embeddings or searchable knowledge base built from study material.

### Assistant runtime

Interactive query-time components.

- [Main app](https://github.com/ayushsaini9156/studypal/blob/main/src/main.py): query entrypoint · Runs the interactive assistant and handles user queries. · `src/main.py`
- [Chatbot utils](https://github.com/ayushsaini9156/studypal/blob/main/src/chatbot_utility.py): shared logic · Common retrieval, prompt, and response helpers used by the runtime. · `src/chatbot_utility.py`
- [Env template](https://github.com/ayushsaini9156/studypal/tree/main/src/env_template): config template · Environment variable template for runtime configuration. · `src/env_template`
- [Dependencies](https://github.com/ayushsaini9156/studypal/blob/main/requirements.txt): python deps · Python packages supporting extraction, vectorization, and chat runtime. · `requirements.txt`

### Corpus storage

Raw and working biology document sets.

- **Biology corpus**: study content · Class 12 Biology document set as the primary domain corpus.

## Connections

- Raw biology PDFs → Book vectorizer: source PDFs · Original PDFs are the main input to book ingestion.
- Working biology PDFs → Book vectorizer: working PDFs · Curated PDFs may also feed the same vectorization path.
- YouTube input → Video fetcher: fetch · External video content is acquired before processing.
- Video fetcher → Script vectorizer: transcript/text · Downloaded video-derived text enters the script ingestion path.
- Book vectorizer → Vector index: build index · Book ingestion produces searchable vectors or chunks.
- Script vectorizer → Vector index: build index · Script ingestion contributes to the same retrieval artifact.
- Vector index → Main app: retrieve · The runtime loads the prebuilt knowledge base at query time.
- Chatbot utils → Main app: shared helpers · Reusable chat and retrieval logic supports the main app.
- Env template → Main app: configure · Environment settings control runtime behavior and paths.
- Dependencies → Book vectorizer: supports · Dependencies enable PDF extraction and embedding work.
- Dependencies → Script vectorizer: supports · Dependencies also support script and media processing.
- Dependencies → Main app: supports · Runtime dependencies power the assistant entrypoint.
- Biology corpus → Raw biology PDFs: stored as · The primary biology corpus is preserved in the raw data tree.
- Biology corpus → Working biology PDFs: curated as · A smaller working subset is kept for processing.
- Book vectorizer → Chatbot utils: formats context · Ingestion output is shaped for downstream retrieval and prompt assembly.
- Script vectorizer → Chatbot utils: formats context · Script-derived content is normalized for the assistant pipeline.
