# pankajtanwarbanna/cringe-guard architecture

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

- Interactive diagram: https://gitdiagram.com/pankajtanwarbanna/cringe-guard
- Repository: https://github.com/pankajtanwarbanna/cringe-guard

## Overview

##### Project type and purpose
- This is a client-side Chrome extension (“cringe-guard”) whose purpose is to filter LinkedIn feed posts in real time using an external AI model. It injects a content script into LinkedIn pages, analyzes posts via an API, and then either blurs or removes “cringe” content. It also provides a popup/settings UI for users to input their API key and choose filtering modes.

##### File structure
- Top-level files:
- manifest.json – Chrome extension manifest defining content scripts and UI pages
- README.md, LICENSE, Privacy-Policy.md – docs
- pages/ directory (popup.html, settings.html) – extension UI for user settings
- scripts/ directory
- content.js – injected into LinkedIn pages, detects new posts, sends content to AI, manipulates DOM
- popup.js & settings.js – handle user input in popup.html and settings.html, persist to Chrome Storage

##### README for additional insights
- Architecture described in prose: real-time detection, API analysis, DOM filtering, user control via settings, persisting settings in Chrome Storage API.

##### Final advice
- Be very detailed: break out each script and UI page as its own component.
- Settings persistence and retrieval explicitly.
- Real-time nature of the content script’s interaction with the LinkedIn DOM.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Browser / Host Environment"
        LinkedInPage["LinkedIn Page"]:::host
    end

    subgraph "Chrome Extension"
        Manifest["manifest.json"]:::ext
        subgraph "Content Script"
            ContentScript["scripts/content.js"]:::ext
        end
        subgraph "UI Layer"
            PopupHTML["pages/popup.html"]:::ext
            PopupJS["scripts/popup.js"]:::ext
            SettingsHTML["pages/settings.html"]:::ext
            SettingsJS["scripts/settings.js"]:::ext
        end
        Storage[(Chrome Storage)]:::storage
        Assets["images/"]:::ext
    end

    subgraph "External Services"
        ExternalAI["External AI Service"]:::external
    end

    subgraph "Documentation"
        README["README.md"]:::docs
        PrivacyPolicy["Privacy-Policy.md"]:::docs
        License["LICENSE"]:::docs
    end

    LinkedInPage -->|"Injected by manifest.json"| ContentScript
    ContentScript -->|"MutationObserver event"| LinkedInPage
    ContentScript -->|"chrome.storage.get()"| Storage
    PopupJS -->|"chrome.storage.get/set"| Storage
    SettingsJS -->|"chrome.storage.get/set"| Storage
    PopupHTML -->|"load UI"| PopupJS
    SettingsHTML -->|"load UI"| SettingsJS
    ContentScript -->|"POST /analyze (Fetch API)"| ExternalAI
    ExternalAI -->|"classification response"| ContentScript
    ContentScript -->|"DOM update (blur/remove)"| LinkedInPage

    click Manifest "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/manifest.json"
    click ContentScript "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/scripts/content.js"
    click PopupHTML "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/pages/popup.html"
    click PopupJS "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/scripts/popup.js"
    click SettingsHTML "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/pages/settings.html"
    click SettingsJS "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/scripts/settings.js"
    click Assets "https://github.com/pankajtanwarbanna/cringe-guard/tree/main/images/"
    click README "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/README.md"
    click PrivacyPolicy "https://github.com/pankajtanwarbanna/cringe-guard/blob/main/Privacy-Policy.md"
    click License "https://github.com/pankajtanwarbanna/cringe-guard/tree/main/LICENSE"

    classDef host fill:#cce5ff,stroke:#004085,color:#004085
    classDef ext fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef storage fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef docs fill:#f8d7da,stroke:#721c24,color:#721c24
```
