# epicmet/rtlit architecture

> Architecture diagram of the GitHub repository epicmet/rtlit, 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/epicmet/rtlit
- Repository: https://github.com/epicmet/rtlit

## Overview

##### Main Components Identification

The system consists of three main components, as evident from the src directory:
- Popup Interface
- Content Script
- Service Worker (SW)

##### Specific Implementation Details

Technical annotations for:
- TypeScript implementation (noted in tsconfig.json)
- Browser-specific APIs
- DOM manipulation capabilities
- Message passing interfaces

**Top Layer: User Interface (Popup)**
**Middle Layer: Extension Core (Service Worker)**
**Bottom Layer: Content Script & Web Page Interaction**

##### Security boundaries between extension components

Remember to indicate the extension's privacy aspect (no data collection) as mentioned in the README, as this affects the architectural decisions and data flow patterns.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        UI[User Interface]:::ui
        AC[Active Component]:::active
        BS[Background Service]:::background
        EX[External Element]:::external
        
        style Legend fill:#f5f5f5,stroke:#333
        
        DirectComm[Direct Communication]:::legend
        EventComm[Event-based]:::legend
        TwoWay[Two-way Communication]:::legend
        
        DirectComm --> |Solid|DirectComm
        EventComm -.-> |Dashed|EventComm
        TwoWay <--> |Bidirectional|TwoWay
    end

    subgraph BrowserExtension["Browser Extension Container"]
        Manifest["manifest.json"]
        TSConfig["tsconfig.json"]
        
        subgraph PopupLayer["Popup Interface Layer"]
            PopupHTML["index.html"]:::ui
            PopupJS["main.js"]:::ui
            PopupCSS["styles.css"]:::ui
        end
        
        subgraph CoreLayer["Extension Core Layer"]
            ServiceWorker["Service Worker"]:::background
            BuildSystem["Build System"]:::background
        end
        
        subgraph ContentLayer["Content Layer"]
            ContentScript["Content Script"]:::active
            WebPage["Web Page DOM"]:::external
        end
    end

    %% Component Relationships
    PopupHTML --> PopupJS
    PopupJS --> PopupCSS
    PopupJS <--> ServiceWorker
    ServiceWorker <--> ContentScript
    ContentScript <--> WebPage
    
    Manifest --> ServiceWorker
    Manifest --> ContentScript
    TSConfig -.-> BuildSystem
    BuildSystem -.-> ContentScript
    BuildSystem -.-> ServiceWorker
    BuildSystem -.-> PopupJS

    %% Click Events
    click Manifest "https://github.com/epicmet/rtlit/blob/main/manifest.json"
    click TSConfig "https://github.com/epicmet/rtlit/blob/main/tsconfig.json"
    click PopupHTML "https://github.com/epicmet/rtlit/blob/main/src/popup/index.html"
    click PopupJS "https://github.com/epicmet/rtlit/blob/main/src/popup/main.js"
    click PopupCSS "https://github.com/epicmet/rtlit/blob/main/src/popup/styles.css"
    click ContentScript "https://github.com/epicmet/rtlit/blob/main/src/content-script/index.ts"
    click ServiceWorker "https://github.com/epicmet/rtlit/blob/main/src/sw/index.js"
    click BuildSystem "https://github.com/epicmet/rtlit/blob/main/scripts/build.mjs"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef active fill:#2ecc71,stroke:#27ae60,color:white
    classDef background fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef legend fill:none,stroke:none
    
    %% Notes
    note["Note: Extension focuses on RTL text manipulation<br/>with no data collection"]
    style note fill:#fff,stroke:#333,stroke-dasharray: 5 5
```
