# happycola233/tchmaterial-parser architecture

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

- Interactive diagram: https://gitdiagram.com/happycola233/tchmaterial-parser
- Repository: https://github.com/happycola233/tchmaterial-parser

## Overview

##### Project type and purpose
- This is a **desktop GUI application** written in Python (single‐script monolith) whose purpose is to **fetch and download PDF electronic textbooks** from the “国家中小学智慧教育平台” by parsing preview page URLs, managing an Access Token for authentication, and saving the files locally with automatic naming and progress visualization.

##### File structure
- Top-level files:
- `.github/workflows/python-app.yml` – CI pipeline for linting/testing.
- `requirements.txt` – Python dependencies (likely including GUI and HTTP libraries).
- `src/tchMaterial-parser.pyw` – the entire application code (GUI + core logic).
- No separate “frontend”/“backend” folders; the project is a single‐entry Python GUI app.
- Configuration: uses platform‐specific storage: Windows Registry, `~/.config/.../data.json` on Linux, in‐memory on macOS.

##### README for additional insights
- UI features: high-DPI adaptation, progress bar with pause/resume.
- Auth: manual Access Token input and storage.
- Batch URL parsing, automatic file naming.
- Cross‐platform support: Windows/Linux/macOS.
- External dependency: “国家中小学智慧教育平台” API endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    GUI["User Interface (GUI Layer)"]:::app
    Auth["Auth Module"]:::app
    subgraph "Token Storage Adapters"
        WinReg["Windows Registry"]:::storage
        ConfigFile["Config File (~/.config)"]:::storage
        InMemory["In-Memory (macOS)"]:::storage
    end
    Parser["URL Parser & Request Scheduler"]:::app
    HTTP["HTTP Download Engine"]:::app
    FileMgr["File Manager"]:::app
    External["External Service (智慧教育平台 API)"]:::external
    subgraph "Infrastructure & Resources"
        CI["CI Pipeline"]:::infra
        Res["Static Resources"]:::infra
        Req["Python Dependencies"]:::infra
        Doc["Project Documentation"]:::infra
    end

    GUI -->|"set/load token"| Auth
    Auth -->|"uses adapter"| WinReg
    Auth --> ConfigFile
    Auth --> InMemory
    GUI -->|"Download click"| Parser
    Parser -->|"download tasks"| HTTP
    HTTP -->|"GET requests with token"| External
    HTTP -->|"stream PDF"| FileMgr
    HTTP -->|"pause/resume events"| GUI
    FileMgr -->|"progress/completion events"| GUI

    click GUI "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click Auth "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click WinReg "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click ConfigFile "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click InMemory "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click Parser "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click HTTP "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click FileMgr "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click External "https://github.com/happycola233/tchmaterial-parser/blob/main/src/tchMaterial-parser.pyw"
    click Res "https://github.com/happycola233/tchmaterial-parser/tree/main/res/"
    click CI "https://github.com/happycola233/tchmaterial-parser/blob/main/.github/workflows/python-app.yml"
    click Req "https://github.com/happycola233/tchmaterial-parser/blob/main/requirements.txt"
    click Doc "https://github.com/happycola233/tchmaterial-parser/blob/main/README.md"

    classDef app fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px,shape:cylinder
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px,shape:cloud
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px
```
