# mymaswayvpn/genshin-checkin architecture

> Architecture diagram of the GitHub repository mymaswayvpn/genshin-checkin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mymaswayvpn/genshin-checkin
- Repository: https://github.com/mymaswayvpn/genshin-checkin

## Overview

This repository automates Genshin Impact daily check-ins and promo-code redemption for accounts supplied through GitHub secrets. The main workflows are scheduled check-in with result logging and Telegram reporting, scheduled promo-code discovery followed by redemption, and manual redemption of selected or saved active codes. Shared HoYoLab services handle account loading, role lookup, token verification, redemption, and notifications. Source excerpts show these runtime calls; GitHub secret cleanup and workflow scheduling are documented capabilities, but their implementation wiring was not sampled.

Main entry points: [`scripts/promo-codes.js`](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/promo-codes.js) (Promo monitor), [`scripts/daily-checkin.js`](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/daily-checkin.js) (Daily check-in), [`scripts/redeem-codes.js`](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/redeem-codes.js) (Manual redeem), [`scripts/hoyolab-api.js`](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js) (Role lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflows["Account workflows"]
  node_checkin["Daily check-in<br/>[daily-checkin.js]"]
  node_manual["Manual redeem<br/>[redeem-codes.js]"]
end

subgraph group_services["Game services"]
  node_accounts["Account loading<br/>[hoyolab-api.js]"]
  node_roles["Role lookup<br/>[hoyolab-api.js]"]
  node_token["Token verification<br/>[hoyolab-api.js]"]
  node_redeem["Code redemption<br/>[hoyolab-api.js]"]
  node_telegram["Telegram reporting<br/>[hoyolab-api.js]"]
  node_ua["User-Agent rotation<br/>[user-agents.js]"]
  node_secret_cleanup["Expired-secret cleanup<br/>[hoyolab-api.js]"]
end

subgraph group_promos["Promo discovery"]
  node_monitor["Promo monitor<br/>[promo-codes.js]"]
end

subgraph group_state["Persistent state"]
  node_log["Check-in log<br/>[log.txt]"]
  node_codes[("Promo-code database<br/>[promo-codes.json]")]
end

node_scheduler(("GitHub Actions"))
node_game["HoYoverse APIs"]
node_wiki["Promo sources"]
node_github_secrets[("GitHub secrets")]

node_scheduler -.->|"runs daily"| node_checkin
node_scheduler -.->|"runs periodically"| node_monitor
node_scheduler -.->|"dispatches"| node_manual
node_checkin -->|"loads accounts"| node_accounts
node_checkin -->|"writes results"| node_log
node_checkin -->|"sends report"| node_telegram
node_checkin -->|"checks in"| node_game
node_checkin -.->|"cleans expired accounts"| node_secret_cleanup
node_manual -->|"loads accounts"| node_accounts
node_manual -->|"verifies token"| node_token
node_manual -->|"finds roles"| node_roles
node_manual -->|"redeems codes"| node_redeem
node_manual -->|"reads active codes"| node_codes
node_manual -->|"sends report"| node_telegram
node_monitor -->|"fetches promo pages"| node_wiki
node_monitor -->|"loads accounts"| node_accounts
node_monitor -->|"finds roles"| node_roles
node_monitor -->|"redeems new codes"| node_redeem
node_monitor -->|"reads and updates"| node_codes
node_monitor -->|"sends report"| node_telegram
node_accounts -.->|"reads credentials"| node_github_secrets
node_secret_cleanup -.->|"updates secrets"| node_github_secrets
node_roles -.->|"queries roles"| node_game
node_token -.->|"validates token"| node_game
node_redeem -.->|"submits codes"| node_game
node_telegram -.->|"sends messages"| node_game
node_checkin -.->|"rotates requests"| node_ua
node_roles -->|"rotates requests"| node_ua
node_redeem -->|"rotates requests"| node_ua
node_monitor -->|"rotates requests"| node_ua

click node_checkin "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/daily-checkin.js"
click node_manual "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/redeem-codes.js"
click node_monitor "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/promo-codes.js"
click node_accounts "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_roles "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_token "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_redeem "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_telegram "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_ua "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/user-agents.js"
click node_secret_cleanup "https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js"
click node_log "https://github.com/mymaswayvpn/genshin-checkin/blob/main/log.txt"
click node_codes "https://github.com/mymaswayvpn/genshin-checkin/blob/main/promo-codes.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_checkin,node_manual toneBlue
class node_accounts,node_roles,node_token,node_redeem,node_telegram,node_ua,node_secret_cleanup,node_github_secrets toneAmber
class node_monitor,node_game toneMint
class node_log,node_codes toneRose
class node_scheduler,node_wiki toneIndigo
```

## Components

### Account workflows

- [Daily check-in](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/daily-checkin.js): `scripts/daily-checkin.js`
- [Manual redeem](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/redeem-codes.js): `scripts/redeem-codes.js`

### Game services

- [Account loading](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`
- [Role lookup](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`
- [Token verification](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`
- [Code redemption](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`
- [Telegram reporting](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`
- [User-Agent rotation](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/user-agents.js): `scripts/user-agents.js`
- [Expired-secret cleanup](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/hoyolab-api.js): `scripts/hoyolab-api.js`

### Promo discovery

- [Promo monitor](https://github.com/mymaswayvpn/genshin-checkin/blob/main/scripts/promo-codes.js): `scripts/promo-codes.js`

### Persistent state

- [Check-in log](https://github.com/mymaswayvpn/genshin-checkin/blob/main/log.txt): `log.txt`
- [Promo-code database](https://github.com/mymaswayvpn/genshin-checkin/blob/main/promo-codes.json): `promo-codes.json`

### Other components

- **GitHub Actions**
- **HoYoverse APIs**
- **Promo sources**
- **GitHub secrets**

## Connections

- GitHub Actions → Daily check-in: runs daily (evidence: `README.md`)
- GitHub Actions → Promo monitor: runs periodically (evidence: `README.md`)
- GitHub Actions → Manual redeem: dispatches (evidence: `README.md`)
- Daily check-in → Account loading: loads accounts (evidence: `scripts/daily-checkin.js`)
- Daily check-in → Check-in log: writes results (evidence: `scripts/daily-checkin.js`)
- Daily check-in → Telegram reporting: sends report (evidence: `scripts/daily-checkin.js`)
- Daily check-in → HoYoverse APIs: checks in (evidence: `scripts/daily-checkin.js`)
- Daily check-in → Expired-secret cleanup: cleans expired accounts (evidence: `README.md`)
- Manual redeem → Account loading: loads accounts (evidence: `scripts/redeem-codes.js`)
- Manual redeem → Token verification: verifies token (evidence: `scripts/redeem-codes.js`)
- Manual redeem → Role lookup: finds roles (evidence: `scripts/redeem-codes.js`)
- Manual redeem → Code redemption: redeems codes (evidence: `scripts/redeem-codes.js`)
- Manual redeem → Promo-code database: reads active codes (evidence: `scripts/redeem-codes.js`)
- Manual redeem → Telegram reporting: sends report (evidence: `scripts/redeem-codes.js`)
- Promo monitor → Promo sources: fetches promo pages (evidence: `scripts/promo-codes.js`)
- Promo monitor → Account loading: loads accounts (evidence: `scripts/promo-codes.js`)
- Promo monitor → Role lookup: finds roles (evidence: `scripts/promo-codes.js`)
- Promo monitor → Code redemption: redeems new codes (evidence: `scripts/promo-codes.js`)
- Promo monitor → Promo-code database: reads and updates (evidence: `scripts/promo-codes.js`)
- Promo monitor → Telegram reporting: sends report (evidence: `scripts/promo-codes.js`)
- Account loading → GitHub secrets: reads credentials (evidence: `README.md`)
- Expired-secret cleanup → GitHub secrets: updates secrets (evidence: `README.md`)
- Role lookup → HoYoverse APIs: queries roles
- Token verification → HoYoverse APIs: validates token
- Code redemption → HoYoverse APIs: submits codes
- Telegram reporting → HoYoverse APIs: sends messages
- Daily check-in → User-Agent rotation: rotates requests (evidence: `README.md`)
- Role lookup → User-Agent rotation: rotates requests (evidence: `scripts/hoyolab-api.js`)
- Code redemption → User-Agent rotation: rotates requests (evidence: `scripts/hoyolab-api.js`)
- Promo monitor → User-Agent rotation: rotates requests (evidence: `scripts/promo-codes.js`)
