# siddhiipatell/youtube-lecture-summarizer-microagent architecture

> Architecture diagram of the GitHub repository siddhiipatell/youtube-lecture-summarizer-microagent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siddhiipatell/youtube-lecture-summarizer-microagent
- Repository: https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent

## Overview

##### Project Type & Purpose
- This project is a full-stack, lightweight, AI-powered microagent that converts YouTube lecture content into structured study notes and quiz questions.
- The primary user interaction occurs through a Streamlit frontend, while the business logic happens in modular Python utilities that handle transcript extraction, summarization, quiz generation, and PDF creation.

##### File Structure
- Top-Level Files:
- app.py: Serves as the Streamlit-based frontend interface.
- requirements.txt, README.md: Help with dependency management and documentation.
- Directories:
- utils: Contains modular utilities:
- transcript_utils.py – handles fetching transcripts from YouTube.
- summarizer.py – implements AI summarization logic using an LLM.
- quiz_generator.py – provides AI-based quiz generation.
- pdf_generator.py – converts markdown or structured notes into a PDF.
- llm_utils: Contains code (ollama_api.py) likely providing additional support or wrapping external LLM API calls (e.g., to Ollama or even OpenAI API).

##### Insights from the README
- The README confirms the project’s purpose, tech stack (Streamlit for frontend, Python backend, OpenAI LLM for AI functions, ReportLab for PDF generation, and youtube-transcript-api for transcripts).
- It clearly outlines a modular approach by separating functionalities into distinct utility modules.
- The README also documents the sequence: user inputs the YouTube lecture URL, transcript extraction, summarization, quiz generation, and PDF output.

a. Main components:
- User Interface Component (Streamlit App):
- App.py as the entry point for user interaction.
- Modules/Services:
- Transcript Extraction Module (utils/transcript_utils.py) that fetches and processes YouTube transcript data.
- Summarization Module (utils/summarizer.py) which uses an LLM to convert transcripts into clear lecture notes.
- Quiz Generation Module (utils/quiz_generator.py) that creates quiz questions based on the transcript and summarization.
- PDF Generation Module (utils/pdf_generator.py) that compiles the outputs into a downloadable PDF.
- LLM Utilities Module (llm_utils/*): potentially acts as an integration point to communicate with external language model APIs (like Ollama and/or OpenAI).
- External Services:
- YouTube Transcript API: Used by the transcript extraction module to fetch lecture transcripts.
- LLM APIs: Such as OpenAI and possibly Ollama for summarization and quiz generation.
- ReportLab: Used inside the PDF generation module.

b. Relationships & Interactions:
- The UI component (app.py) serves as the orchestration layer:
- It receives a YouTube lecture URL from the user.
- It invokes the transcript extraction module to fetch the transcript.
- Next, it passes the transcript to the summarization and quiz generation modules.
- Finally, it hands off the summarized notes and quiz data to the PDF generator for exporting.
- User Input → app.py → transcript_utils → summarizer & quiz_generator → pdf_generator.
- The llm_utils module can be shown as a helper/adapter that supports the summarization and quiz generation services by interfacing with external LLM APIs.

c. Architectural Patterns & Design Principles:
- Modular Design: Each utility module focuses on a specific responsibility.
- Separation of Concerns: The UI strictly handles user interaction, delegating logic operations to backend services.
- Extensibility: The use of separate modules (e.g., llm_utils) indicates potential for additional LLM integrations or upgrades.
- Input->Process->Output Pipeline: Clear stages from obtaining the transcript, processing (summarization/quiz), and final output (PDF).

d. Technologies & Libraries:
- Streamlit (for frontend UI).
- Python (backend logic).
- OpenAI LLM (summarization and quiz generation) and potentially Ollama via llm_utils.
- ReportLab (PDF generation).
- youtube-transcript-api (transcript extraction).

##### Elements
- Use clear labels for each component:
- “Streamlit Interface (app.py)”
- “Transcript Service (transcript_utils.py)”
- “Summarization Service (summarizer.py)”
- “Quiz Generation Service (quiz_generator.py)”
- “PDF Generation Service (pdf_generator.py)”
- “LLM Utilities (llm_utils/ollama_api.py)”
- “External APIs (YouTube-transcript-api, OpenAI/Ollama)”
- Data flow from the UI → transcript service → summarization/quiz generation → PDF generation.

##### Final Recommendation
- How each module interacts with one another and with external services.
- Provide annotations or legends to clarify the roles of each component, ensuring that anyone reviewing the architecture can quickly understand the flow of information and dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    USR["User Input"]:::user
    UI["Streamlit Interface (app.py)"]:::frontend
    TRN["Transcript Service (transcript_utils.py)"]:::backend
    SUM["Summarization Service (summarizer.py)"]:::backend
    QUIZ["Quiz Generation Service (quiz_generator.py)"]:::backend
    PDF["PDF Generation Service (pdf_generator.py)"]:::backend
    LLM["LLM Utilities (ollama_api.py)"]:::backend
    YTA["YouTube Transcript API"]:::external
    LLMA["LLM API (OpenAI/Ollama)"]:::external
    RPT["ReportLab (PDF Generation Library)"]:::external

    %% Data flow from user input to UI layer
    USR -->|"submits URL"| UI

    %% UI invokes transcript extraction
    UI -->|"triggers transcript fetch"| TRN

    %% Transcript Service fetches data from external YouTube Transcript API
    TRN -->|"fetches transcript"| YTA

    %% Transcript Service sends transcript to processing modules
    TRN -->|"provides transcript"| SUM
    TRN -->|"provides transcript"| QUIZ

    %% Processing modules call LLM utilities for AI functions
    SUM -->|"calls LLM utilities"| LLM
    QUIZ -->|"calls LLM utilities"| LLM

    %% LLM Utilities communicates with external LLM API
    LLM -->|"integrates with"| LLMA

    %% Both Summarization and Quiz Generation modules contribute to final output
    SUM -->|"sends notes"| PDF
    QUIZ -->|"sends quiz data"| PDF

    %% PDF Generation module uses ReportLab for PDF output
    PDF -->|"generates PDF using"| RPT

    %% Styling classes
    classDef frontend fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef user fill:#FFB6C1,stroke:#FF1493,stroke-width:2px,dasharray: 5,5;

    %% Click Events
    click UI "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/app.py"
    click TRN "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/utils/transcript_utils.py"
    click SUM "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/utils/summarizer.py"
    click QUIZ "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/utils/quiz_generator.py"
    click PDF "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/utils/pdf_generator.py"
    click LLM "https://github.com/siddhiipatell/youtube-lecture-summarizer-microagent/blob/main/llm_utils/ollama_api.py"
```
