# whotto/video_note_generator architecture

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

- Interactive diagram: https://gitdiagram.com/whotto/video_note_generator
- Repository: https://github.com/whotto/video_note_generator

## Overview

- Downloading the video
- Extracting audio from the video using FFmpeg
- Transcribing the audio via Whisper
- Running an AI-based long text reorganization (using OpenRouter) to optimize content in a targeted Xiaohongshu style
- Generating output files in three different formats (raw transcription, organized note, and a fully optimized Xiaohongshu note with title, content, tags, and images retrieved from Unsplash)

##### And Label Core Components
a. Input Handler:
– Accepts different forms of input (URL, list file, Markdown).
b. Video Download & Processing Module:
– Uses FFmpeg to download the video and extract audio.
c. Transcription Module:
– Integrates Whisper for converting audio to text.
d. AI Content Optimization Module:
– Uses an AI service (OpenRouter) to reorganize and optimize the transcribed text into a long-form note.
e. Generation Module:
– Handles creation of the three output files: original transcription, organized note, and the tailored Xiaohongshu note (with title, optimized text, tags, and image references via Unsplash).
f. Environment & Configuration Manager:
– Uses the .env file to load API keys and other configuration parameters.
g. Utility Scripts:
– A script for checking the system environment (check_environment.py).

##### Component Interactions and Data Flow
c. Next, the extracted audio flows to the “Transcription Module” (Whisper integration), converting audio into raw text.
d. The raw text then flows into the “AI Content Optimization Module” that applies longer text organization and Xiaohongshu style rules.
e. From there, the transformation pipeline converges in the “Note Generation Module”, which produces three separate output files.
f. The “Environment & Configuration Manager” supplies necessary API keys (for OpenRouter and Unsplash) and parameters (like tokens, temperature) to relevant modules.

##### Architectural Patterns or Design Principles
– There is a clear separation of concerns where each module is responsible for one stage of the processing pipeline.
– Consider indicating modular interactions which could allow for independent updates to video downloading, transcription, or AI optimization without overall system disruption.

##### Technologies and Frameworks
– Note the use of Python for scripting and orchestration.
– List external utilities/services: FFmpeg for media processing, Whisper for transcription, OpenRouter for AI content processing, and Unsplash for image retrieval.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main CLI Tool Process
    subgraph "CLI Tool Process"
        Input["Input Handler"]:::module
        VideoProcessing["Video Download & Audio Extraction Module"]:::module
        Transcription["Transcription Module (Whisper)"]:::module
        AIOptimization["AI Content Optimization Module (OpenRouter)"]:::module
        NoteGeneration["Note Generation Module"]:::module
    end

    %% Supporting Utilities and Configuration
    Utility["Environment Checker (check_environment.py)"]:::utility
    Config["Environment & Configuration Manager (.env)"]:::config

    %% External Services
    FFmpeg["FFmpeg"]:::external
    WhisperService["Whisper"]:::external
    OpenRouterService["OpenRouter"]:::external
    Unsplash["Unsplash"]:::external

    %% Data Flow
    Input -->|"triggers"| VideoProcessing
    VideoProcessing -->|"extracts audio"| Transcription
    Transcription -->|"produces raw text"| AIOptimization
    AIOptimization -->|"outputs optimized content"| NoteGeneration

    %% Configuration Influence
    Config -.->|"provides API keys to"| AIOptimization
    Config -.->|"provides API keys to"| NoteGeneration

    %% Utility Check
    Utility ---|"verifies system environment"| Input

    %% External Tools Integration
    VideoProcessing -->|"uses"| FFmpeg
    Transcription -->|"invokes"| WhisperService
    AIOptimization -->|"calls"| OpenRouterService
    NoteGeneration -->|"retrieves images from"| Unsplash

    %% Click Events
    click Input "https://github.com/whotto/video_note_generator/blob/main/video_note_generator.py"
    click VideoProcessing "https://github.com/whotto/video_note_generator/blob/main/video_note_generator.py"
    click Transcription "https://github.com/whotto/video_note_generator/blob/main/video_note_generator.py"
    click AIOptimization "https://github.com/whotto/video_note_generator/blob/main/video_note_generator.py"
    click NoteGeneration "https://github.com/whotto/video_note_generator/blob/main/video_note_generator.py"
    click Config "https://github.com/whotto/video_note_generator/blob/main/.env.example"
    click Utility "https://github.com/whotto/video_note_generator/blob/main/check_environment.py"

    %% Styles
    classDef module fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px,stroke-dasharray: 5 5;
    classDef utility fill:#C8F7C5,stroke:#196F3D,stroke-width:2px;
    classDef config fill:#F5CBA7,stroke:#784212,stroke-width:2px;
```
