# ryuumeow/neverthinkautoreply architecture

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

- Interactive diagram: https://gitdiagram.com/ryuumeow/neverthinkautoreply
- Repository: https://github.com/ryuumeow/neverthinkautoreply

## Overview

##### Project type and purpose
- This is a Windows-only Python desktop application (“Never Think Auto Reply”) that listens for a global hotkey, captures text or images, runs AI/OCR processing, and automatically pastes reply content.

##### File structure
- Top-level scripts:
- NeverThinkAutoReply.py (entry point, GUI + orchestration)
- ocr_download.py (download OCR models)
- config.ini (runtime settings)
- src/ – modular code:
- src/api/llm.py – AI service adapter (OpenAI, Gemini, DeepSeek)
- src/configs.py – configuration loader
- src/utils/ – logging, file naming, clipboard copy helpers

##### Readme insights
- GUI framework: PySide6
- System-level hooks: pynput (hotkey), pyperclip (clipboard), pyautogui (paste/click), windows-toasts (notifications), pywin32
- OCR: easyocr + OpenCV
- AI backends: OpenAI API, HuggingFace model loading support

##### Main components and interactions
┌──────────────────┐        ┌───────────────────────────┐
│  1. Hotkey Listener  │───► │ 2. UI Dialog & Mode Selector │
└──────────────────┘        └───────────────────────────┘
│                              │
│                              ▼
│                   ┌────────────────────┐
│                   │ 3. Core Orchestrator │
│                   └────────────────────┘
│                              │
│         ┌──────────┬─────────┴─────────┬───────────┐
│         ▼          ▼                   ▼           ▼
┌────────────────┐  ┌──────────┐   ┌──────────────────────┐  ┌─────────────────┐
│4a. Clipboard   │  │4b. OCR   │   │4c. LLM API Adapter    │  │4d. Asset Manager │
│    Manager     │  │  Module  │   │  (OpenAI/HF/DeepSeek) │  │ (prompts/mygo/…) │
└────────────────┘  └──────────┘   └──────────────────────┘  └─────────────────┘
│             │                │                       │
└─────────────┴────────────────┴───────────────────────┘
▼
┌────────────────────┐
│5. Automation & UI  │
│   output (pyautogui,│
│ windows-toasts)     │
└────────────────────┘
│
▼
┌────────────────────┐
│6. Logging & Config │
└────────────────────┘

- Data flows from the hotkey event through the orchestrator into the selected mode (normal, rebut, sarcasm, MyGo/Mujica image, OCR).
- In OCR mode, image data routes via the OCR Module before entering the orchestrator.
- The LLM API Adapter is invoked for text-based modes; Asset Manager provides pre-bundled images for image modes.
- Output is automatically pasted and a Windows toast is shown. All steps are configurable via config.ini; operations are logged.

##### Architectural patterns and design principles
- Layered modular monolith: UI layer, orchestration layer, service adapters (LLM, OCR), utility layer (clipboard, logging), configuration
- Separation of concerns: each module has a single responsibility (hotkey, UI, AI, OCR, assets, notifications)
- Configuration-driven: behavior and API keys controlled by config.ini
- Extensibility points: adding new reply modes, swapping AI backends, dropping in new assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI/OS Interactions Layer
    subgraph "UI/OS Interactions"
        HotkeyListener["Hotkey Listener"]:::ui
        Clipboard["Clipboard Manager"]:::ui
        Automation["Automation & UI Output"]:::ui
    end

    %% Core Logic Layer
    subgraph "Core Logic"
        UIDialog["UI Dialog & Mode Selector"]:::core
        Orchestrator["Core Orchestrator"]:::core
    end

    %% Service Adapters Layer
    subgraph "Service Adapters"
        OCRDownload["OCR Model Download & Loader"]:::ext
        OCRModule["OCR Module"]:::ext
        LLM["LLM API Adapter"]:::ext
        ExternalAI["External AI API"]:::ext
    end

    %% Assets & Config & Logging
    subgraph "Assets, Config & Logging"
        Assets[(Assets)]:::data
        ConfigFile[(config.ini)]:::data
        ConfigLoader["Configuration Loader"]:::util
        Logger["Logging"]:::util
    end

    %% Connections
    HotkeyListener -->|hotkey event| UIDialog
    UIDialog -->|start| Orchestrator
    Orchestrator -->|text mode| Clipboard
    Orchestrator -->|OCR mode| OCRModule
    Orchestrator -->|AI mode| LLM
    Orchestrator -->|image mode| Assets
    OCRModule -->|download/initialize| OCRDownload
    LLM -->|call| ExternalAI
    Clipboard --> Automation
    OCRModule --> Automation
    LLM --> Automation
    Assets --> Automation
    Automation --> ConfigLoader
    Automation --> Logger
    UIDialog --> ConfigLoader
    Orchestrator --> ConfigLoader
    UIDialog --> Logger
    Orchestrator --> Logger

    %% Click Events
    click HotkeyListener "https://github.com/ryuumeow/neverthinkautoreply/blob/master/NeverThinkAutoReply.py"
    click UIDialog "https://github.com/ryuumeow/neverthinkautoreply/blob/master/NeverThinkAutoReply.py"
    click Orchestrator "https://github.com/ryuumeow/neverthinkautoreply/blob/master/NeverThinkAutoReply.py"
    click Clipboard "https://github.com/ryuumeow/neverthinkautoreply/blob/master/src/utils/copy_.py"
    click OCRDownload "https://github.com/ryuumeow/neverthinkautoreply/blob/master/ocr_download.py"
    click LLM "https://github.com/ryuumeow/neverthinkautoreply/blob/master/src/api/llm.py"
    click Assets "https://github.com/ryuumeow/neverthinkautoreply/tree/master/assets/"
    click Automation "https://github.com/ryuumeow/neverthinkautoreply/blob/master/NeverThinkAutoReply.py"
    click ConfigLoader "https://github.com/ryuumeow/neverthinkautoreply/blob/master/src/configs.py"
    click ConfigFile "https://github.com/ryuumeow/neverthinkautoreply/blob/master/config.ini"
    click Logger "https://github.com/ryuumeow/neverthinkautoreply/blob/master/src/utils/logger.py"

    %% Styles
    classDef ui fill:#d5f5e3,stroke:#27ae60,color:#145a32;
    classDef core fill:#aed6f1,stroke:#2e86c1,color:#1b4f72;
    classDef ext fill:#f9e79f,stroke:#d35400,color:#873600;
    classDef util fill:#d7dbdd,stroke:#7f8c8d,color:#2c3e50;
    classDef data fill:#fadbd8,stroke:#c0392b,color:#641e16;
```
