# heliomarpm/udemy-downloader-gui architecture

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

- Interactive diagram: https://gitdiagram.com/heliomarpm/udemy-downloader-gui
- Repository: https://github.com/heliomarpm/udemy-downloader-gui

## Overview

##### Project Type and Purpose
- This is a cross-platform desktop application built with Electron and Node.js, serving as a GUI tool to download your purchased Udemy courses.
- It combines a Chromium-based renderer (the UI) with a Node.js main process to handle file I/O, HTTP requests, and packaging.

##### File Structure Analysis
- Top-level files:
– main.js: Electron’s main process entry point—initializes windows, IPC, auto-updater.
– preload.js: Exposes safe, limited Node.js APIs to the renderer via contextBridge.
– environments.js & .env.example: Configuration loader for environment variables (Udemy credentials, timeouts, directories).
- app/: Contains the renderer application:
– app/index.html, app/assets, app/css: UI layout and styling (Semantic UI).
– app/locale: JSON files for internationalization.
– app/renderer.js: Renderer startup script, initializes UI event listeners and IPC calls to the main process.
- app/core/services/: Business-logic modules that perform HTTP calls to Udemy’s API (udemy.service.js) and handle M3U8 stream parsing/downloads (m3u8.service.js).
- app/helpers/: Utility modules (auto_authenticator.js, settings.js, ui.js, utils.js) for session management, UI helpers, local settings, and generic functions.
- sync-locales.js: Script to synchronize locale files.
- Package & CI: package.json, package-lock.json, GitHub workflows for CodeQL, publishing with electron-builder.

##### README Insights
- Confirms Electron + Node.js stack, uses semantic-ui for the front end.
- Describes usage (npm start, npm run dev), packaging (npm run deploy).
- Mentions auto-updates via electron-builder and GitHub releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Renderer Layer
    subgraph "Renderer Layer"
        direction TB
        RHTML["app/index.html"]:::frontend
        RJS["app/renderer.js"]:::frontend
        AJS["app/app.js"]:::frontend
        Assets["app/assets/semantic-ui"]:::frontend
        CSS["app/css/style.css"]:::frontend
    end

    %% Preload
    Preload["Preload Script (contextBridge API)"]:::electron

    %% Main Process
    Main["Electron Main Process (main.js)"]:::electron

    %% Configuration
    subgraph "Configuration"
        direction TB
        EnvLoader["environments.js"]:::config
        EnvExample[".env.example"]:::config
    end

    %% Core Services
    subgraph "Core Services Layer"
        direction TB
        SIndex["app/core/services/index.js"]:::service
        UdemyService["app/core/services/udemy.service.js"]:::service
        M3U8Service["app/core/services/m3u8.service.js"]:::service
    end

    %% Helpers
    subgraph "Helpers Layer"
        direction TB
        HelpersIndex["app/helpers/index.js"]:::service
        Auth["app/helpers/auto_authenticator.js"]:::service
        Settings["app/helpers/settings.js"]:::service
        UIHelpers["app/helpers/ui.js"]:::service
        Utils["app/helpers/utils.js"]:::service
    end

    %% File System
    FS["File System (Downloads)"]:::storage

    %% Internationalization
    subgraph "Internationalization"
        direction TB
        Locales["app/locale/*.json"]:::config
        SyncLocales["sync-locales.js"]:::config
    end

    %% Package & CI/CD
    subgraph "Package & CI/CD"
        direction TB
        PKG["package.json\npackage-lock.json"]:::config
        Workflows[".github/workflows/codeql-analysis.yml\n.github/workflows/publish.yml"]:::config
    end

    %% External Services
    UdemyAPI["Udemy REST API"]:::external
    M3U8Servers["M3U8 Media Servers"]:::external
    GitHubReleases["GitHub Releases (Auto-Update Feed)"]:::external

    %% Connections
    RHTML -->|loads| Preload
    RJS -->|calls IPC| Preload
    AJS -->|uses UI| RJS
    Assets -->|styles| RHTML
    CSS -->|styles| RHTML

    Preload -->|exposes API| Main

    Main -->|loads config| EnvLoader
    EnvLoader -->|reads| EnvExample

    Main -->|calls| SIndex
    SIndex -->|imports| UdemyService
    SIndex -->|imports| M3U8Service

    Main -->|calls| Auth
    Main -->|calls| Settings
    Main -->|calls| UIHelpers
    Main -->|calls| Utils

    UdemyService -->|HTTP| UdemyAPI
    M3U8Service -->|download TS| M3U8Servers

    Main -->|writes files| FS

    Main -->|checks updates| GitHubReleases
    GitHubReleases -->|delivers installers| Main

    Main -->|syncs locales| SyncLocales
    SyncLocales -->|updates| Locales

    Main -->|publishes| PKG
    PKG -->|CI runs| Workflows

    %% Click Events
    click RHTML "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/index.html"
    click RJS "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/renderer.js"
    click AJS "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/app.js"
    click Assets "https://github.com/heliomarpm/udemy-downloader-gui/tree/master/app/assets/semantic-ui"
    click CSS "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/css/style.css"
    click Preload "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/preload.js"
    click Main "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/main.js"
    click EnvLoader "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/environments.js"
    click EnvExample "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/.env.example"
    click SIndex "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/core/services/index.js"
    click UdemyService "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/core/services/udemy.service.js"
    click M3U8Service "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/core/services/m3u8.service.js"
    click HelpersIndex "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/helpers/index.js"
    click Auth "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/helpers/auto_authenticator.js"
    click Settings "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/helpers/settings.js"
    click UIHelpers "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/helpers/ui.js"
    click Utils "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/helpers/utils.js"
    click Locales "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/app/locale/*.json"
    click SyncLocales "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/sync-locales.js"
    click PKG "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/package.json"
    click PKG "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/package-lock.json"
    click Workflows "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/.github/workflows/codeql-analysis.yml"
    click Workflows "https://github.com/heliomarpm/udemy-downloader-gui/blob/master/.github/workflows/publish.yml"

    %% Styles
    classDef electron fill:#D0E8FF,stroke:#005B9F,color:#000;
    classDef frontend fill:#E8F4D0,stroke:#7B8B00,color:#000;
    classDef service fill:#DFF0D8,stroke:#3C763D,color:#000;
    classDef external fill:#FFE0B2,stroke:#E65100,color:#000;
    classDef config fill:#F5F5F5,stroke:#AAA,color:#000;
    classDef storage fill:#E0E0E0,stroke:#616161,color:#000;
```
