# seungineer/chattoc-chrome-ext architecture

> Architecture diagram of the GitHub repository seungineer/chattoc-chrome-ext, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seungineer/chattoc-chrome-ext
- Repository: https://github.com/seungineer/chattoc-chrome-ext

## Overview

##### Main Components Identification
The project is clearly a Chrome Extension with the following key architectural components:

a. User Interface Layer:
- Popup interface (popup.html, popup.js, styles.css)
- Content Script (content.js)

b. Utility Layer:
- Chat functionality (chat.js)
- Storage management (chromeStorage.js)
- Event handling (eventHandlers.js)
- Form handling (form.js)
- Table of Contents helper (tocHelper.js)
- URL handling (urlHelper.js)

##### Component Relationships

a. User Interaction Flow:
- Browser Action → Popup UI → Event Handlers
- Content Script → Web Page Integration
- Content Script ↔ Chrome Message Passing → Popup

b. Utility Services Integration:
- How chat.js, tocHelper.js, and urlHelper.js interact with content.js
- ChromeStorage.js connection to Chrome's Storage API
- Form.js integration with popup.js

**[User Interface Layer]**
- ↓
**[Extension Core Layer]**
- ↓
**[Utility Services Layer]**
- ↓
**[Chrome API Layer]**

##### Technical Details

Annotations for:

- Chrome Extension Manifest version
- Content Script injection points
- Permission requirements
- API version dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        PopupUI["Popup Interface"]
        CS["Content Script"]
    end

    subgraph "Utility Services Layer"
        Chat["Chat Service"]:::utility
        Storage["Storage Manager"]:::utility
        Events["Event Handler"]:::utility
        Form["Form Handler"]:::utility
        TOC["TOC Helper"]:::utility
        URL["URL Helper"]:::utility
    end

    subgraph "Chrome API Layer"
        StorageAPI["Storage API"]:::api
        MessageAPI["Message API"]:::api
        TabsAPI["Tabs API"]:::api
    end

    %% Component Relationships
    PopupUI --> Events
    PopupUI --> Form
    PopupUI --> Storage
    
    CS --> TOC
    CS --> URL
    CS --> Chat
    
    Storage --> StorageAPI
    CS <-.->|Message Passing| PopupUI
    CS --> MessageAPI
    PopupUI --> TabsAPI

    %% Component Mappings with Click Events
    click PopupUI "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/popup.html"
    click CS "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/content.js"
    click Chat "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/chat.js"
    click Storage "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/chromeStorage.js"
    click Events "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/eventHandlers.js"
    click Form "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/form.js"
    click TOC "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/tocHelper.js"
    click URL "https://github.com/seungineer/chatTOC-chrome-ext/blob/main/utils/urlHelper.js"

    %% Styling
    classDef utility fill:#90EE90,stroke:#333,stroke-width:2px
    classDef api fill:#FFA500,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        UI[UI Component]
        UTIL[Utility Service]:::utility
        API[Chrome API]:::api
        UI --- UTIL
        UTIL --- API
    end
```
