# askman-dev/askman-chrome-extension architecture

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

- Interactive diagram: https://gitdiagram.com/askman-dev/askman-chrome-extension
- Repository: https://github.com/askman-dev/askman-chrome-extension

## Overview

##### Main Components Identification

a) Browser Extension Components:
- Content Scripts (src/pages/content)
- Background Service (src/pages/background)
- UI Components (src/components)
- Storage Management (src/shared/storages)
- Agents System (src/agents)

b) External Systems:
- AI Service Providers
- Web Pages (GitHub, StackOverflow, etc.)

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

- ┌─ Extension UI ─────────┐                           │
- Popup               │ ┌─ Side Panel ┐            │
- Chat Interface      │ │            │            │
- Configuration UI    │ │            │            │
- ┘ └──────────┘             │

- ┌─ Extension Core ───────────────────────────────┐   │

- ┌─ Agents ─────┐    ┌─ Storage Manager ─┐    │   │
- GitHub       │    │ Config Storage    │    │   │
- StackOverflow│    │ Theme Storage     │    │   │
- ┘    └─────────────────────┘   │   │

- ┌─ Background Service ─┐  ┌─ Content Scripts┐│   │
- Message Handling     │  │ Page Integration││   │
- State Management    │  │ DOM Manipulation││   │
- ┘  └───────────────┘│   │
- ┘   │

- ┘

**┌─ External Services ─────┐    ┌─ Web Pages ──────────┐**
- AI Service Providers    │    │ GitHub               │
- (API Integration)       │    │ StackOverflow        │
- ┘    └─────────────────────────┘

##### Component Relationships

Following interactions:
- Content Scripts ↔ Web Page DOM
- UI Components ↔ Background Service
- Background Service ↔ AI Providers
- Storage Manager ↔ All Components
- Agents ↔ Specific Web Pages

##### Technical Details

- React components for UI (shown in src/components)
- TypeScript implementation (evident from .ts files)
- Configuration management (TOML files in src/assets/conf)
- Localization support (_locales directory)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Browser Context"]
        subgraph ExtUI["Extension UI"]
            Popup["Popup Interface"]:::ui
            SidePanel["Side Panel"]:::ui
            ChatUI["Chat Interface"]:::ui
            ConfigUI["Configuration UI"]:::ui
        end

        subgraph ExtCore["Extension Core"]
            subgraph Agents["Agents System"]
                GitAgent["GitHub Agent"]:::agent
                SOAgent["StackOverflow Agent"]:::agent
            end

            subgraph Storage["Storage Management"]
                StorageManager["Storage Manager"]:::storage
                ThemeStorage["Theme Storage"]:::storage
                ConfigStorage["Configuration Storage"]:::storage
            end

            subgraph Core["Core Services"]
                Background["Background Service"]:::core
                Content["Content Scripts"]:::core
                ChatCore["Chat Core"]:::core
            end
        end
    end

    subgraph External["External Layer"]
        AI["AI Service Providers"]:::external
        WebPages["Web Pages"]:::external
    end

    %% Relationships
    Popup --> Background
    SidePanel --> Background
    ChatUI --> ChatCore
    ConfigUI --> StorageManager
    
    Background --> AI
    Content --> WebPages
    
    GitAgent --> WebPages
    SOAgent --> WebPages
    
    ChatCore --> AI
    ChatCore --> StorageManager
    
    Background --> StorageManager
    Content --> StorageManager

    %% Click Events
    click Content "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/pages/content"
    click Background "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/pages/background"
    click Popup "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/pages/popup"
    click SidePanel "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/pages/sidepanel"
    click ChatUI "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/components/ask"
    click ConfigUI "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/components/config"
    click StorageManager "https://github.com/askman-dev/askman-chrome-extension/blob/main/src/utils/StorageManager.ts"
    click ThemeStorage "https://github.com/askman-dev/askman-chrome-extension/blob/main/src/shared/storages/exampleThemeStorage.ts"
    click ConfigStorage "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/assets/conf"
    click ChatCore "https://github.com/askman-dev/askman-chrome-extension/blob/main/src/chat/chat.ts"
    click GitAgent "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/agents/page-github"
    click SOAgent "https://github.com/askman-dev/askman-chrome-extension/tree/main/src/agents/page-stackoverflow"

    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef storage fill:#FF9800,stroke:#F57C00,color:white
    classDef agent fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef external fill:#757575,stroke:#424242,color:white

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        CoreComp["Core Component"]:::core
        StorageComp["Storage Component"]:::storage
        AgentComp["Agent Component"]:::agent
        ExternalComp["External System"]:::external
    end
```
