# maxitservice/chatgpt-quick-buttons-for-your-text architecture

> Architecture diagram of the GitHub repository maxitservice/chatgpt-quick-buttons-for-your-text, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maxitservice/chatgpt-quick-buttons-for-your-text
- Repository: https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text

## Overview

##### Main Components
- Extension Core Logic: This includes all the JavaScript files responsible for initializing the extension (init.js, config.js, default-config.json) and handling the prompt injections (buttons.js, buttons-init.js, buttons-injection.js, event-handlers.js).
- User Interface Components:
- Welcome Page: A separate HTML page (welcome.html) with associated style/scripts in the welcome-page-files folder for onboarding.
- External Resources and Assets: This is seen in the Promo directory (images, videos, text files) which provide promotional assets and media used in the extension.
- Manifest and Configuration: The manifest.json file defines the extension entry points, permissions, and other registration details along with configuration files.
- Utility and Support Modules: Additional JavaScript utilities (e.g., utils.js, log.js) that support the overall application logic.

##### Relationships and Data Flow
- The manifest.json file is the starting point: it loads the extension’s assets and scripts.
- The core logic (init.js, buttons.js, event-handlers.js) ties the user interface actions (like button clicks) to the underlying functionality, updating the prompt profiles and interacting with browser storage.
- Utility modules (utils.js and log.js) are used across the components to handle common tasks (such as logging events, handling errors, and shared configuration management).
- The welcome page (welcome.html) offers first-run guidance and uses its own minimal set of UI assets.
- Data related to user settings and customizations are stored locally (using browser’s sync storage as mentioned in the README) and interact with the configuration files.

##### Architectural Patterns and Design Principles
- Modular Design: The project clearly separates concerns with different folders for popup scripts/styles, core logic, and promotional assets.
- Loose Coupling: Components like the popup UI, welcome page, and core logic modules interact through well-defined interfaces and utility functions.
- Inversion of Control: The use of configuration files (default-config.json, config.js) allows the system behavior to be driven by configuration rather than hard-coded parameters.
- Event-Driven Interactions: Event-handlers are central to capturing user interactions (like clicks) and then triggering the prompt insertion logic.

##### Regarding Relevant Technologies and Frameworks
- Core JavaScript is used along with CSS for styling.
- The design has clear separation between content scripts (that interact with AI chat pages) and the extension’s own UIs (popup.html, welcome.html).
- The use of manifest.json indicates adherence to the Chrome Extension API guidelines.

##### Specific Elements
- Popup Interface (popup.html + popup-page-scripts & popup-page-styles)
- Welcome Page (welcome.html and its related assets)
- Core Functionality (init.js, buttons.js, event-handlers.js, config.js, default-config.json)
- Utility Modules (utils.js, log.js)
- Manifest (manifest.json) as the deployment descriptor.
- Promo Assets (Promo directory) – as a support/marketing component.
- Data flow: e.g., from user interaction on the popup UI to event-handlers to prompt insertion.
- Dependencies: e.g., the initialization sequence where manifest.json triggers init.js, which then calls the core modules.
- Another for utility/support modules
- Interactions: show storage interactions (browser sync storage) for saving user prompt profiles and settings.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        m1["manifest.json"]:::config
        c1["config.js"]:::config
        dcf["default-config.json"]:::config
    end

    subgraph "Extension Core Modules"
        i1["init.js"]:::core
        b1["buttons.js"]:::core
        bi1["buttons-init.js"]:::core
        binj["buttons-injection.js"]:::core
        eh["event-handlers.js"]:::core
    end

    subgraph "User Interface Components"
        ph["popup.html"]:::ui
        ps["popup-page-scripts"]:::ui
        psty["popup-page-styles"]:::ui
        wh["welcome.html"]:::ui
        wa["welcome-page-files"]:::ui
    end

    subgraph "Utility Modules"
        u1["utils.js"]:::util
        l1["log.js"]:::util
    end

    pa["Promo Assets"]:::promo
    store["Browser Sync Storage"]:::storage

    %% Relationships and Data Flow
    m1 -->|"triggers"| i1
    c1 --> i1
    dcf --> i1

    i1 --> b1
    i1 --> bi1
    i1 --> binj
    i1 --> eh

    ph -->|"user_click"| eh
    ph --> ps
    ph --> psty
    wh --> wa

    eh -->|"utilizes"| u1
    eh -->|"logs"| l1
    b1 --> u1
    b1 --> l1

    eh -->|"saves_settings"| store
    c1 -->|"configures_storage"| store
    dcf -->|"default_settings"| store

    pa -->|"assets_used_in"| ph
    pa -->|"assets_used_in"| wh

    %% Click Events
    click m1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/manifest.json"
    click c1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/config.js"
    click dcf "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/default-config.json"
    click i1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/init.js"
    click b1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/buttons.js"
    click bi1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/buttons-init.js"
    click binj "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/buttons-injection.js"
    click eh "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/event-handlers.js"
    click ph "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/popup.html"
    click ps "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/tree/master/popup-page-scripts"
    click psty "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/tree/master/popup-page-styles"
    click wh "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/welcome.html"
    click wa "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/tree/master/welcome-page-files"
    click pa "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/tree/master/Promo"
    click u1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/utils.js"
    click l1 "https://github.com/maxitservice/chatgpt-quick-buttons-for-your-text/blob/master/log.js"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef util fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef promo fill:#F08080,stroke:#000,stroke-width:2px;
    classDef storage fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
