# novysodope/yunso architecture

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

- Interactive diagram: https://gitdiagram.com/novysodope/yunso
- Repository: https://github.com/novysodope/yunso

## Overview

##### Project Type & Purpose
- This is a Python-based bot script that integrates with WeChat using the wxauto library.
- Its purpose is multi-fold: (a) to monitor GitHub for new events and push updates to WeChat; (b) to offer GitHub content search functionality upon command; and (c) to interact with an AI service for conversational queries.
- The README mentions distinct classes (Yunso for monitoring, Yunsobt for searching, AiBot for AI model interactions), indicating a modular, class-based design centered around these functionalities.

##### File Structure Analysis
- The project is relatively simple with just four files:
– README.md: Provides detailed usage instructions, feature descriptions, and operational details.
– requirements.txt: Lists external dependencies (like wxauto and any other libraries necessary for GitHub and AI API interaction).
– yunso.py: The entry point that orchestrates the bot’s runtime behavior. It likely sets up scheduled tasks (monitoring every 30 minutes, weekly reports, etc.) and routes incoming WeChat messages.
– yunso_config.ini: Holds configuration details such as GitHub API key, target contact list, keyword lists, and AI API parameters.
- The lean file structure emphasizes that all the main logic is centralized within yunso.py and its class definitions.

##### Diagramming the Architecture
- Main Components:
– Entry Point/Controller (yunso.py): Responsible for initializing configuration, setting up periodic tasks, and coordinating between various modules.
– Configuration Module: Represents the use of yunso_config.ini, feeding the system with API keys, contact details, and keywords.
– GitHub Monitor (Yunso class): Handles periodic checks on GitHub for new events and then pushes notifications to WeChat.
– GitHub Search (Yunsobt class): Activated when the bot is mentioned with a search query; processes search requests and returns results via WeChat.
– AI Interaction (AiBot class): Handles interactions with an external AI service using provided API credentials.
– External Dependencies & Services:
- wxauto Library: Integrates with the WeChat client to send and receive messages.
- GitHub API: For obtaining repository events and search results.
- AI API: For processing AI-related queries.
– Heartbeat Module (part of the yunso.py loop): Ensures the script remains active and indicates its running state through periodic messages.

- Depicting Relationships and Interactions:
– Show that the Configuration Module feeds all three functional modules with necessary settings.

- Architectural Patterns & Design Principles:
– The design is modular, with clear separation into different operational classes.
– It shows a simple “scheduler and event-driven” pattern, where various events (timer-based or triggered by messages) lead to specific actions.
– Emphasize the single responsibility principle, with each class handling a dedicated aspect (monitoring, search, AI interaction).
– Note that the system is built for a Windows environment and has operational constraints (e.g., must keep WeChat open, avoid system lock).

##### Specific Elements
- Wxauto library as an “Interface Module” connecting the internal logic to the external WeChat client.
– The Yunso module interacts with the GitHub API.
– The Yunsobt module makes search queries to the GitHub API.
– The AiBot module communicates with the external AI service using the provided ai_key and ai_url.
- A note or visual indicator for the “heartbeat” mechanism that periodically confirms the script’s operational status.
- Optional annotations/notes about the operating environment (Windows, need for an active WeChat session, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Scheduling and Heartbeat Section
    Sched("Scheduler (30min,Weekly)"):::scheduler
    Heart("Heartbeat Monitor"):::scheduler

    %% Internal Modules Section
    EP("Entry Point (yunso.py)"):::controller
    Config("Configuration (yunso_config.ini)"):::config
    Monitor("GitHub Monitor (Yunso)"):::module
    Search("GitHub Search (Yunsobt)"):::module
    Ai("AI Interaction (AiBot)"):::module

    %% External Services Section
    Wx("wxauto/WeChat Client"):::external
    GHub("GitHub API"):::external
    AIAPI("AI API"):::external

    %% Scheduling interactions
    Sched -->|"triggers"| EP
    Sched -->|"signals"| Heart
    EP -->|"reports status"| Heart

    %% Entry Point initializes and loads configuration
    EP -->|"loads"| Config
    EP -->|"initializes"| Monitor
    EP -->|"initializes"| Search
    EP -->|"initializes"| Ai

    %% Configuration feeds settings to internal modules
    Config -->|"configures"| Monitor
    Config -->|"configures"| Search
    Config -->|"configures"| Ai

    %% Internal modules interact with external services
    Monitor -->|"polls"| GHub
    Search -->|"queries"| GHub
    Ai -->|"requests"| AIAPI

    Monitor -->|"notifies"| Wx
    Search -->|"sendsResults"| Wx
    Ai -->|"respondsVia"| Wx

    %% Class Definitions with colors
    classDef controller fill:#CAF0F8,stroke:#03045E,stroke-width:2px;
    classDef config fill:#FFDDD2,stroke:#E63946,stroke-width:2px;
    classDef module fill:#D8F3DC,stroke:#1B4332,stroke-width:2px;
    classDef external fill:#FFE066,stroke:#F4A261,stroke-width:2px;
    classDef scheduler fill:#F1FAEE,stroke:#457B9D,stroke-width:2px;

    %% Click Events
    click EP "https://github.com/novysodope/yunso/blob/main/yunso.py"
    click Config "https://github.com/novysodope/yunso/blob/main/yunso_config.ini"
    click Monitor "https://github.com/novysodope/yunso/blob/main/yunso.py"
    click Search "https://github.com/novysodope/yunso/blob/main/yunso.py"
    click Ai "https://github.com/novysodope/yunso/blob/main/yunso.py"
```
