# emirkabal/better-instagram-videos architecture

> Architecture diagram of the GitHub repository emirkabal/better-instagram-videos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emirkabal/better-instagram-videos
- Repository: https://github.com/emirkabal/better-instagram-videos

## Overview

##### Project Type and Purpose
- This is a browser extension intended to enhance video controls on Instagram (playback, volume, autoskip, and download options).
- The project is built with modern web technologies and uses a tool like Plasmo for extension framework management.
- The extension supports multiple locales, as seen in the assets/_locales directory.

##### File Structure
- Top-Level Directories:
– .github: Contains workflows and CI/CD scripts (e.g., submit.yml) that show how the project is integrated with GitHub actions.
– src: The heart of the project where the application logic is maintained.
- Within src:
– components: Contains reusable UI components (Buttons, ProgressBars, Controller, etc.) that constitute the extension’s interface.
▪ The Controller subfolder organises various UI controls (Download, Volume, Autoskip, etc.) with associated styles.
– modules: Houses specific functionality related to the Instagram integration (modules/instagram with Home, Reels, Stories, etc.) and possibly overarching injection logic (Injector.tsx and IntervalInjector.tsx).
– utils and contents: Provide helper functions and core logic (like main.ts) to coordinate the extension’s operations.
- Other Files:
– plasmo.md implies the use of the Plasmo framework, which is common in building browser extensions.
– package.json, pnpm-lock.yaml, tsconfig.json define the overall development and build environment for the project.

##### Diagramming the Architecture
a. Main Components:
- UI Components:
- Popup UI: Represented by the code in src/popup.
- Controller and Other UI Components: Group all interactive components under src/components/Controller and other components.
- Application Modules:
- Instagram-specific Modules: Show src/modules/instagram, which contains specialized components (e.g., Home, Reels, Stories) that hook into Instagram’s video content.
- Utility Modules: Represent the Injector and IntervalInjector under src/modules that might interface with the DOM or run periodic tasks.
- Assets and Localization:
- Use assets folder to represent localization support (multiple languages) and static images.
- Build/Deployment & Configuration:
- Mention the build process triggered by pnpm scripts (“pnpm run build”), with integration points from GitHub workflows (.github/workflows) and Plasmo configurations.

b. Relationships and Interactions:
- Data Flow:
- Start from the browser’s extension loader, which loads the built artifact from the dist directory.
- Once loaded, the popup and content scripts (e.g., controllers on Instagram pages) interact with the user.
- The components (Buttons, Progress Bars, etc.) in the Controller send and receive data (such as playback state, volume, etc.).
- Modules (especially under modules/instagram) are responsible for interfacing directly with Instagram’s pages, injecting additional controls via the Injector components.
- Communication:
- How the popup UI can dispatch events that change the state in the controller components, possibly through background scripts or direct injection.

c. Architectural Patterns & Design Principles:
- Separation of Concerns: Clearly illustrate the distinction between concerns: UI / presentation (components), business logic (modules, injector), and localization/assets.
- Use of a Framework (Plasmo): Mark any integration points where the Plasmo framework’s abstractions might affect loading or context (e.g., content script injection, lazy-loading of modules).

d. Relevant Technologies/Frameworks:
- React or a similar framework (inferred from the use of .tsx files).
- Plasmo framework for browser extension scaffolding.
- CSS styling for UI components.
- pnpm for package and dependency management.

##### Instructing the Principal Software Engineer
- Clear Labels:
- Visual Differentiation:
- Detail the Roles:
- How the Injector components are responsible for interfacing with Instagram’s DOM and enabling custom behavior.
- How the assets and localization support integrate with the UI to offer multi-language capability.
- Overall Layout:

Final Thought:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Browser Extension Loader
    A["Browser Extension Loader"]:::module

    %% Subgraph: Extension Interface (UI Components and Localization)
    subgraph "Extension Interface"
        B["Popup UI"]:::ui
        C["Controller UI Components"]:::ui
        D["Localization Assets"]:::asset
    end

    %% Subgraph: Instagram Integration (Content Scripts and Modules)
    subgraph "Instagram Integration"
        E["Instagram Modules"]:::module
        F["Injector Module: Injector"]:::module
        G["Injector Module: IntervalInjector"]:::module
        H["Core Logic (Content Scripts)"]:::module
        I["Utility Functions"]:::utility
        J["Instagram Web Page"]:::external
    end

    %% Subgraph: Build & Deployment Infrastructure
    subgraph "Build & Deployment"
        K["Build/Deployment & CI/CD Pipeline"]:::build
        L["Plasmo Framework"]:::build
    end

    %% Relationships and Data Flow
    A -->|"loads"| B
    B -->|"triggers"| C
    C -->|"dispatches_to"| E
    E -->|"uses_injection"| F
    E -->|"uses_injection"| G
    F -->|"injects_into"| J
    G -->|"injects_into"| J
    H -->|"coordinates_with"| E
    H -->|"coordinates_with"| F
    H -->|"coordinates_with"| G
    I -->|"supports"| C
    I -->|"supports"| E
    D -->|"localizes"| B
    D -->|"localizes"| C
    L -->|"framework_for"| B
    L -->|"framework_for"| C
    L -->|"framework_for"| F
    L -->|"framework_for"| G
    K -->|"builds_and_deploys"| A
    K -->|"builds_and_deploys"| C
    K -->|"builds_and_deploys"| E
    K -->|"builds_and_deploys"| F
    K -->|"builds_and_deploys"| G
    K -->|"builds_and_deploys"| H

    %% Click Events for Component Mapping
    click B "https://github.com/emirkabal/better-instagram-videos/tree/master/src/popup"
    click C "https://github.com/emirkabal/better-instagram-videos/tree/master/src/components/Controller"
    click E "https://github.com/emirkabal/better-instagram-videos/tree/master/src/modules/instagram"
    click F "https://github.com/emirkabal/better-instagram-videos/blob/master/src/modules/Injector.tsx"
    click G "https://github.com/emirkabal/better-instagram-videos/blob/master/src/modules/IntervalInjector.tsx"
    click D "https://github.com/emirkabal/better-instagram-videos/tree/master/assets/_locales"
    click K "https://github.com/emirkabal/better-instagram-videos/blob/master/.github/workflows/submit.yml"
    click I "https://github.com/emirkabal/better-instagram-videos/tree/master/src/utils"
    click H "https://github.com/emirkabal/better-instagram-videos/tree/master/src/contents"

    %% Styles
    classDef ui fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef module fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef asset fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef build fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef utility fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef external fill:#c0c0c0,stroke:#333,stroke-width:2px;
```
