# tonquer/picacg-qt architecture

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

- Interactive diagram: https://gitdiagram.com/tonquer/picacg-qt
- Repository: https://github.com/tonquer/picacg-qt

## Overview

##### Project type and purpose
- This is a cross-platform desktop client (“哔咔漫画PC客户端”) for browsing and downloading comics from the PicACG service.
- It uses PyQt (Qt) for its GUI, Python 3.9+ for business logic, and packages for Windows, Linux and macOS.

##### File structure
- Top‐level:
- src/ – main Python code
– component/ – custom Qt widgets (buttons, dialogs, sliders, frameless windows)
– interface/ – .ui files converted to Python: the raw Qt Designer forms
– view/ – MVC “views” that compose components and interface into screens (login, search, read, download, chat, settings…)
– server/ – internal HTTP server and API layer that mediates between GUI and data tasks
– task/ – background worker modules (download, convert, upload, SQL operations)
– db/ – local SQLite database (book.db)
– config/, tools/ – global configs and utility functions
– start.py – application bootstrapper
- script/ – build helpers for .ui, .qrc, translations, packaging
- README, CI workflows, packaging scripts (build_mac.sh), release assets
- This clearly follows an MVC/MVVM‐like pattern: UI forms + custom widgets (View), view classes (MVVM “ViewModels”), server/tasks (Controller), DB/files (Model).

##### README for additional insights
- Confirms: PyQt, waifu2x (GPU/Vulkan image upscaling), SQLite local cache, multi‐OS packaging.
- Highlights features: browse comics, download, read, chat, proxy support, themes, translations.

##### Elements
- Blue: Presentation (Qt)
- Green: Application Logic (server & tasks)
- Orange: Data (SQLite, config, resources)
- Gray: External Systems (PicACG API, waifu2x, SMB/WebDAV)

##### Detail
– Show the internal server’s handler modules (req.py, res.py, user_handler.py)
– Include build & packaging scripts off to one side (script/, build_mac.sh, CI.yml)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Interface["UI Forms (src/interface/)"]:::presentation
        Component["Custom Widgets (src/component/)"]:::presentation
        View["View Classes (src/view/)"]:::presentation
    end

    subgraph "Application Logic Layer"
        Server["Internal HTTP Server (src/server/server.py)"]:::logic
        subgraph "Handlers"
            UserH["User Handler (src/server/user_handler.py)"]:::logic
            SQLH["SQL Handler (src/server/sql_server.py)"]:::logic
        end
        subgraph "Models"
            Req["Request Models (src/server/req.py)"]:::logic
            Res["Response Models (src/server/res.py)"]:::logic
        end
        Scheduler["Task Scheduler & Workers (src/task/)"]:::logic
    end

    subgraph "Data Layer"
        DB["SQLite Cache (src/db/book.db)"]:::data
        Config["Configuration (src/config/)"]:::data
        Tools["Utility Tools (src/tools/)"]:::data
        Resources["Resources (res/)"]:::data
        Translate["Translations (translate/)"]:::data
    end

    subgraph "Packaging & CI"
        BuildUI["UI Compiler (script/build_ui.py)"]:::data
        BuildQRC["QRC Compiler (script/build_qrc.py)"]:::data
        BuildUni["Universal Mac Build (script/build_universal2.py)"]:::data
        BuildMac["Mac Packaging (build_mac.sh)"]:::data
        CI1["CI Workflow (.github/workflows/CI.yml)"]:::data
        CI2["Release Workflow (.github/workflows/release.yml)"]:::data
    end

    subgraph "External Services"
        PicACG["PicACG HTTP API"]:::external
        Waifu["waifu2x (Vulkan)"]:::external
        Storage["Network Storage (SMB/WebDAV)"]:::external
    end

    Interface -->|HTTP request| Server
    Component -->|signal/slot| View
    View -->|UI action| Server
    Server -->|dispatch| UserH
    Server -->|dispatch| SQLH
    Server -->|uses| Req
    Server -->|uses| Res
    Server -->|enqueues| Scheduler
    UserH -->|respond| Res
    SQLH -->|query/write| DB
    Scheduler -->|read/write| DB
    Scheduler -->|fetch| PicACG
    Scheduler -->|upscale| Waifu
    Scheduler -->|sync| Storage
    Server -->|HTTP response| Interface

    click Interface "https://github.com/tonquer/picacg-qt/tree/main/src/interface/"
    click Component "https://github.com/tonquer/picacg-qt/tree/main/src/component/"
    click View "https://github.com/tonquer/picacg-qt/tree/main/src/view/"
    click Server "https://github.com/tonquer/picacg-qt/blob/main/src/server/server.py"
    click UserH "https://github.com/tonquer/picacg-qt/blob/main/src/server/user_handler.py"
    click SQLH "https://github.com/tonquer/picacg-qt/blob/main/src/server/sql_server.py"
    click Req "https://github.com/tonquer/picacg-qt/blob/main/src/server/req.py"
    click Res "https://github.com/tonquer/picacg-qt/blob/main/src/server/res.py"
    click Scheduler "https://github.com/tonquer/picacg-qt/tree/main/src/task/"
    click DB "https://github.com/tonquer/picacg-qt/blob/main/src/db/book.db"
    click Config "https://github.com/tonquer/picacg-qt/tree/main/src/config/"
    click Tools "https://github.com/tonquer/picacg-qt/tree/main/src/tools/"
    click Resources "https://github.com/tonquer/picacg-qt/tree/main/res/"
    click Translate "https://github.com/tonquer/picacg-qt/tree/main/translate/"
    click BuildUI "https://github.com/tonquer/picacg-qt/blob/main/script/build_ui.py"
    click BuildQRC "https://github.com/tonquer/picacg-qt/blob/main/script/build_qrc.py"
    click BuildUni "https://github.com/tonquer/picacg-qt/blob/main/script/build_universal2.py"
    click BuildMac "https://github.com/tonquer/picacg-qt/blob/main/build_mac.sh"
    click CI1 "https://github.com/tonquer/picacg-qt/blob/main/.github/workflows/CI.yml"
    click CI2 "https://github.com/tonquer/picacg-qt/blob/main/.github/workflows/release.yml"

    classDef presentation fill:#D0E6FF,stroke:#0366D6,color:#0366D6
    classDef logic fill:#DFFFE0,stroke:#28A745,color:#28A745
    classDef data fill:#FFEFD0,stroke:#D99002,color:#D99002
    classDef external fill:#F0F0F0,stroke:#3C3C3C,color:#3C3C3C
```
