# saitejasrivilli/youtube-transcript-query-tool architecture

> Architecture diagram of the GitHub repository saitejasrivilli/youtube-transcript-query-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saitejasrivilli/youtube-transcript-query-tool
- Repository: https://github.com/saitejasrivilli/youtube-transcript-query-tool

## Overview

##### Main Components
- User Interface & Application Server:
- The Streamlit-based front end serves as both the UI and the entry point for user requests (e.g., entering a YouTube URL and specifying a query task). This is implemented in the file (app.py) which orchestrates the overall workflow.
- YouTube Transcript Fetcher:
- This component interacts with the YouTube Transcript API to fetch the transcript of a given video.
- Transcript Chunking Module:
- A logical layer within the application that handles splitting the full transcript into manageable chunks, especially considering GPT-3.5’s token limitations.
- Pinecone Storage Service:
- Acts as the vector database where the processed (chunked) transcript data is stored for efficient retrieval and similarity searches.
- Query & Summarization Engine:
- Utilizes OpenAI GPT-3.5 to process the stored transcript chunks when a query or summarization request is made.

##### Relationships and Interactions
- The user interacts with the Streamlit UI from their web browser.
- When a YouTube URL is submitted, the application first fetches the transcript using the YouTube Transcript API.
- The fetched transcript is then passed to the chunking module; after processing, these chunks are stored in Pinecone.
- Upon receiving a user query (i.e., “Summarize the video” or similar task), the system retrieves the relevant transcript chunks from Pinecone and sends these, along with the query, to the OpenAI GPT-3.5 API.
- The response generated by GPT-3.5 is then displayed back to the user via the Streamlit UI.

##### Architectural Patterns & Design Principles
- The System Follows a Modular Architecture: each functionality (fetching, chunking, storing, querying) is handled as a separate logical component.
- Service-Oriented Integration: external APIs (YouTube, Pinecone, OpenAI GPT-3.5) are integrated as services.
- Separation of Concerns: the UI (user interactions via Streamlit) is clearly separated from data processing and storage.
- Lightweight, Single-Page App: given that the entire codebase is encapsulated in a few files, the design should emphasize clarity in data flow over overly complex inter-module interactions.

##### Relevant Technologies
- Streamlit – for building the interactive web user interface.
- OpenAI GPT-3.5 API – for natural language processing tasks.
- Pinecone – for scalable vector storage and similarity search.
- YouTube Transcript API – for fetching video transcripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Side"
        Browser["User's Browser"]:::external
    end

    subgraph "Streamlit Application"
        UI["User Interface (Streamlit Frontend)"]:::ui
    end

    subgraph "Processing Components"
        FETCH["YouTube Transcript Fetcher"]:::service
        CHUNK["Transcript Chunking Module"]:::service
        PINE["Pinecone Vector Database"]:::database
        GPT["Query & Summarization Engine (GPT-3.5)"]:::api
    end

    Browser -->|"requests"| UI
    UI -->|"FetchTranscript"| FETCH
    FETCH -->|"ProcessTranscript"| CHUNK
    CHUNK -->|"StoreChunks"| PINE
    UI -->|"SubmitQuery"| GPT
    PINE -->|"RetrieveChunks"| GPT
    GPT -->|"SendResponse"| UI

    click UI "https://github.com/saitejasrivilli/youtube-transcript-query-tool/blob/main/app.py"
    click FETCH "https://github.com/saitejasrivilli/youtube-transcript-query-tool/blob/main/app.py"
    click CHUNK "https://github.com/saitejasrivilli/youtube-transcript-query-tool/blob/main/app.py"
    click PINE "https://github.com/saitejasrivilli/youtube-transcript-query-tool/blob/main/app.py"
    click GPT "https://github.com/saitejasrivilli/youtube-transcript-query-tool/blob/main/app.py"

    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef service fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef database fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef api fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
```
