# shasnow/starrailassistant architecture

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

- Interactive diagram: https://gitdiagram.com/shasnow/starrailassistant
- Repository: https://github.com/shasnow/starrailassistant

## Overview

##### Project Overview
- SRA is an automation tool for the game “崩坏: 星穹铁道” that leverages image recognition and simulated user inputs to automate various in-game tasks (launching, reward collection, task automation, and more).
- The software is built in Python and uses a GUI (with PySide6/PyQt or similar libraries) and modularizes logic into separate components for core automation, extensions (like fun features or additional modules), utilities, and update mechanisms.
- There’s also integration with CI/CD pipelines via GitHub workflows, helping to automate tests and releases.

##### Main Components
a. Application Entry Point:
- SRA.py: The main script that launches the application.
b. Core Automation Engine:
- Modules under SRACore/core (e.g., SRAssistant.py, AutoPlot.py, SRACloud.py) that implement the main automation logic, game interaction, and possibly image recognition flows.
c. Extension Plugins:
- Modules inside SRACore/extensions (for example, FuXuanDivination.py and QTHandler.py) represent additional features. This area can be seen as plugin/extensions that enhance or customize behavior.
d. Utility Library:
- The SRACore/utils package (with modules like Configure.py, Dialog.py, Encryption.py, Logger.py, WindowsPower.py, and WindowsProcess.py) which provides common functionality such as configuration management, logging, error handling, encryption, and interacting with the underlying OS.
e. Updater:
- SRAUpdater.py and version.json indicate a built-in updater mechanism that handles self-updating based on version control.
f. Resources and UI Assets:
- The “res” folder holds images, UI layout files (e.g., .ui files from Qt Designer) which are used by the application’s graphical interface.
g. Packaging and Deployment:
- Files like package.py, requirements.txt, and tools (e.g., the 7z.exe in the tools folder) hint at packaging/deployment support.
h. CI/CD and Community Contributions:
- The presence of .github workspaces and workflows demonstrate automated build, test, and release pipelines.

##### Relationships and Interactions
- The user (or automated process) starts the application via SRA.py.
- SRA.py invokes the core modules (from SRACore/core) and coordinates with the extensions (from SRACore/extensions) to execute game automation tasks.
- Utilities (SRACore/utils) are used by both the core and extension modules to handle configuration, logging, and OS-level interactions (e.g., manipulating Windows processes or power states).
- The GUI and interface components, stored in the “res” directory, are loaded by the appropriate modules (likely mediated by QT or PySide calls) to display the automation interface.
- The updater (SRAUpdater.py) may run either before launch or as a separate process to check version.json and handle automatic updates.
- CI/CD pipelines (.github/workflows) run automated tests and release scripts based on changes in the repository.

##### Architectural Patterns and Design Principles
- Modularization: The clear separation into “core”, “extensions”, and “utils” helps to manage responsibilities.
- Plugin/Extension architecture: The use of extensions indicates that features can be added or modified with minimal changes to the core.
- Separation of Concerns: Dividing UI resources from business logic and update mechanism ensures clarity.
- Automation and CI/CD: GitHub workflows support continuous integration.

##### Technologies, Frameworks, and Tools
- Programming Language: Python.
- GUI Framework: Likely PySide6 or PyQt (as indicated by mentions in the README).
- Image recognition & simulated operations: Fundamental for the automation tasks (though the libraries are not directly named in the file tree, they are implied by functionality).
- Build/Package Tools: Requirements file and packaging scripts, along with external tools like 7z.exe.
- CI/CD: GitHub Actions workflows.

##### Final Advice for the Principal Software Engineer
- Break out the plugin/extensions as optional add-ons that interface with the core system.
- Encapsulate utilities as supporting layers that are shared by both the core and extensions.
- Do not forget to include the updater flow that connects version checking and update execution.
- Incorporate the CI/CD pipelines as a separate side-panel or integration point, linking to the development and deployment lifecycle.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction Layer
    subgraph "User Interaction Layer"
        ui1("UI Assets (res/ui)"):::ui
    end

    %% Application Entry Point
    entry("SRA.py (Entry Point)"):::entry

    %% Core Automation Engine
    subgraph "Core Automation Engine"
        core1("SRAssistant.py"):::core
        core2("AutoPlot.py"):::core
        core3("SRACloud.py"):::core
    end

    %% Extension Plugins
    subgraph "Extension Plugins"
        ext1("FuXuanDivination.py"):::ext
        ext2("QTHandler.py"):::ext
    end

    %% Utilities
    subgraph "Utilities"
        util1("Configure.py"):::util
        util2("Dialog.py"):::util
        util3("Encryption.py"):::util
        util4("Logger.py"):::util
        util5("WindowsPower.py"):::util
        util6("WindowsProcess.py"):::util
    end

    %% Updater & Deployment
    subgraph "Updater & Deployment"
        upd1("SRAUpdater.py"):::updater
        upd2("version.json"):::updater
        dep1("package.py"):::pkg
        dep2("requirements.txt"):::pkg
        dep3("7z.exe (tools)"):::pkg
    end

    %% CI/CD & Repository
    subgraph "CI/CD & Repository"
        ci1("mirrorchyan.yml"):::ci
        ci2("mirrorchyan_release_note.yml"):::ci
        ci3("python-app.yml"):::ci
    end

    %% External Component
    game("Game Client"):::external

    %% Connections
    entry -->|"invokes"| core1
    entry -->|"invokes"| core2
    entry -->|"invokes"| core3
    entry -->|"loadsUI"| ui1

    core1 -->|"uses"| util1
    core1 -->|"uses"| util2
    core1 -->|"uses"| util3
    core1 -->|"uses"| util4
    core1 -->|"uses"| util5
    core1 -->|"uses"| util6

    core1 -->|"integrates"| ext1
    core1 -->|"integrates"| ext2

    core1 -->|"interacts"| game
    core2 -->|"interacts"| game
    core3 -->|"interacts"| game

    upd1 -->|"checks"| upd2
    upd1 -->|"updates"| entry

    dep1 -->|"deploys"| entry
    dep2 -->|"deploys"| entry
    dep3 -->|"deploys"| entry

    ci1 -->|"triggersBuild"| entry
    ci2 -->|"automatesTests"| entry
    ci3 -->|"releases"| entry

    %% Styles
    classDef entry fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef core fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef ext fill:#ccffcc,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef util fill:#fffacd,stroke:#333,stroke-width:2px;
    classDef updater fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef pkg fill:#ccffff,stroke:#333,stroke-width:2px;
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef ci fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:2px,stroke-dasharray: 2 2;

    %% Click Events
    click entry "https://github.com/shasnow/starrailassistant/blob/main/SRA.py"
    click core1 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/core/SRAssistant.py"
    click core2 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/core/AutoPlot.py"
    click core3 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/core/SRACloud.py"
    click ext1 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/extensions/FuXuanDivination.py"
    click ext2 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/extensions/QTHandler.py"
    click util1 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/Configure.py"
    click util2 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/Dialog.py"
    click util3 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/Encryption.py"
    click util4 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/Logger.py"
    click util5 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/WindowsPower.py"
    click util6 "https://github.com/shasnow/starrailassistant/blob/main/SRACore/utils/WindowsProcess.py"
    click upd1 "https://github.com/shasnow/starrailassistant/blob/main/SRAUpdater.py"
    click upd2 "https://github.com/shasnow/starrailassistant/blob/main/version.json"
    click dep1 "https://github.com/shasnow/starrailassistant/blob/main/package.py"
    click dep2 "https://github.com/shasnow/starrailassistant/blob/main/requirements.txt"
    click dep3 "https://github.com/shasnow/starrailassistant/blob/main/tools/7z.exe"
    click ui1 "https://github.com/shasnow/starrailassistant/tree/main/res/ui"
    click ci1 "https://github.com/shasnow/starrailassistant/blob/main/.github/workflows/mirrorchyan.yml"
    click ci2 "https://github.com/shasnow/starrailassistant/blob/main/.github/workflows/mirrorchyan_release_note.yml"
    click ci3 "https://github.com/shasnow/starrailassistant/blob/main/.github/workflows/python-app.yml"
```
