# torikushiii/hoyolab-auto architecture

> Architecture diagram of the GitHub repository torikushiii/hoyolab-auto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/torikushiii/hoyolab-auto
- Repository: https://github.com/torikushiii/hoyolab-auto

## Overview

##### Main Components

a. Core System Components:
- Command Handler System
- Cron Job Manager
- Platform Integration Layer
- HoyoLab API Integration
- Game-Specific Modules
- Notification System

b. External Services:
- HoyoLab/Hoyoverse APIs
- Discord Webhook
- Telegram API
- Google App Script (alternative deployment)

**Top Layer: User Interface/Entry Points**

**Middle Layer: Core Business Logic**

**Bottom Layer: External Services Integration**

##### Component Relationships

a. Core Components:
- Command Handler (commands/) → HoyoLab Modules
- Cron Jobs (crons/) → Game-specific Tasks
- Platform Integration (platforms/) → Notification Delivery
- HoyoLab Client (gots/) → API Communication

b. Game-Specific Modules:
- Genshin Impact Module
- Honkai: Star Rail Module
- Honkai Impact 3rd Module
- Tears of Themis Module
- Zenless Zone Zero Module

##### Specific Implementation Details

a. Service Architecture:
**Command Handler → Game Module → HoyoLab Client → External API**
- ↑                 ↓
**Cron Manager  ←→  Notification System**

b. Data Flow:
- How commands flow from user input through the system
- How cron jobs trigger automated tasks
- Demonstrate notification dispatch paths

##### Key Features to Emphasize

- Multi-game support architecture
- Automated task scheduling system
- Notification delivery pipeline
- Code redemption flow
- Check-in automation process

**┌─ User Interface Layer ─┐**
- Discord             │
- Telegram           │
- Webhook            │
- ┘
- ↓
**┌─ Core Services ───────┐**
- Command Handler    │
- Cron Manager      │
- Game Modules      │
- ┘
- ↓
**┌─ External Integration ┐**
- HoyoLab API       │
- Notification APIs │
- ┘

##### Additional Notes

- Version/configuration management flow
- Error handling paths
- Caching mechanisms

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#2374e1,color:white
    classDef game fill:#4CAF50,color:white
    classDef external fill:#FF9800,color:white
    classDef platform fill:#9C27B0,color:white
    classDef utility fill:#757575,color:white

    %% User Interface Layer
    subgraph Interface
        Discord["Discord Platform"]
        Telegram["Telegram Platform"]
        Webhook["Webhook Platform"]
    end

    %% Core System Components
    subgraph CoreSystem
        CmdHandler["Command Handler"]
        CronManager["Cron Job Manager"]
        Config["Configuration"]
        HTTPClient["HTTP Client"]
    end

    %% Game Modules
    subgraph GameModules
        Genshin["Genshin Impact"]
        Honkai["Honkai Impact"]
        StarRail["Star Rail"]
        Themis["Tears of Themis"]
        Zenless["Zenless Zone Zero"]
    end

    %% Utility Components
    subgraph Utilities
        Cache["Cache System"]
        Logger["Logger"]
        Utils["Utilities"]
    end

    %% Code Redemption System
    subgraph CodeRedemption
        CodeHandler["Code Redemption Handler"]
        GenshinCode["Genshin Codes"]
        StarRailCode["Star Rail Codes"]
        ZenlessCode["Zenless Codes"]
    end

    %% External Services
    subgraph ExternalServices
        HoyoAPI["HoyoLab API"]
        GoogleScript["Google App Script"]
    end

    %% Relationships
    CmdHandler --> GameModules
    CronManager --> CodeRedemption
    CodeRedemption --> GameModules
    GameModules --> HoyoAPI
    CmdHandler --> Interface
    CronManager --> Interface

    %% Click Events
    click CmdHandler "https://github.com/torikushiii/hoyolab-auto/tree/main/commands"
    click CronManager "https://github.com/torikushiii/hoyolab-auto/tree/main/crons"
    click Discord "https://github.com/torikushiii/hoyolab-auto/blob/main/platforms/discord.js"
    click Telegram "https://github.com/torikushiii/hoyolab-auto/blob/main/platforms/telegram.js"
    click Webhook "https://github.com/torikushiii/hoyolab-auto/blob/main/platforms/webhook.js"
    click Config "https://github.com/torikushiii/hoyolab-auto/blob/main/classes/config.js"
    click HTTPClient "https://github.com/torikushiii/hoyolab-auto/blob/main/classes/got.js"
    click Cache "https://github.com/torikushiii/hoyolab-auto/blob/main/singleton/cache.js"
    click Logger "https://github.com/torikushiii/hoyolab-auto/blob/main/singleton/logger.js"
    click Utils "https://github.com/torikushiii/hoyolab-auto/blob/main/singleton/utils.js"
    click Genshin "https://github.com/torikushiii/hoyolab-auto/tree/main/hoyolab-modules/genshin"
    click Honkai "https://github.com/torikushiii/hoyolab-auto/tree/main/hoyolab-modules/honkai"
    click StarRail "https://github.com/torikushiii/hoyolab-auto/tree/main/hoyolab-modules/starrail"
    click Themis "https://github.com/torikushiii/hoyolab-auto/tree/main/hoyolab-modules/termis"
    click Zenless "https://github.com/torikushiii/hoyolab-auto/tree/main/hoyolab-modules/zenless"
    click CodeHandler "https://github.com/torikushiii/hoyolab-auto/blob/main/crons/code-redeem/index.js"
    click GenshinCode "https://github.com/torikushiii/hoyolab-auto/blob/main/crons/code-redeem/genshin.js"
    click StarRailCode "https://github.com/torikushiii/hoyolab-auto/blob/main/crons/code-redeem/starrail.js"
    click ZenlessCode "https://github.com/torikushiii/hoyolab-auto/blob/main/crons/code-redeem/zenless.js"
    click GoogleScript "https://github.com/torikushiii/hoyolab-auto/tree/main/services/google-script"

    %% Style Applications
    class CmdHandler,CronManager,Config,HTTPClient core
    class Genshin,Honkai,StarRail,Themis,Zenless game
    class HoyoAPI,GoogleScript external
    class Discord,Telegram,Webhook platform
    class Cache,Logger,Utils utility
```
