# itousouta15/pyas architecture

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

- Interactive diagram: https://gitdiagram.com/itousouta15/pyas
- Repository: https://github.com/itousouta15/pyas

## Overview

##### Project Type and Purpose
- PYAS is a Windows desktop antivirus application.
- It combines a GUI frontend (PyQt5), a scanning engine (deep-learning + YARA rules), a kernel-mode protection driver, and auxiliary repair/tools scripts.

##### File Structure
- Top-level folders:
- Driver/ – kernel driver (.sys), installer/uninstaller scripts, digital signing tool, Microsoft VC redistributable.
- Engine/ – deep learning models (ONNX), YARA rule files (.yar/.ips).
- Extens/ – system-repair scripts and auxiliary tools.
- Top-level Python modules:
- PYAS.py – main application logic + GUI integration + protection hooks
- PYAS_Engine.py – scanning logic (loads ONNX model, runs YARA scans)
- PYAS_Interface.py – Qt Designer UI definitions
- PYAS_Language.py – i18n (EN, ZH-CN, ZH-TW)
- PYAS_Suffixes.py – file-suffix lists for scanning
- PYAS_Version.py – versioning and metadata

##### README for Additional Insights
- Confirms Windows-only support, Python dependencies (PyQt5, ONNXRuntime, yara-python, etc.), and external runtime requirements (VC_redist).
- No external online service, but “requests” is installed—likely for updates or signature downloads.

##### Main Architectural Components
a. Presentation Layer (GUI)
- PyQt5 application (PYAS.py + PYAS_Interface.py + language & resource modules)
b. Application Logic
- PYAS.py orchestrates user actions, feeds file paths to engine, triggers driver protection calls
c. Scanning Engine
- Deep-learning model loader (ONNX via onnxruntime)
- YARA rule matcher (yara-python)
- pefile for PE parsing, numpy, pillow for file handling, pyperclip for clipboard integration
d. Protection Driver
- PYAS_Driver.sys loaded/unloaded via batch scripts
- Communicates with user-mode via IOCTLs (implied)
e. Extensions
- Repair scripts (regedit, batch) and auxiliary tools invoked from within UI or standalone

##### Interactions and Data Flows
1. User clicks “Scan” in UI →
2. Main app (PYAS.py) calls scanning API in PYAS_Engine.py →
3. Engine loads model (PYAS_Model_A1.onnx) and rules (PYAS_Rules_A1.yar) →
4. Engine returns verdicts →
6. If “Real-time Protection” is enabled, PYAS.py sends control codes to kernel driver →
7. Driver intercepts file operations at the kernel level to enforce blocking/quarantine.
8. Repair/Tools: accessed via menu, launch Extens/Repair/*.bat or Extens/Tools/*.txt

##### Architectural Patterns & Design Principles
- Layered architecture: Presentation → Application → Engine → System (driver)
- Modular separation: UI, engine, data (models/rules), system hooks
- Pluggable rules/models: Easy to swap ONNX or YARA files without code changes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        PYAS["PYAS.py"]:::python
        Interface["PYAS_Interface.py"]:::python
        Resource["PYAS_Resource.py"]:::python
        Language["PYAS_Language.py"]:::python
        Version["PYAS_Version.py"]:::python
        Suffixes["PYAS_Suffixes.py"]:::python
    end

    %% Scanning Engine
    subgraph "Scanning Engine"
        direction TB
        EngineCode["PYAS_Engine.py"]:::python
        subgraph "Model Storage"
            direction TB
            ModelJSON["PYAS_Model.json"]:::datastore
            ONNXModel["PYAS_Model_A1.onnx"]:::datastore
        end
        subgraph "YARA Rules"
            direction TB
            RuleA["PYAS_Rules_A1.yar"]:::datastore
            RuleB["PYAS_Rules_B1.ips"]:::datastore
        end
    end

    %% Protection Driver
    subgraph "Protection Driver"
        direction TB
        DriverBin["PYAS_Driver.sys"]:::driver
        InstallScript["Install_Driver.bat"]:::script
        UninstallScript["Uninstall_Driver.bat"]:::script
        SignTool["signtool.exe"]:::script
        Cert["PYAS.pfx"]:::script
        VC["VC_redist.x64.exe"]:::script
    end

    %% Extensions
    subgraph "Extensions"
        direction TB
        RepairReg["Repair_Regedit.reg"]:::script
        RepairSys["Repair_System.bat"]:::script
        ToolsList["Tools.txt"]:::script
    end

    %% External Updates
    External["External Updates (requests)"]:::external

    %% Data Flows
    PYAS -->|"scan()"| EngineCode
    EngineCode -->|"load ONNX model"| ONNXModel
    EngineCode -->|"load rules"| RuleA
    EngineCode -->|"load rules"| RuleB
    EngineCode -->|"return verdicts"| PYAS
    PYAS -->|"send Protect IOCTL"| DriverBin
    PYAS -->|"invoke repair/tools"| RepairSys
    External -.->|"check updates"| PYAS

    %% Click Events
    click PYAS "https://github.com/itousouta15/pyas/blob/main/PYAS.py"
    click Interface "https://github.com/itousouta15/pyas/blob/main/PYAS_Interface.py"
    click Resource "https://github.com/itousouta15/pyas/blob/main/PYAS_Resource.py"
    click Language "https://github.com/itousouta15/pyas/blob/main/PYAS_Language.py"
    click Version "https://github.com/itousouta15/pyas/blob/main/PYAS_Version.py"
    click Suffixes "https://github.com/itousouta15/pyas/blob/main/PYAS_Suffixes.py"
    click EngineCode "https://github.com/itousouta15/pyas/blob/main/PYAS_Engine.py"
    click ModelJSON "https://github.com/itousouta15/pyas/blob/main/Engine/Model/PYAS_Model.json"
    click ONNXModel "https://github.com/itousouta15/pyas/blob/main/Engine/Model/PYAS_Model_A1.onnx"
    click RuleA "https://github.com/itousouta15/pyas/blob/main/Engine/Rules/PYAS_Rules_A1.yar"
    click RuleB "https://github.com/itousouta15/pyas/blob/main/Engine/Rules/PYAS_Rules_B1.ips"
    click DriverBin "https://github.com/itousouta15/pyas/blob/main/Driver/Protect/PYAS_Driver.sys"
    click InstallScript "https://github.com/itousouta15/pyas/blob/main/Driver/Protect/Install_Driver.bat"
    click UninstallScript "https://github.com/itousouta15/pyas/blob/main/Driver/Protect/Uninstall_Driver.bat"
    click SignTool "https://github.com/itousouta15/pyas/blob/main/Driver/Protect/signtool.exe"
    click Cert "https://github.com/itousouta15/pyas/blob/main/Driver/Protect/PYAS.pfx"
    click VC "https://github.com/itousouta15/pyas/blob/main/Driver/Runtime/VC_redist.x64.exe"
    click RepairReg "https://github.com/itousouta15/pyas/blob/main/Extens/Repair/Repair_Regedit.reg"
    click RepairSys "https://github.com/itousouta15/pyas/blob/main/Extens/Repair/Repair_System.bat"
    click ToolsList "https://github.com/itousouta15/pyas/blob/main/Extens/Tools/Tools.txt"

    %% Styles
    classDef python fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef datastore fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef driver fill:#ffcccc,stroke:#333,stroke-width:1px
    classDef script fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef external fill:#f9e79f,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
