# besuper/twitchnosub architecture

> Architecture diagram of the GitHub repository besuper/twitchnosub, 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/besuper/twitchnosub
- Repository: https://github.com/besuper/twitchnosub

## Overview

##### Main Components
- Extension Core: Identify the common logic that is used regardless of the browser. This is mostly found in files like src/app.js and perhaps shared scripts like src/twitchnosub.js.
- Browser-Specific Components:
– Chrome Component: Under src/chrome, you have chrome/app.js (and a corresponding manifest.json file in the root for Chrome).
– Firefox Component: Under src/firefox, which includes firefox/app.js and additional Firefox-specific files (e.g., twitchnosub.js, patch files).
- Userscript Component: Located in userscript/twitchnosub.user.js indicates an alternative injection method outside of the traditional extension framework.
- Tooling/Patching Functionality: There’s a tools directory (with tools/patch.js) and a script (src/patch_amazonworker.js) that hints at some dynamic adjustments or fixes possibly related to external worker scripts.

##### Relationships and Interactions
- The core extension logic (src/app.js and shared files) provides general functionality, whereas the browser-specific folders (src/chrome and src/firefox) adapt this logic with APIs and browser-specific customization.
- The manifest files (manifest.json and firefox-manifest.json) are key configuration files driving the extension behavior in each environment.
- The userscript version offers a lightweight alternative, perhaps for injecting functionality directly onto pages.
- Tools and patch files suggest that some pre-deployment processing or runtime patching is involved.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly segments common logic from browser-specific implementations.
- Modular Design: Each browser has its dedicated folder, and the existence of a tools directory suggests that any build or patching operations are handled in isolation.
- Multi-Platform Support: The architecture is purposefully created to handle differences between Chromium-based browsers and Firefox while sharing a base functionality.

##### Relevant Technologies/Frameworks
- JavaScript is the core language used.
- Browser Extension APIs (evident from the manifest and the designated directories for Chrome and Firefox).
- Build/patch tools captured under the tools folder, which might use Node.js or a similar runtime (as indicated by package.json).
- The file tree shows a .github folder, indicating that GitHub workflows or issue templates might also be a part of this project’s overall ecosystem for development and collaboration.

## Diagram (Mermaid)

```mermaid
graph TD
    Ext["TwitchNoSub Extension"]:::extension

    subgraph "Core Logic"
        Core1["src/app.js (Core Logic)"]:::core
        Core2["src/twitchnosub.js (Shared Script)"]:::core
    end

    subgraph "Browser-Specific Components"
        subgraph "Chrome Extension"
            Chrome1["src/chrome/app.js (Chrome Logic)"]:::chrome
            Chrome2["manifest.json (Chrome Manifest)"]:::chrome
        end
        subgraph "Firefox Extension"
            Fx1["src/firefox/app.js (Firefox Logic)"]:::firefox
            Fx2["src/firefox/twitchnosub.js (Firefox Shared Script)"]:::firefox
            Fx3["firefox-manifest.json (Firefox Manifest)"]:::firefox
            Fx4["src/patch_amazonworker.js (Worker Patch)"]:::firefox
        end
    end

    subgraph "Alternative Delivery"
        Userscript["userscript/twitchnosub.user.js (Userscript)"]:::userscript
    end

    subgraph "Tooling & Patching"
        Tooling["tools/patch.js (Patching Tool)"]:::tooling
    end

    Ext -->|"includes"| Core1
    Ext -->|"includes"| Core2
    Ext -->|"extends"| Chrome1
    Ext -->|"configures"| Chrome2
    Ext -->|"extends"| Fx1
    Ext -->|"extends"| Fx2
    Ext -->|"configures"| Fx3
    Ext -->|"patches"| Fx4
    Ext -->|"alternative"| Userscript
    Ext -->|"prepares"| Tooling

    Core1 -->|"provides_base"| Chrome1
    Core1 -->|"provides_base"| Fx1
    Core1 -->|"provides_base"| Userscript

    Tooling -->|"applies_patch"| Core2
    Tooling -->|"applies_patch"| Fx4

    classDef extension fill:#f9e79f,stroke:#b9770e,stroke-width:2px,color:#000;
    classDef core fill:#aed6f1,stroke:#1f618d,stroke-width:2px,color:#000;
    classDef chrome fill:#f5b7b1,stroke:#c0392b,stroke-width:2px,color:#000;
    classDef firefox fill:#abebc6,stroke:#239b56,stroke-width:2px,color:#000;
    classDef userscript fill:#fcf3cf,stroke:#d4ac0d,stroke-width:2px,color:#000;
    classDef tooling fill:#d2b4de,stroke:#8e44ad,stroke-width:2px,color:#000;

    click Core1 "https://github.com/besuper/twitchnosub/blob/master/src/app.js"
    click Core2 "https://github.com/besuper/twitchnosub/blob/master/src/twitchnosub.js"
    click Chrome1 "https://github.com/besuper/twitchnosub/blob/master/src/chrome/app.js"
    click Chrome2 "https://github.com/besuper/twitchnosub/blob/master/manifest.json"
    click Fx1 "https://github.com/besuper/twitchnosub/blob/master/src/firefox/app.js"
    click Fx2 "https://github.com/besuper/twitchnosub/blob/master/src/firefox/twitchnosub.js"
    click Fx3 "https://github.com/besuper/twitchnosub/blob/master/firefox-manifest.json"
    click Fx4 "https://github.com/besuper/twitchnosub/blob/master/src/patch_amazonworker.js"
    click Userscript "https://github.com/besuper/twitchnosub/blob/master/userscript/twitchnosub.user.js"
    click Tooling "https://github.com/besuper/twitchnosub/blob/master/tools/patch.js"
```
