# zhenda-hub/random_recipe architecture

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

- Interactive diagram: https://gitdiagram.com/zhenda-hub/random_recipe
- Repository: https://github.com/zhenda-hub/random_recipe

## Overview

##### Project Type and Purpose
- This is a standalone desktop application built with Python and PyQt5.
- It provides a “random choice” utility: users load or edit option pools (stored as text files), click a button, and the tool picks an item at random.

##### File‐Structure Analysis
- Top level:
- main_gui.py – entry point, sets up the Qt application and main window.
- requirements.txt & freeze.yml – environment and dependency specs.
- settings/ – folder of plain‑text option pools (e.g., “美食.txt”, “旅游地选择.txt”).
- ui/ – Qt Designer files (.ui) and their Python wrappers (random_recipe.py, random_recipe2.py).
- Patterns:
- UI layer separated into .ui and generated Python wrappers.
- Configuration as text resources, loaded at runtime.
- Business logic (random selection, config management) in main_gui.py or imported modules.

##### Key README Insights
- Built on PyQt5.
- Users can freely add/remove option files.
- Packaged via PyInstaller for distribution.

##### Detailed Checklist
- [ ] UI Layer: .ui files → Python wrappers → Qt Widgets
- [ ] Controller: main_gui.py binds UI to services
- [ ] Random‐Selection Service: logic module
- [ ] Configuration Data: settings/*.txt
- [ ] Static Resources: statics/food.ico, images
- [ ] External Dependencies: PyQt5, Python runtime
- [ ] Build/Packaging: PyInstaller step

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies
    subgraph "External Dependencies"
        REQ["requirements.txt"]:::ext
        FRZ["freeze.yml"]:::ext
    end

    %% UI Layer
    subgraph "UI Layer"
        UI1["random_recipe.ui"]:::ui
        UI2["random_recipe2.ui"]:::ui
        WR1["random_recipe.py"]:::ui
        WR2["random_recipe2.py"]:::ui
    end

    %% Controller / Application Logic
    CTRL["main_gui.py"]:::logic

    %% Random-Selection Service
    RS["Random-Selection Service"]:::logic

    %% Data & Resources
    subgraph "Data & Resources"
        CFG1["美食.txt"]:::data
        CFG2["旅游地选择.txt"]:::data
        CFG3["不同权重的选项设置.txt"]:::data
        CFG4["选购手机.txt"]:::data
        STAT["statics/"]:::data
    end

    %% Packaging Layer
    PKG["PyInstaller Packaging"]:::pkg

    %% Connections
    REQ -->|supports| CTRL
    FRZ -->|supports| CTRL

    UI1 -->|generates wrapper| WR1
    UI2 -->|generates wrapper| WR2
    WR1 -->|binds signals| CTRL
    WR2 -->|binds signals| CTRL

    CTRL -->|loads UI| WR1
    CTRL -->|loads UI| WR2
    CTRL -->|reads config| CFG1
    CTRL -->|reads config| CFG2
    CTRL -->|reads config| CFG3
    CTRL -->|reads config| CFG4
    CTRL -->|loads icon/image| STAT
    CTRL -->|invokes| RS
    RS -->|returns result| CTRL
    CTRL -->|updates UI| WR1
    CTRL -->|updates UI| WR2

    CTRL -->|packaged by| PKG
    STAT -->|included in| PKG

    %% Click Events
    click UI1 "https://github.com/zhenda-hub/random_recipe/blob/master/ui/random_recipe.ui"
    click UI2 "https://github.com/zhenda-hub/random_recipe/blob/master/ui/random_recipe2.ui"
    click WR1 "https://github.com/zhenda-hub/random_recipe/blob/master/ui/random_recipe.py"
    click WR2 "https://github.com/zhenda-hub/random_recipe/blob/master/ui/random_recipe2.py"
    click CTRL "https://github.com/zhenda-hub/random_recipe/blob/master/main_gui.py"
    click CFG1 "https://github.com/zhenda-hub/random_recipe/blob/master/settings/美食.txt"
    click CFG2 "https://github.com/zhenda-hub/random_recipe/blob/master/settings/旅游地选择.txt"
    click CFG3 "https://github.com/zhenda-hub/random_recipe/blob/master/settings/不同权重的选项设置.txt"
    click CFG4 "https://github.com/zhenda-hub/random_recipe/blob/master/settings/选购手机.txt"
    click STAT "https://github.com/zhenda-hub/random_recipe/tree/master/statics/"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef logic fill:#d4edda,stroke:#155724,color:#155724
    classDef data fill:#fff3cd,stroke:#856404,color:#856404
    classDef ext fill:#e2e3e5,stroke:#d6d8db,color:#383d41
    classDef pkg fill:#f8d7da,stroke:#721c24,color:#721c24,stroke-dasharray: 5 5
```
