# arandomboiisme/tweetpatrol architecture

> Architecture diagram of the GitHub repository arandomboiisme/tweetpatrol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arandomboiisme/tweetpatrol
- Repository: https://github.com/arandomboiisme/tweetpatrol

## Overview

##### Main Components

a) Browser Extension Components:
- Popup Interface (User Dashboard)
- Background Service Worker
- Content Scripts
- Storage System

b) External Systems:
- X/Twitter Web Interface
- Chrome Extension API
- Browser Storage API

**┌─ Browser Context ──────────────────────────────────────┐**

- ┌─ Extension Components ─────────────────────┐        │

- ┌─ Popup ─────┐    ┌─ Background.js ─┐   │        │
- Dashboard   │←──→│ Event Handler   │   │        │
- UI         │    │ State Manager  │   │        │
- ┘    └───────────────┘   │        │

- ┌─ Content Scripts ───────────────────┐   │        │
- home.js                          │   │        │
- poast.js                         │   │        │
- profile.js                       │   │        │
- search.js                        │   │        │
- ┘   │        │

- ┌─ Utils ─────────────────────────────┐   │        │
- Shared Functions & Helpers           │   │        │
- ┘   │        │
- ┘        │

- ┌─ X/Twitter Web Interface ────────────────────┐      │
- DOM Injection Points                         │      │
- Image Detection & Monitoring                 │      │
- ┘      │
- ┘

##### Key Interactions to Highlight

a) Content Script Injection:
- How content scripts are injected into X/Twitter pages
- Which scripts handle different pages (home, profile, search)

b) Image Registration Flow:
- Process of detecting and registering images
- Storage interaction for saving registered images

c) Image Monitoring Flow:
- How the extension checks for registered images
- Banner injection process for stolen images

##### Additional Elements

- Annotations for key processes
- Version information and supported browsers

##### Implementation Details to Note

- How the popup interface communicates with background.js
- Role of utils.js in supporting various components
- Demonstrate how content scripts interact with the X/Twitter DOM

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Browser Context"]
        subgraph Extension["Extension Components"]
            subgraph Popup["Popup Interface"]
                Dashboard["Dashboard UI"]:::ui
                PopupHTML["Popup HTML"]:::ui
                PopupCSS["Popup CSS"]:::ui
                PopupJS["Popup JS"]:::ui
            end

            Background["Background Service Worker"]:::background
            
            subgraph ContentScripts["Content Scripts"]
                HomeJS["Home Script"]:::script
                PostJS["Post Script"]:::script
                ProfileJS["Profile Script"]:::script
                SearchJS["Search Script"]:::script
            end

            Utils["Utility Functions"]:::util
            Manifest["Extension Manifest"]:::config
        end

        subgraph Twitter["X/Twitter Web Interface"]
            DOM["DOM Injection Points"]:::twitter
            ImageDetect["Image Detection"]:::twitter
        end
    end

    %% Relationships
    Dashboard --> Background
    Background --> ContentScripts
    ContentScripts --> DOM
    DOM --> ImageDetect
    Utils --> ContentScripts
    Utils --> Background
    Utils --> Popup
    Background --> Browser

    %% Styling
    classDef ui fill:#4A90E2,stroke:#2171C7,color:white
    classDef background fill:#67B246,stroke:#4A8C2F,color:white
    classDef script fill:#9B59B6,stroke:#804399,color:white
    classDef util fill:#E67E22,stroke:#BA651B,color:white
    classDef twitter fill:#1DA1F2,stroke:#1681C2,color:white
    classDef config fill:#E74C3C,stroke:#BE3D2F,color:white

    %% Click Events
    click Dashboard "https://github.com/ARandomBoiIsMe/tweetpatrol/tree/main/popup"
    click PopupHTML "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/popup/popup.html"
    click PopupCSS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/popup/popup.css"
    click PopupJS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/popup/popup.js"
    click Background "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/background.js"
    click HomeJS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/scripts/home.js"
    click PostJS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/scripts/poast.js"
    click ProfileJS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/scripts/profile.js"
    click SearchJS "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/scripts/search.js"
    click Utils "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/utils.js"
    click Manifest "https://github.com/ARandomBoiIsMe/tweetpatrol/blob/main/manifest.json"

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        BG["Background Process"]:::background
        CS["Content Script"]:::script
        UT["Utility"]:::util
        TW["Twitter Interface"]:::twitter
        CF["Configuration"]:::config
    end
```
