# saarthakkj/detoxify_yt architecture

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

- Interactive diagram: https://gitdiagram.com/saarthakkj/detoxify_yt
- Repository: https://github.com/saarthakkj/detoxify_yt

## Overview

##### Main Components

A. Client-Side Components:
- Chrome Extension (Frontend)
- Popup Interface
- Content Script
- Background Service Worker

B. Server-Side Components:
- FastAPI Backend
- BERT Classification Model
- BrightData API Integration

##### Specific Implementation Details

a) Extension Components:
- Popup interface for category selection
- Content script for YouTube page interaction
- Background script for API communication

b) Backend Flow:
- FastAPI endpoints
- Token-based authentication
- Asynchronous processing
- Model inference pipeline

c) Model Integration:
- BERT classification system
- Multi-category output (Chess, Coding, Mathematics)
- Real-time inference path

##### Key Processes to Illustrate

Main workflows:

##### Additional Elements

Include:
- Performance metrics (87.8% accuracy)
- Category labels
- Security components
- API authentication flow

##### Technical Details to Note

Highlight:
- Python 3.8+ requirement
- FastAPI/Uvicorn backend
- BERT model specifications
- Chrome extension manifest version

Remember to include the performance metrics (ROC-AUC scores) for each category as they're significant differentiators:
- Chess: 0.976
- Coding: 0.971
- Mathematics: 0.949
- Other: 0.941

This system design should emphasize the project's unique combination of browser extension technology with AI-powered content classification, making it clear how the components work together to provide a "cleaner YouTube experience."

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#95a5a6,stroke:#7f8c8d,color:white
    
    subgraph "Chrome Extension"
        UI[Popup Interface]:::frontend
        CS[Content Script]:::frontend
        BSW[Background Service Worker]:::frontend
        MC[Manifest Configuration]:::frontend
        Assets[Extension Assets]:::frontend
    end
    
    subgraph "Backend Services"
        API[FastAPI Backend]:::backend
        Auth[Authentication Middleware]:::backend
        Deps[Backend Dependencies]:::backend
    end
    
    subgraph "Model & Processing"
        BERT[BERT Classification Model]:::model
        PreProc[Data Pre-processing]:::model
        Response[API Response Handler]:::model
    end
    
    subgraph "External Services"
        BrightData[BrightData API]:::external
        YouTube[YouTube Interface]:::external
    end
    
    %% Connections
    UI --> BSW
    CS --> BSW
    BSW --> API
    API --> Auth
    Auth --> BERT
    BERT --> Response
    API --> BrightData
    CS --> YouTube
    PreProc --> BERT
    
    %% Performance Metrics
    subgraph "Model Accuracy"
        Chess[Chess: 97.6%]:::data
        Coding[Coding: 97.1%]:::data
        Math[Mathematics: 94.9%]:::data
        Other[Other: 94.1%]:::data
    end
    
    BERT --> Chess
    BERT --> Coding
    BERT --> Math
    BERT --> Other
    
    %% Click Events
    click UI "https://github.com/Saarthakkj/detoxify_yt/blob/master/extension/popup.html"
    click CS "https://github.com/Saarthakkj/detoxify_yt/blob/master/extension/contentScript.js"
    click BSW "https://github.com/Saarthakkj/detoxify_yt/blob/master/extension/background.js"
    click MC "https://github.com/Saarthakkj/detoxify_yt/blob/master/extension/manifest.json"
    click Assets "https://github.com/Saarthakkj/detoxify_yt/tree/master/extension/icons/"
    click API "https://github.com/Saarthakkj/detoxify_yt/blob/master/backend/app/main.py"
    click Deps "https://github.com/Saarthakkj/detoxify_yt/blob/master/backend/requirements.txt"
    click BERT "https://github.com/Saarthakkj/detoxify_yt/blob/master/model/notebooks/main.ipynb"
    click PreProc "https://github.com/Saarthakkj/detoxify_yt/blob/master/pre_processing.py"
    click Response "https://github.com/Saarthakkj/detoxify_yt/blob/master/sample_response.json"
```
