# pedrokuper/yt-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/pedrokuper/yt-downloader
- Repository: https://github.com/pedrokuper/yt-downloader

## Overview

##### Project Type and Purpose
- Identified as an Electron application designed to provide a desktop interface.
- The content under src/main/lib/youtube (modules like FfmpegProcessor.js and FileManager.js) hints at features related to handling video processing or YouTube integration.
- The presence of react-like files (App.jsx in the renderer) suggests that the frontend is built using a modern JavaScript framework (likely React) running in the Electron renderer process.
- Build configuration files (electron-builder.yml, electron.vite.config.mjs) further indicate that the app is set up for packaging into desktop applications.

##### Analyzing the File Structure
- The top-level directories such as "src", "build", and "resources" show a clear separation of concerns:
a. "src/main": Contains the main process code (core Electron logic) and libraries. This includes application initialization and modules like "store.js" for state management, and a subfolder "youtube" for video processing functionality (handling FFmpeg and file management).
b. "src/preload": Contains preload scripts responsible for securely bridging the main and renderer processes.
c. "src/renderer": Contains the web-based user interface with an HTML file and a "src" folder that further holds React components, assets, and utility files. The components (e.g., Header, Options, VideoPreview) indicate that the UI is modular and component-based.
- Configuration files like .eslintrc.cjs, tailwind.config.js, and various prettier and eslint configurations show that code quality and style consistency are maintained.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Electron Main Process"
        mainIndex["Main Process: index.js"]:::main
        mainLib["Main Lib Directory"]:::main
        store["Store Management: store.js"]:::main
        youtubeModule["YouTube Module"]:::main
        ffmpeg["FfmpegProcessor.js"]:::youtube
        fileManager["FileManager.js"]:::youtube
        ytIndex["YouTube index.js"]:::youtube
        mainIndex --> mainLib
        mainLib --> store
        mainLib --> youtubeModule
        youtubeModule --> ffmpeg
        youtubeModule --> fileManager
        youtubeModule --> ytIndex
    end

    subgraph "Preload Scripts (IPC Bridge)"
        preload["Preload: index.js"]:::preload
    end

    subgraph "Renderer Process (React UI Components)"
        rendererHtml["Renderer: index.html"]:::renderer
        app["React Component: App.jsx"]:::renderer
        header["React Component: Header.jsx"]:::renderer
        options["React Component: Options.jsx"]:::renderer
        videoPreview["React Component: VideoPreview.jsx"]:::renderer
        rendererHtml --> app
        app --> header
        app --> options
        app --> videoPreview
    end

    subgraph "Build & Packaging"
        buildDir["Build Directory"]:::build
        builder["Configuration: electron-builder.yml"]:::build
        vite["Configuration: electron.vite.config.mjs"]:::build
        buildDir --> builder
        buildDir --> vite
    end

    %% Inter-process Communication
    app -->|"IPC_request"| preload
    preload -->|"IPC_forward"| mainIndex
    mainIndex -->|"IPC_response"| preload
    preload -->|"IPC_reply"| app

    %% Click Events
    click mainIndex "https://github.com/pedrokuper/yt-downloader/blob/main/src/main/index.js"
    click mainLib "https://github.com/pedrokuper/yt-downloader/tree/main/src/main/lib"
    click store "https://github.com/pedrokuper/yt-downloader/blob/main/src/main/lib/store.js"
    click youtubeModule "https://github.com/pedrokuper/yt-downloader/tree/main/src/main/lib/youtube"
    click ffmpeg "https://github.com/pedrokuper/yt-downloader/blob/main/src/main/lib/youtube/FfmpegProcessor.js"
    click fileManager "https://github.com/pedrokuper/yt-downloader/blob/main/src/main/lib/youtube/FileManager.js"
    click ytIndex "https://github.com/pedrokuper/yt-downloader/blob/main/src/main/lib/youtube/index.js"
    click preload "https://github.com/pedrokuper/yt-downloader/blob/main/src/preload/index.js"
    click rendererHtml "https://github.com/pedrokuper/yt-downloader/blob/main/src/renderer/index.html"
    click app "https://github.com/pedrokuper/yt-downloader/blob/main/src/renderer/src/App.jsx"
    click header "https://github.com/pedrokuper/yt-downloader/blob/main/src/renderer/src/components/Header.jsx"
    click options "https://github.com/pedrokuper/yt-downloader/blob/main/src/renderer/src/components/Options.jsx"
    click videoPreview "https://github.com/pedrokuper/yt-downloader/blob/main/src/renderer/src/components/VideoPreview.jsx"
    click buildDir "https://github.com/pedrokuper/yt-downloader/tree/main/build"
    click builder "https://github.com/pedrokuper/yt-downloader/blob/main/electron-builder.yml"
    click vite "https://github.com/pedrokuper/yt-downloader/blob/main/electron.vite.config.mjs"

    %% Styles
    classDef main fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef youtube fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef preload fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef renderer fill:#577590,stroke:#333,stroke-width:2px;
    classDef build fill:#277da1,stroke:#333,stroke-width:2px;
```
