# dharminjoshi/tabsort-devkay architecture

> Architecture diagram of the GitHub repository dharminjoshi/tabsort-devkay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dharminjoshi/tabsort-devkay
- Repository: https://github.com/dharminjoshi/tabsort-devkay

## Overview

##### Project type and purpose
- TabSort-DevKay is a Chrome browser extension whose primary purpose is to help users group, manage, and automatically close inactive tabs.
- It consists of two interacting components: a popup-based UI (popup.html, popup.js, styles.css) and a background script (background.js), tied together by the Chrome Extensions API and manifest.json.

##### File structure
- manifest.json: defines extension metadata, permissions (tabs, storage), entry points (background script, popup page), and version.
- background.js: long-running background service (event-driven), tracks tab activity, enforces inactivity rules, persists data.
- popup.html / popup.js / styles.css: front-end UI that lets the user view, create, rename, or delete tab groups; invokes extension APIs.
- README.md: outlines features, installation steps, and contributing guidelines.

##### README for additional insights
- Persistent storage across browser sessions → uses chrome.storage API.
- Real-time UI updates → message-passing or runtime events between popup and background.
- Tab inactivity auto-closure → background listens for tab events and timeouts.

##### Elements
- Clear labels: Popup UI, Background Service, Chrome API (Tabs/Storage), Browser Toolbar
- Popup UI ↔ Background Service (message passing)
- Background Service → Chrome Tabs API (tab grouping, closing)
- Background Service ↔ Chrome Storage API
- Storage API → Popup UI (storage.onChanged events)
- UI components (e.g., blue rectangles)
- Background/event handlers (e.g., green circles)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Toolbar
    User["User"]:::external
    ToolbarIcon["Browser Toolbar Icon"]:::external
    User -->|"clicks"| ToolbarIcon
    ToolbarIcon -->|"opens"| PopupHTML

    %% Manifest defining entry points
    Manifest["manifest.json"]:::external
    Manifest -->|"defines popup entry"| PopupHTML
    Manifest -->|"defines background entry"| BackgroundJS

    %% Popup UI Context
    subgraph "Popup UI Context"
        direction TB
        PopupHTML["popup.html"]:::ui
        PopupJS["popup.js"]:::ui
        Styles["styles.css"]:::ui
        PopupHTML --> PopupJS
        PopupHTML --> Styles
        PopupJS -->|"sendMessage"| BackgroundJS
        Styles -.-> PopupHTML
    end

    %% Background Service Context
    subgraph "Background Service Context"
        direction TB
        BackgroundJS["background.js"]:::background
        BackgroundJS -->|"tabs API calls"| TabsAPI
        BackgroundJS -->|"storage read/write"| StorageAPI
        BackgroundJS -->|"listens runtime events"| RuntimeAPI
        TabsAPI["Chrome Tabs API"]:::api
        StorageAPI["Chrome Storage API"]:::storage
        RuntimeAPI["Chrome Runtime API"]:::api
    end

    %% Message and storage events
    StorageAPI -->|"onChanged events"| PopupJS
    RuntimeAPI -.->|"onMessage"| PopupJS
    BackgroundJS -->|"onActivated/onUpdated"| TabsAPI

    %% External Assets and Documentation
    Icons["icons/"]:::external
    README["README.md"]:::external
    Manifest --> Icons
    Manifest --> README

    %% Click Events
    click PopupHTML "https://github.com/dharminjoshi/tabsort-devkay/blob/master/popup.html"
    click PopupJS "https://github.com/dharminjoshi/tabsort-devkay/blob/master/popup.js"
    click Styles "https://github.com/dharminjoshi/tabsort-devkay/blob/master/styles.css"
    click BackgroundJS "https://github.com/dharminjoshi/tabsort-devkay/blob/master/background.js"
    click Manifest "https://github.com/dharminjoshi/tabsort-devkay/blob/master/manifest.json"
    click Icons "https://github.com/dharminjoshi/tabsort-devkay/tree/master/icons/"
    click README "https://github.com/dharminjoshi/tabsort-devkay/blob/master/README.md"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef background fill:#E8F5E9,stroke:#388E3C,color:#000
    classDef api fill:#CFD8DC,stroke:#607D8B,color:#000
    classDef storage fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef external fill:#F3E5F5,stroke:#9C27B0,color:#000
```
