# mauuxl/whatsapp-dark-theme architecture

> Architecture diagram of the GitHub repository mauuxl/whatsapp-dark-theme, 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/mauuxl/whatsapp-dark-theme
- Repository: https://github.com/mauuxl/whatsapp-dark-theme

## Overview

##### Main Components
- Manifest Configuration (manifest.json): Acts as the entry point by declaring the extension’s scripts, permissions, and UI configuration.
- Popup Module (popup folder):
- popup.html – the UI for the extension’s popup.
- popup.css – styling for the popup.
- popup.js – handles JavaScript logic for interactions in the popup interface.
- Content Scripts (scripts folder):
- content.js – dynamically injects or modifies the web page (in this case, WhatsApp Web) to apply the dark theme.
- Style Definitions (css folder):
- content.css – contains the CSS rules that define the dark theme styles.
- Additional Assets:

##### Relationships and Interactions
- The manifest.json defines which pages and scripts are loaded by the browser. It “connects” the popup interface and the content scripts.
- When the extension is loaded, the manifest tells the browser to inject content.js and/or css/content.css into the WhatsApp Web page for applying the dark theme.
- The popup component (HTML/CSS/JS in the popup folder) provides a user interface where users can interact with the extension—turning the theme on/off or accessing settings.

##### Architectural Patterns and Design Principles
- Modular structure: Separation of styling (css), logic (scripts and popup/js), assets (images), and configuration (manifest.json).
- Client-side injection: The key architectural pattern is that the extension injects CSS/JS into the host web app (WhatsApp Web) to alter its presentation.
- Clear separation between the extension’s own UI (popup) and the modifications applied to the target web page.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes with Styles
    manifest["Manifest (manifest.json)"] 
    subgraph "Popup Module"
        popupHTML["Popup HTML (popup.html)"]
        popupCSS["Popup CSS (popup.css)"]
        popupJS["Popup JS (popup.js)"]
    end
    contentScript["Content Script (scripts/content.js)"]
    cssStyles["CSS Styles (css/content.css)"]
    assets["Assets (images)"]
    whatsappWeb["WhatsApp Web"]

    %% Connections
    manifest -->|"initializes"| popupHTML
    manifest -->|"initializes"| contentScript
    manifest -->|"initializes"| cssStyles
    manifest -->|"contains"| assets

    popupJS -->|"sendsMessages"| contentScript

    contentScript -->|"injectsTheme"| whatsappWeb
    cssStyles -->|"appliesStyles"| whatsappWeb

    %% Styles
    style manifest fill:#add8e6,stroke:#333,stroke-width:2px
    style popupHTML fill:#98FB98,stroke:#333,stroke-width:2px,rx:5,ry:5
    style popupCSS fill:#98FB98,stroke:#333,stroke-width:2px,rx:5,ry:5
    style popupJS fill:#98FB98,stroke:#333,stroke-width:2px,rx:5,ry:5
    style contentScript fill:#FFB6C1,stroke:#333,stroke-width:2px,rx:5,ry:5
    style cssStyles fill:#FFFF99,stroke:#333,stroke-width:2px,rx:5,ry:5
    style assets fill:#D3D3D3,stroke:#333,stroke-width:2px,stroke-dasharray: 4,4,rx:5,ry:5
    style whatsappWeb fill:#FFDEAD,stroke:#333,stroke-width:2px,stroke-dasharray: 4,4,rx:5,ry:5

    %% Click Events
    click manifest "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/manifest.json"
    click popupHTML "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/popup/popup.html"
    click popupCSS "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/popup/popup.css"
    click popupJS "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/popup/popup.js"
    click contentScript "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/scripts/content.js"
    click cssStyles "https://github.com/mauuxl/whatsapp-dark-theme/blob/main/css/content.css"
    click assets "https://github.com/mauuxl/whatsapp-dark-theme/tree/main/images"
```
