# thiojoe/yt-spammer-purge architecture

> Architecture diagram of the GitHub repository thiojoe/yt-spammer-purge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thiojoe/yt-spammer-purge
- Repository: https://github.com/thiojoe/yt-spammer-purge

## Overview

##### Main Components
- User Interface Layer: Represent both the CLI (via the main script “YTSpammerPurge.py”) and GUI (in Scripts/gui.py).
- Authentication & API Communication Module: Show components handling the OAuth2 flow (referencing Scripts/auth.py) and any API credential management using a local “client_secret.json” file.
- Utility Modules: Include utilities like logging (Scripts/logging.py), shared imports (Scripts/shared_imports.py), and custom text handling (the “confusablesCustom” submodule).
- Configuration & Assets Management: Mark out configuration management using the “assets” folder (which includes config INI files and spam lists) and resource files handled by the install process.
- External Services: Highlight the interaction with the YouTube Data API (and by extension, the Google Cloud project). Also note that Docker (via Dockerfile and docker-compose files) provides an alternative deployment environment.

##### Out the Relationships & Data Flow
- The UI component processes user inputs (either via a command-line interface or a GUI) and passes commands to the core engine.
- The Core Engine then invokes the filtering engine, which uses various filtering modules to analyze fetched YouTube comments.
- Authentication and API Communication Modules grab the necessary OAuth2 credentials, establish communication with the YouTube Data API, and handle requests (like fetching comments, deleting, marking, or reporting spam).
- Configuration and Assets modules supply required settings, spam lists, and other supporting data.
- Utility modules (logging, helper functions, and confusables processing) support the logical flow and track detailed logs.
- Finally, the results and operations (such as deletion or reporting) flow back to the UI, and the system also produces log files or recovery options as needed.
- For containerized deployments, an additional “Docker Layer” can wrap the entire application, with volumes binding local configuration and token files into the container.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project clearly differentiates between user-interface (CLI/GUI), core logic (filtering/operations), authentication/API layer, and auxiliary utilities.
- Modularity: Each Python script is dedicated to a specific part of the application, making the system extensible.
- External Integration: A strong dependency exists on the YouTube Data API for fetching and updating comment statuses as well as on external configuration (assets and API keys).
- Containerization: The design supports Docker for consistent deployment across environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction Layer
    subgraph "User Interaction"
        U("User"):::user
        CLI("User Interface (CLI)"):::ui
        GUI("User Interface (GUI)"):::ui
    end
    U --> CLI
    U --> GUI

    %% Core System
    subgraph "Core System"
        CE("Core Engine / Control Flow"):::core

        subgraph "Authentication & API Communication"
            Auth("Auth & API Handler"):::auth
        end

        subgraph "Filtering/Scanning Engine"
            FV("Filtering Variables"):::filter
            MP("Mode Preparation"):::filter
            OP("Operations"):::filter
        end

        subgraph "Utility Modules"
            LG("Logging"):::util
            SI("Shared Imports"):::util
            CC("Confusables Handling"):::util
        end

        CA("Configuration & Assets"):::config
    end

    CLI --> CE
    GUI --> CE
    CE --> Auth
    CE --> FV
    CE --> MP
    CE --> OP
    CE --> LG
    CE --> SI
    CE --> CC
    CE --> CA

    %% External Services
    API("YouTube Data API"):::external
    Auth -->|"OAuth2+API"| API
    API -- "responses" --> Auth

    %% Containerized Deployment Support
    DO("Docker Deployment Support"):::docker
    DO --> CE
    DO --> CA

    %% Click Events
    click CLI "https://github.com/thiojoe/yt-spammer-purge/blob/main/YTSpammerPurge.py"
    click GUI "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/gui.py"
    click Auth "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/auth.py"
    click FV "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/filter_variables.py"
    click MP "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/prepare_modes.py"
    click OP "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/operations.py"
    click LG "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/logging.py"
    click SI "https://github.com/thiojoe/yt-spammer-purge/blob/main/Scripts/shared_imports.py"
    click CC "https://github.com/thiojoe/yt-spammer-purge/tree/main/Scripts/confusablesCustom"
    click CA "https://github.com/thiojoe/yt-spammer-purge/tree/main/assets"
    click DO "https://github.com/thiojoe/yt-spammer-purge/tree/main/Dockerfile"

    %% Styles
    classDef user fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef ui fill:#b3d7ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef auth fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef filter fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef util fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef config fill:#fefefe,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef docker fill:#ffeeba,stroke:#fd7e14,stroke-width:2px;
```
