# esteve11/wab-tools architecture

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

## Overview

##### Main Components
- Manifest & Configuration: Represented by “manifest.json”, which is the core configuration file for the Chrome extension. This defines things like the extension’s permissions, injected scripts, and entry points.
- Content Scripts / Feature Scripts:
– “add-rotate-image-button.js”: Implements the feature to rotate images.
– “avoid-enter-send.js”: Implements the modified behavior for the Enter key.
– “observer-setup.js”: Likely used to monitor DOM changes on WhatsApp Web so that when the page updates, the extension can hook in and modify the necessary elements.
- Developer Tools & Ignored Files: “.gitignore” for source control and “README.md” which provides instructions and an overview for installation.

##### Establish Relationships and Interactions
- The content scripts then interact directly with the WhatsApp Web DOM. For example, the “add-rotate-image-button.js” script inserts an additional UI element, while “avoid-enter-send.js” alters key event behaviors.
- “observer-setup.js” acts as a monitoring component that detects dynamic changes on the webpage and triggers the appropriate functionality. This component can be noted as essential for ensuring that the changes persist as new content loads in the dynamic web environment.

##### Architectural Patterns & Principles
- Modular Design: The extension is designed in a modular way by separating feature-specific logic into individual scripts.
- Event-Driven Behavior: “observer-setup.js” typically uses event listeners (like Mutation Observers) to react to changes in the web page.
- Separation of Concerns: Each file is focused on a specific feature, making it easier to maintain and update functionalities independently.
- Minimal Invasiveness: The extension only injects small pieces of code into the existing WhatsApp Web interface rather than rebuilding the entire UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Chrome Extension Group
    subgraph "Chrome Extension"
        direction TB
        manifest["Manifest (manifest.json)"]:::config
        
        subgraph "Content Scripts"
            direction TB
            rotateFeature["Feature: Rotate Images (add-rotate-image-button.js)"]:::feature
            enterKeyFeature["Feature: Prevent Enter Send (avoid-enter-send.js)"]:::feature
            observer["DOM Observer (observer-setup.js)"]:::feature
        end
        
        assets["Asset Resources (img)"]:::asset
        
        subgraph "Developer Tools & Documentation"
            direction TB
            gitignore[".gitignore"]:::dev
            readme["README.md"]:::dev
        end
    end

    %% External Environment
    whatsapp["WhatsApp Web"]:::external

    %% Manifest injecting content scripts
    manifest -->|"injects"| rotateFeature
    manifest -->|"injects"| enterKeyFeature
    manifest -->|"injects"| observer

    %% Content scripts interactions
    rotateFeature -->|"modifies"| whatsapp
    enterKeyFeature -->|"modifies"| whatsapp
    observer -->|"monitors"| whatsapp

    %% Feature scripts dependent on assets
    rotateFeature -->|"uses"| assets
    enterKeyFeature -->|"uses"| assets
    observer -->|"uses"| assets

    %% Click Events
    click manifest "https://github.com/esteve11/wab-tools/blob/master/manifest.json"
    click rotateFeature "https://github.com/esteve11/wab-tools/blob/master/add-rotate-image-button.js"
    click enterKeyFeature "https://github.com/esteve11/wab-tools/blob/master/avoid-enter-send.js"
    click observer "https://github.com/esteve11/wab-tools/blob/master/observer-setup.js"
    click assets "https://github.com/esteve11/wab-tools/tree/master/img"
    click gitignore "https://github.com/esteve11/wab-tools/blob/master/.gitignore"
    click readme "https://github.com/esteve11/wab-tools/blob/master/README.md"

    %% Styles
    classDef config fill:#FFE4B5,stroke:#FF8C00,stroke-width:2px;
    classDef feature fill:#B0E0E6,stroke:#4682B4,stroke-width:2px;
    classDef asset fill:#98FB98,stroke:#2E8B57,stroke-width:2px;
    classDef dev fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef external fill:#E6E6FA,stroke:#9370DB,stroke-width:2px;
```
