# zamanmayed1/famusa architecture

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

- Interactive diagram: https://gitdiagram.com/zamanmayed1/famusa
- Repository: https://github.com/zamanmayed1/famusa

## Overview

##### Main Components

A. Browser Components:
- Chrome Browser Interface
- Extension Popup UI
- Active Tab/Website

B. Extension Components:
- Background Service Worker (background.js)
- Content Script (content.js)
- Popup Interface (popup.html/js)
- Storage Layer (Chrome Storage API)

**┌─ User Interface Layer ─────────────────────┐**
- Chrome Browser                          │
- Extension Popup UI                      │
- Active Website Tab                      │
- ┘
- ↕
**┌─ Extension Core Layer ────────────────────┐**
- ┌─ Background Service Worker ─┐          │
- Website Monitoring       │          │
- Blocking Logic           │          │
- ┘         │
- ┌─ Content Script ──────────┐            │
- DOM Manipulation       │            │
- Overlay/Blur Effects   │            │
- ┘           │
- ┘
- ↕
**┌─ Storage Layer ──────────────────────────┐**
- Chrome Storage API                     │
- Blocklist Data                         │
- User Preferences                       │
- ┘

##### Key Interactions to Highlight

a. Popup to Background Service Worker:
- Blocklist management commands
- Toggle blocking status

b. Background Service Worker to Content Script:
- Website blocking instructions
- State updates

c. Content Script to Webpage:
- DOM modifications
- Visual effects application

d. Storage Layer Interactions:
- Reading/writing blocklist
- Saving user preferences

##### Implementation Notes

- The event-driven nature of the extension
- The separation between background and content scripts
- The role of Chrome's extension APIs
- The persistent storage mechanism

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#a8d1f0,stroke:#2c3e50
    classDef core fill:#90EE90,stroke:#2c3e50
    classDef storage fill:#FFB347,stroke:#2c3e50
    classDef config fill:#D3D3D3,stroke:#2c3e50

    subgraph UI["User Interface Layer"]
        Browser["Chrome Browser"]:::ui
        Popup["Extension Popup UI"]:::ui
        ActiveTab["Active Website Tab"]:::ui
    end

    subgraph Core["Extension Core Layer"]
        subgraph BSW["Background Service Worker"]
            Background["Website Monitoring & Blocking Logic"]:::core
        end
        
        subgraph CS["Content Script"]
            Content["DOM Manipulation & Effects"]:::core
        end
    end

    subgraph Storage["Storage Layer"]
        ChromeStorage["Chrome Storage API"]:::storage
        BlockList["Blocklist Data"]:::storage
        Preferences["User Preferences"]:::storage
    end

    %% Configuration
    Manifest["manifest.json"]:::config

    %% Relationships
    Popup --> Background
    Background --> Content
    Content --> ActiveTab
    Background <--> ChromeStorage
    Background <--> BlockList
    Background <--> Preferences
    Popup <--> ChromeStorage
    Manifest -.-> Background
    Manifest -.-> Content
    Manifest -.-> Popup

    %% Click Events
    click Background "https://github.com/zamanmayed1/Famusa/blob/main/background.js"
    click Content "https://github.com/zamanmayed1/Famusa/blob/main/content.js"
    click Popup "https://github.com/zamanmayed1/Famusa/blob/main/popup.html"
    click Manifest "https://github.com/zamanmayed1/Famusa/blob/main/manifest.json"

    %% Legend
    subgraph Legend
        UI_Legend["UI Component"]:::ui
        Core_Legend["Core Component"]:::core
        Storage_Legend["Storage Component"]:::storage
        Config_Legend["Configuration"]:::config
    end
```
