# alganzory/haramblur architecture

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

- Interactive diagram: https://gitdiagram.com/alganzory/haramblur
- Repository: https://github.com/alganzory/haramblur

## Overview

##### Component Relationships

a) User Interaction Flow:
- Browser → Popup UI → Settings Management
- Webpage → Content Scripts → Detection Module

b) Processing Flow:
- Content Scripts → Queue Management → Detection Module
- Detection Module → AI Models
- AI Models → Processing Module → Content Scripts

##### Extension Architecture
- Clear separation between browser extension components
- Parallel processing capabilities
- Demonstrate the offscreen worker implementation

##### AI Integration
- How the two AI models (Human.js and NSFWJS) are integrated
- Model loading and initialization paths
- Processing pipeline for content detection

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef browser fill:#a8d1f0,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef ai fill:#FFB6C6,stroke:#333
    classDef config fill:#FFE4B5,stroke:#333
    classDef utility fill:#DDA0DD,stroke:#333

    %% Legend
    subgraph Legend
        L1[Browser Components]:::browser
        L2[Processing Components]:::processing
        L3[AI Components]:::ai
        L4[Configuration Components]:::config
        L5[Utility Components]:::utility
    end

    %% Browser Interface Layer
    subgraph Browser_Layer
        PopupUI["Popup UI"]
        ContentScripts["Content Scripts"]
        BackgroundWorker["Background Service Worker"]
        OffscreenWorker["Offscreen Worker"]
    end

    %% Core Processing Layer
    subgraph Processing_Layer
        DetectionModule["Detection Module"]
        ProcessingModule["Processing Module"]
        QueueManagement["Queue Management"]
        SettingsManagement["Settings Management"]
    end

    %% AI Models Layer
    subgraph AI_Layer
        HumanJS["Human.js Face Detection"]
        NSFWJS["NSFWJS Content Detection"]
    end

    %% Utility Components
    subgraph Utility_Layer
        Observers["Observer Patterns"]
        Helpers["Helper Utilities"]
        Styling["Styling Module"]
        Translation["Translation System"]
        Constants["Constants/Configuration"]
    end

    %% Relationships
    PopupUI --> SettingsManagement
    ContentScripts --> QueueManagement
    QueueManagement --> DetectionModule
    DetectionModule --> HumanJS
    DetectionModule --> NSFWJS
    HumanJS --> ProcessingModule
    NSFWJS --> ProcessingModule
    ProcessingModule --> ContentScripts
    BackgroundWorker --> QueueManagement
    OffscreenWorker --> ProcessingModule
    Observers --> ContentScripts
    Helpers --> ProcessingModule
    Styling --> ContentScripts
    Translation --> PopupUI
    Constants --> SettingsManagement

    %% Click Events
    click PopupUI "https://github.com/alganzory/HaramBlur/blob/main/src/popup.html"
    click ContentScripts "https://github.com/alganzory/HaramBlur/blob/main/src/content.js"
    click BackgroundWorker "https://github.com/alganzory/HaramBlur/blob/main/src/background.js"
    click OffscreenWorker "https://github.com/alganzory/HaramBlur/blob/main/src/offscreen.html"
    click DetectionModule "https://github.com/alganzory/HaramBlur/blob/main/src/modules/detector.js"
    click ProcessingModule "https://github.com/alganzory/HaramBlur/blob/main/src/modules/processing2.js"
    click QueueManagement "https://github.com/alganzory/HaramBlur/blob/main/src/modules/queues.js"
    click SettingsManagement "https://github.com/alganzory/HaramBlur/blob/main/src/modules/settings.js"
    click HumanJS "https://github.com/alganzory/HaramBlur/blob/main/tfjs/human.js"
    click NSFWJS "https://github.com/alganzory/HaramBlur/tree/main/src/assets/models/nsfwjs"
    click Observers "https://github.com/alganzory/HaramBlur/blob/main/src/modules/observers.js"
    click Helpers "https://github.com/alganzory/HaramBlur/blob/main/src/modules/helpers.js"
    click Styling "https://github.com/alganzory/HaramBlur/blob/main/src/modules/style.js"
    click Translation "https://github.com/alganzory/HaramBlur/blob/main/src/translations.js"
    click Constants "https://github.com/alganzory/HaramBlur/blob/main/src/constants.js"

    %% Apply Classes
    class PopupUI,ContentScripts,BackgroundWorker,OffscreenWorker browser
    class DetectionModule,ProcessingModule,QueueManagement processing
    class HumanJS,NSFWJS ai
    class SettingsManagement,Constants config
    class Observers,Helpers,Styling,Translation utility
```
