# diygod/rsshub-radar architecture

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

## Overview

##### Main Components

a. Browser Extension Components:
- Popup Interface (src/popup)
- Options Page (src/options)
- Background Service Worker (src/background)
- Content Scripts (src/contents)
- Sandboxed Scripts (src/sandboxes)

b. Core Services:
- RSS Detection System
- RSSHub Integration
- Rules Engine
- Feed Management System

##### Key Architectural Elements

**┌─ Browser Extension UI Layer ─┐**
- Popup Interface           │
- Options Pages            │
- Preview Pages            │
- ┘
- ↕
**┌─ Core Processing Layer ──────┐**
- Rules Engine              │
- RSS Detection             │
- RSSHub Integration        │
- ┘
- ↕
**┌─ Background Services Layer ──┐**
- Badge Management          │
- Message Handling          │
- Update Notifications      │
- ┘
- ↕
**┌─ External Integration Layer ─┐**
- RSS Readers               │
- RSSHub Servers           │
- Website Content          │
- ┘

##### Component Relationships

- Message passing between components (→)
- Data flow (⇢)
- Dependencies (-->)

##### Implementation Details

Technical elements:
- React components (src/lib/components)
- Localization system (locales/)
- Configuration management
- Hook system (src/lib/hooks)

##### Additional Notes

- Separation between privileged and unprivileged contexts
- Rules system as it's central to the extension's functionality
- Quick subscription system
- How the extension integrates with various RSS readers

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef background fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef critical fill:#e74c3c,stroke:#c0392b,color:white

    subgraph BrowserExtensionUI["Browser Extension UI Layer"]
        PopupUI["Popup Interface"]:::ui
        OptionsUI["Options Pages"]:::ui
        PreviewUI["Preview Pages"]:::ui
        ReactComponents["React Components"]:::ui
    end

    subgraph CoreProcessing["Core Processing Layer"]
        RulesEngine["Rules Engine"]:::core
        RSSDetection["RSS Detection"]:::core
        RSSHubIntegration["RSSHub Integration"]:::core
        QuickSub["Quick Subscription System"]:::core
        Hooks["Hooks System"]:::core
    end

    subgraph BackgroundServices["Background Services Layer"]
        BadgeMgmt["Badge Management"]:::background
        MessageHandler["Message Handling"]:::background
        UpdateNotif["Update Notifications"]:::background
        BGWorker["Background Service Worker"]:::background
        ContentScripts["Content Scripts"]:::background
        SandboxedScripts["Sandboxed Scripts"]:::background
    end

    subgraph ExternalIntegration["External Integration Layer"]
        RSSReaders["RSS Readers"]:::external
        RSSHubServers["RSSHub Servers"]:::external
        WebContent["Website Content"]:::external
    end

    %% Relationships
    PopupUI --> RulesEngine
    PopupUI --> RSSDetection
    OptionsUI --> RulesEngine
    PreviewUI --> RSSDetection
    ReactComponents --> Hooks

    RulesEngine --> RSSHubIntegration
    RSSDetection --> QuickSub
    RSSHubIntegration --> RSSHubServers
    
    BGWorker --> BadgeMgmt
    BGWorker --> MessageHandler
    BGWorker --> UpdateNotif
    
    ContentScripts --> WebContent
    SandboxedScripts --> RSSDetection
    
    QuickSub --> RSSReaders
    
    %% Click Events
    click PopupUI "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/popup/index.tsx"
    click OptionsUI "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/options/index.tsx"
    click PreviewUI "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/tabs/preview.tsx"
    click RulesEngine "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/lib/rules.ts"
    click RSSDetection "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/lib/rss.ts"
    click RSSHubIntegration "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/lib/rsshub.ts"
    click BadgeMgmt "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/background/badge.ts"
    click MessageHandler "https://github.com/DIYgod/RSSHub-Radar/tree/dev/src/background/messages"
    click UpdateNotif "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/background/update-notifications.ts"
    click ReactComponents "https://github.com/DIYgod/RSSHub-Radar/tree/dev/src/lib/components"
    click QuickSub "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/lib/quick-subscriptions.ts"
    click Hooks "https://github.com/DIYgod/RSSHub-Radar/tree/dev/src/lib/hooks"
    click ContentScripts "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/contents/index.ts"
    click BGWorker "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/background/index.ts"
    click SandboxedScripts "https://github.com/DIYgod/RSSHub-Radar/blob/dev/src/sandboxes/index.ts"

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Core["Core Component"]:::core
        BG["Background Service"]:::background
        Ext["External Service"]:::external
    end
```
