# mbramani/obsidian-yt-video-summarizer architecture

> Architecture diagram of the GitHub repository mbramani/obsidian-yt-video-summarizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mbramani/obsidian-yt-video-summarizer
- Repository: https://github.com/mbramani/obsidian-yt-video-summarizer

## Overview

##### Project Type and Purpose
- It is an Obsidian community plugin.
- The core functionality is to summarize YouTube videos by extracting transcripts and using AI (Gemini) to generate structured summaries.
- The plugin integrates with Obsidian (invoked via the command palette or context menu) and connects with YouTube and Gemini’s APIs.

##### Analyzing the File Structure
- Top-level files like manifest.json and README.md denote that this is an Obsidian plugin.
- The src folder contains the TypeScript source code. Notable files include:
- main.ts: likely the plugin entry point initializing commands and settings.
- settings.ts and constants.ts: configuration and constant definitions.
- modals (e.g., youtube-url.ts): handling user input dialogs specifically for collecting the YouTube URL.
- services (gemini.ts, prompt.ts, storage.ts, youtube.ts): encapsulate core business logic for different external and internal functionalities.
- Build and configuration files (esbuild.config.mjs, tsconfig.json, package.json) indicate that the project uses modern JavaScript/TypeScript tooling.
- Assets (demo video) help illustrate the plugin’s UI/UX in action.

##### Components and Their Relationships
- Plugin Core (main.ts)
- Initializes the plugin within Obsidian.
- Registers commands (via Obsidian’s command palette) which users will use to trigger the summary functionality.
- UI Modals (src/modals/*)
- The YouTube URL modal component (youtube-url.ts) gathers the video URL from the user.
- Service Modules:
- YouTube Service (youtube.ts): Handles operations such as fetching video transcripts or validating URLs.
- Gemini Service (gemini.ts): Interfaces with Google Gemini AI for generating summaries.
- Prompt Service (prompt.ts): Prepares the text prompt based on the video transcript that is sent to Gemini AI.
- Storage Service (storage.ts): Manages note creation or metadata storage within Obsidian.
- Configuration & Constants (settings.ts, constants.ts)
- Handle plugin configurations including API keys, selected summary model, and custom prompts.
- External Dependencies:
- Google’s Gemini API for AI summarization.
- YouTube’s data (used in fetching transcripts, thumbnails, etc.).

##### Architectural Patterns and Design Principles
- Modularization: The project follows a modular structure where each service handles a specific responsibility. This separation improves maintainability and potential testing.
- Decoupling: UI (modals, main plugin logic) is clearly separated from service code. This implies that changes in one module (for example, updating the Gemini API integration) have minimal impact on UI components.
- Single Responsibility: Each module (service or modal) is responsible for one aspect of the summarization process.
- Integration Pattern: The plugin acts as a mediator between user interaction (Obsidian commands) and external services (YouTube and Gemini API).

## Diagram (Mermaid)

```mermaid
flowchart TD
    PluginCore["Obsidian Plugin Core"]:::core
    UIModal["UI Modal for YouTube URL Input"]:::ui
    YouTubeService["YouTube Service"]:::service
    PromptService["Prompt Service"]:::service
    GeminiService["Gemini Service"]:::service
    StorageService["Storage Service"]:::service
    Config["Configuration & Constants"]:::config
    YouTubeAPI["YouTube API"]:::external
    GeminiAPI["Gemini AI API"]:::external

    PluginCore -->|"triggers"| UIModal
    PluginCore -->|"loads_config"| Config
    UIModal -->|"sends_URL"| YouTubeService
    YouTubeService -->|"fetches_transcript"| YouTubeAPI
    YouTubeService -->|"passes_transcript"| PromptService
    PromptService -->|"prepares_prompt"| GeminiService
    GeminiService -->|"calls_AI"| GeminiAPI
    GeminiService -->|"sends_summary"| StorageService
    StorageService -->|"creates_note"| PluginCore

    %% Click Events
    click PluginCore "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/manifest.json"
    click PluginCore "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/main.ts"
    click UIModal "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/modals/youtube-url.ts"
    click YouTubeService "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/services/youtube.ts"
    click GeminiService "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/services/gemini.ts"
    click PromptService "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/services/prompt.ts"
    click StorageService "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/services/storage.ts"
    click Config "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/settings.ts"
    click Config "https://github.com/mbramani/obsidian-yt-video-summarizer/blob/main/src/constants.ts"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ui fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
