# tgayle/tab-counter architecture

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

- Interactive diagram: https://gitdiagram.com/tgayle/tab-counter
- Repository: https://github.com/tgayle/tab-counter

## Overview

##### Main Components

A. Browser Integration Layer
- Background Script (src/background.ts)
- Content Script (src/content)
- Context Menu Integration (src/contextmenu)

B. Core Features Layer
- Tab Management System
- Tab Filtering (src/action/TabFilter.ts)
- Tab Statistics (src/action/TabStats.ts)
- Tab Grouping (src/action/grouping/*)
- Tab Archiving System (src/features/archives)
- Settings Management (src/state/settings.ts)

C. UI Components Layer
- Popup Interface (src/pages/popup)
- Side Panel Interface (src/pages/sidePanel)
- Shared Components (src/components)

D. State Management
- Store (src/store.ts)
- State Modules
- Rules State (src/state/rules.ts)
- Settings State (src/state/settings.ts)
- Tabs State (src/state/tabs.ts)
- UI State (src/state/ui.ts)

- [Chrome Browser API]
- ↕
- [Extension Integration Layer]
- ↕
- [Core Features Layer]
- ↕
- [State Management Layer]
- ↕
- [UI Layer]

##### Key Architectural Patterns to Highlight

- Event-driven architecture (evidenced by EventEmitter.ts)
- Strategy Pattern for tab grouping (various grouping strategies)
- State management pattern (separate state modules)
- Component-based UI architecture (React components)

##### Implementation Details

- Version information
- Key technologies used:
- TypeScript
- React
- Chrome Extensions API
- Tailwind CSS

##### Additional Notes

- A small section showing the tab grouping strategy hierarchy
- Demonstrate how the filtering system integrates with the UI
- Flow of tab management operations from UI trigger to execution
- Where future Firefox support could be integrated

Remember to emphasize the extension's primary purpose of tab management and organization while showing how the architecture supports the current features and allows for future expansion.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef browser fill:#A8A8A8,stroke:#666
    classDef integration fill:#90CAF9,stroke:#666
    classDef core fill:#81C784,stroke:#666
    classDef ui fill:#FFB74D,stroke:#666
    classDef state fill:#CE93D8,stroke:#666

    %% Browser Layer
    ChromeAPI[Chrome Browser API]:::browser

    %% Integration Layer
    subgraph Integration
        Background["Background Script"]:::integration
        Content["Content Script"]:::integration
        ContextMenu["Context Menu"]:::integration
    end

    %% Core Features Layer
    subgraph CoreFeatures
        TabManagement["Tab Management"]:::core
        TabArchiving["Tab Archiving"]:::core
        Settings["Settings Management"]:::core
        
        subgraph GroupingStrategies
            Expression["Expression Strategy"]:::core
            Origin["Origin Strategy"]:::core
            Window["Window Strategy"]:::core
            TabGroup["Tab Group Strategy"]:::core
        end
        
        subgraph TabUtils
            TabFilter["Tab Filter"]:::core
            TabStats["Tab Statistics"]:::core
            TabUtil["Tab Utilities"]:::core
        end
        
        EventSystem["Event System"]:::core
        BadgeManager["Badge Manager"]:::core
    end

    %% State Management Layer
    subgraph StateManagement
        Store["Store"]:::state
        RulesState["Rules State"]:::state
        SettingsState["Settings State"]:::state
        TabsState["Tabs State"]:::state
        UIState["UI State"]:::state
    end

    %% UI Layer
    subgraph UserInterface
        Popup["Popup Interface"]:::ui
        SidePanel["Side Panel"]:::ui
        
        subgraph SharedComponents
            TabComponents["Tab Components"]:::ui
            GroupComponents["Group Components"]:::ui
            RulesComponents["Rules Components"]:::ui
        end
    end

    %% Relationships
    ChromeAPI <--> Integration
    Integration --> CoreFeatures
    CoreFeatures --> StateManagement
    StateManagement --> UserInterface
    
    TabManagement --> GroupingStrategies
    TabManagement --> TabUtils
    EventSystem --> Store
    
    %% Click Events
    click Background "https://github.com/tgayle/tab-counter/blob/main/src/background.ts"
    click Content "https://github.com/tgayle/tab-counter/blob/main/src/content/index.ts"
    click ContextMenu "https://github.com/tgayle/tab-counter/blob/main/src/contextmenu/listDuplicateTabs.ts"
    click TabFilter "https://github.com/tgayle/tab-counter/blob/main/src/action/TabFilter.ts"
    click TabStats "https://github.com/tgayle/tab-counter/blob/main/src/action/TabStats.ts"
    click TabArchiving "https://github.com/tgayle/tab-counter/tree/main/src/features/archives/"
    click Settings "https://github.com/tgayle/tab-counter/blob/main/src/settings.ts"
    click Popup "https://github.com/tgayle/tab-counter/tree/main/src/pages/popup/"
    click SidePanel "https://github.com/tgayle/tab-counter/tree/main/src/pages/sidePanel/"
    click TabComponents "https://github.com/tgayle/tab-counter/tree/main/src/components/tab/"
    click GroupComponents "https://github.com/tgayle/tab-counter/tree/main/src/components/groups/"
    click RulesComponents "https://github.com/tgayle/tab-counter/tree/main/src/components/rules/"
    click Store "https://github.com/tgayle/tab-counter/blob/main/src/store.ts"
    click RulesState "https://github.com/tgayle/tab-counter/blob/main/src/state/rules.ts"
    click SettingsState "https://github.com/tgayle/tab-counter/blob/main/src/state/settings.ts"
    click TabsState "https://github.com/tgayle/tab-counter/blob/main/src/state/tabs.ts"
    click UIState "https://github.com/tgayle/tab-counter/blob/main/src/state/ui.ts"
    click Expression "https://github.com/tgayle/tab-counter/blob/main/src/action/grouping/ExpressionGroupingStrategy.ts"
    click Origin "https://github.com/tgayle/tab-counter/blob/main/src/action/grouping/OriginGroupingStrategy.ts"
    click Window "https://github.com/tgayle/tab-counter/blob/main/src/action/grouping/WindowGroupingStrategy.ts"
    click TabGroup "https://github.com/tgayle/tab-counter/blob/main/src/action/grouping/TabGroupGroupingStrategy.ts"
    click EventSystem "https://github.com/tgayle/tab-counter/blob/main/src/base/EventEmitter.ts"
    click TabUtil "https://github.com/tgayle/tab-counter/blob/main/src/tabutil.ts"
    click BadgeManager "https://github.com/tgayle/tab-counter/blob/main/src/badge.ts"
```
