# ohmcodes/ext.udemydownloader architecture

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

- Interactive diagram: https://gitdiagram.com/ohmcodes/ext.udemydownloader
- Repository: https://github.com/ohmcodes/ext.udemydownloader

## Overview

##### Project type and purpose
- This is a browser extension (Chrome/Chromium) whose sole purpose is to download Udemy course videos.
- There is no standalone backend—instead, it consists of UI assets (HTML/CSS), extension scripts (background, popup, window), and third-party JS/CSS plugins for rendering data.

##### File structure
Top level:
- manifest.json – extension metadata, permissions, entry points
- background.js – the persistent background script for long-lived tasks and messaging
- createWindow.js – helper to open a custom browser window for downloads
- Plugins/… – a directory of DataTables, Bootstrap, Buttons, Responsive, Scroller, RowGroup, RowReorder, etc., used to build a rich table UI inside the popup or window
- UdemyDownloader.crx – packaged extension (output)
- virustotal.com hashes.txt – external reference file for security hashes

##### README
- Confirms it’s a simple “load unpacked” extension.
- No deep architectural notes beyond “Download Udemy Courses Video using browser Extension.”

##### Main components & interactions
a. Components
1. Browser Environment
2. Extension Manifest
3. Background Script (background.js)
4. Popup UI (popup.html + custom.css + Plugins CSS/JS)
5. Window Creator (createWindow.js)
6. Third-party Plugins Directory (DataTables + Bootstrap + related plugins)
7. External System: Udemy Website (content scripts may inject or request data)

b. Relationships & data flow
2. Popup UI initializes DataTables (using Plugins/*) to show course sections/lectures
3. Popup UI sends messages (chrome.runtime.sendMessage) to Background Script
4. Background Script injects or communicates with content script (implicitly via createWindow.js or directly) to scrape Udemy page for video URLs
5. Background Script receives scraped URLs → passes back to Popup or opens a new window via createWindow.js
6. createWindow.js renders a standalone window with a DataTable of video links, allowing the user to click and download
7. Browser download manager handles video file retrieval

c. Architectural patterns & design principles
- Chrome Extension MVC:
- Model: background.js holds scraped URLs & state
- View: popup.html and the separate window created by createWindow.js
- Controller: message passing between popup and background scripts
- Modular plugin-based UI: Plugins folder serves as a UI component library (Bootstrap + DataTables + extensions)

d. Key technologies & libraries
- Chrome Extensions API (manifest v2/v3 fields)
- JavaScript messaging (chrome.runtime.sendMessage, chrome.tabs.executeScript)
- DataTables (+ Buttons, Responsive, RowGroup, RowReorder, Scroller plugins)
- Bootstrap 4 CSS for styling
- Standard web technologies: HTML5, CSS3, ES5/ES6 JavaScript

##### Detailed breakdown
- “Popup UI” ↔ “Background Script (background.js)” via chrome.runtime messaging
- “Background Script” → “Udemy Content Script” → “Udemy Website” (scrape video info)
- “Background Script” → “Window Creator (createWindow.js)”

- Accurately reflects the Chrome extension’s architecture
- Distinguishes persistent vs transient components
- Shows data flow from user action to video download
- Highlights the role of third-party UI libraries in the overall design

## Diagram (Mermaid)

```mermaid
graph TB
    User["User"]:::external

    subgraph "Browser Host"
        subgraph "Extension Core"
            Manifest["Extension Manifest\n(manifest.json)"]:::core
            Background["Background Script\n(background.js)"]:::core
            WindowCreator["Window Creator\n(createWindow.js)"]:::core
        end
        subgraph "UI Layer"
            Popup["Popup UI\n(popup.html)"]:::ui
            PopupCSS["Popup Stylesheet\n(css/custom.css)"]:::ui
            WindowUI["Window UI\n(DataTables + Buttons)"]:::ui
            Plugins["Third-Party Plugins Library\n(Plugins/)"]:::ui
        end
    end

    UdemySite["Udemy Website"]:::external
    ContentScript["Udemy Content Script"]:::external
    DownloadManager["Browser Download Manager"]:::external

    User -->|click| Popup
    Popup -->|chrome.runtime.sendMessage| Background
    Background -->|chrome.runtime.sendMessage| Popup
    Popup -->|loads CSS/JS| PopupCSS
    Popup -->|uses| Plugins
    WindowUI -->|uses| Plugins
    Background -->|injects/communicates| ContentScript
    ContentScript -->|scrape video info| UdemySite
    Background -->|open window| WindowCreator
    WindowCreator -->|renders| WindowUI
    WindowUI -->|download request| DownloadManager

    click Manifest "https://github.com/ohmcodes/ext.udemydownloader/blob/main/manifest.json"
    click Background "https://github.com/ohmcodes/ext.udemydownloader/blob/main/background.js"
    click Popup "https://github.com/ohmcodes/ext.udemydownloader/blob/main/popup.html"
    click PopupCSS "https://github.com/ohmcodes/ext.udemydownloader/blob/main/css/custom.css"
    click WindowCreator "https://github.com/ohmcodes/ext.udemydownloader/blob/main/createWindow.js"
    click Plugins "https://github.com/ohmcodes/ext.udemydownloader/tree/main/Plugins/"
    click UdemyDownloader "https://github.com/ohmcodes/ext.udemydownloader/blob/main/UdemyDownloader.crx"
    click README "https://github.com/ohmcodes/ext.udemydownloader/blob/main/README.md"
    click VirusTotal "https://github.com/ohmcodes/ext.udemydownloader/blob/main/virustotal.com hashes.txt"

    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef ui fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
