# rohit-wadhwa/git-repo-tools architecture

> Architecture diagram of the GitHub repository rohit-wadhwa/git-repo-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohit-wadhwa/git-repo-tools
- Repository: https://github.com/rohit-wadhwa/git-repo-tools

## Overview

##### Project type and purpose
- This is a browser extension (Chrome) that enhances GitHub repository pages by injecting quick-access buttons (“DeepWiki”, “GitDiagram”, “IDE”) and providing a popup settings UI.
- It consists of content scripts (in-page logic), a background script (persistent event handlers), a popup UI for settings, a manifest for permissions/config, and integrations with external web services.

##### File structure
- Top-level files:
- background.js – background script handling events and message routing
- content.js – content script injected into GitHub pages to modify the DOM and add buttons
- popup.html & popup.js – UI and logic for the browser-action popup (settings panel)
- docs & metadata: README.md, CONTRIBUTING.md, LICENSE.md, SECURITY.md, STORE.md, CHANGELOG.md
- No backend server or database – storage is via Chrome’s extension storage API (chrome.storage.local)

##### README for additional insights
- Confirms three main features: injecting buttons, opening external services, and configurable toggles
- Specifies settings are auto-saved, indicating use of Chrome storage APIs
- No server components – purely client-side + external web services

##### Main components and their relationships
a. Components
- Manifest (config/permissions)
- Content Script (runs on GitHub URLs; reads settings; injects buttons; handles button clicks by opening new tabs)
- Popup UI (settings interface; writes to chrome.storage; sends messages to content script/background)
- Chrome Storage (chrome.storage.local or sync)
- External Services: DeepWiki, GitDiagram, various WebIDE URLs
b. Relationships & data flow
1. On installation or browser load: manifest registers background.js and content.js for matching URLs.
2. User navigates to github.com/* – content.js runs, reads settings from chrome.storage, then injects the appropriate buttons into the page DOM.
3. Button click in page → content.js opens target service in new tab with constructed URL.
5. User changes a toggle in popup → popup.js updates chrome.storage and optionally sends a message to content.js to refresh injected UI.
6. background.js listens for runtime messages if needed (e.g., to coordinate settings changes across tabs).
c. Architectural patterns & principles
- Separation of concerns:
- Content scripts modify page UI, but do not handle persistent state
- Background script acts as a central event/message dispatcher
- Popup UI solely for user configuration
- Event-driven & message-passing using Chrome extension APIs
- Declarative configuration via manifest.json
d. Key technologies
- Chrome Extension APIs: chrome.runtime, chrome.storage, chrome.tabs
- Vanilla JavaScript, HTML/CSS (no framework)
- External REST-style services (DeepWiki, GitDiagram) and URL-based WebIDE endpoints

##### Elements
- Extension contexts (rectangles)
- Annotation for URL match patterns from manifest.json for when content scripts load

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser Extension"
        subgraph "Background Context"
            BG["Background Script"]:::background
        end
        subgraph "Content Script Context"
            CS["Content Script"]:::ui
        end
        subgraph "Popup Context"
            PUHTML["Popup UI (popup.html)"]:::ui
            PUJS["Popup Logic (popup.js)"]:::ui
        end
        MZ["Manifest"]:::config
    end

    Storage["Chrome Storage"]:::storage

    DW["DeepWiki Service"]:::external
    GD["GitDiagram Service"]:::external
    IDE["WebIDE Services"]:::external

    MZ -->|"registersbackground.jsandcontent.js"| BG
    MZ -->|"definescontent_scripts on github.com/*"| CS

    CS -->|"chrome.storage.get"| Storage
    PUHTML -->|"chrome.storage.get/set"| Storage
    PUJS -->|"chrome.storage.get/set"| Storage

    PUJS -->|"chrome.runtime.sendMessage"| BG
    BG -->|"chrome.runtime.sendMessage"| CS

    CS -->|"window.open()"| DW
    CS -->|"window.open()"| GD
    CS -->|"window.open()"| IDE

    classDef config fill:#fff2b2,stroke:#e6b800,color:#333
    classDef background fill:#d9f2d9,stroke:#82c082,color:#333
    classDef ui fill:#cce0ff,stroke:#6699cc,color:#333
    classDef storage fill:#e6e6e6,stroke:#adadad,color:#333
    classDef external fill:#ffd9d9,stroke:#e06666,color:#333

    click MZ "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/manifest.json"
    click BG "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/background.js"
    click CS "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/content.js"
    click PUHTML "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/popup.html"
    click PUJS "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/popup.js"
    click icons "https://github.com/rohit-wadhwa/git-repo-tools/tree/main/icons/"
    click images "https://github.com/rohit-wadhwa/git-repo-tools/tree/main/images/"
    click README "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/README.md"
    click CONTRIBUTING "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/CONTRIBUTING.md"
    click LICENSE "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/LICENSE.md"
    click SECURITY "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/SECURITY.md"
    click STORE "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/STORE.md"
    click CHANGELOG "https://github.com/rohit-wadhwa/git-repo-tools/blob/main/CHANGELOG.md"
```
