# smr8890/kusign-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/smr8890/kusign-plugin
- Repository: https://github.com/smr8890/kusign-plugin

## Overview

KuSign-Plugin is a chat-bot plugin for Kugou Concept Edition login, token maintenance, and daily membership check-in. Users initiate QR login and can manually refresh tokens or run check-in; scheduled jobs perform refresh and check-in for stored users. Configuration controls API settings and schedules, with Guoba exposing configuration management. The sampled source shows these calls and Redis access; the API implementation is only represented by the tree’s `api` directory, so its internal behavior is not expanded.

Main entry points: [`components/Config.js`](https://github.com/smr8890/kusign-plugin/blob/master/components/Config.js) (Config manager), [`utils/api.js`](https://github.com/smr8890/kusign-plugin/blob/master/utils/api.js) (API service client), [`apps/tokenRefresher.js`](https://github.com/smr8890/kusign-plugin/blob/master/apps/tokenRefresher.js) (Token refresh), [`apps/sign.js`](https://github.com/smr8890/kusign-plugin/blob/master/apps/sign.js) (Sign task)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["Plugin entry"]
  node_index["App loader<br/>[index.js]"]
  node_update["Plugin update<br/>[update.js]"]
  node_apiutil["API service client<br/>[api.js]"]
  node_api["API service"]
  node_update_service["Update service<br/>[update.js]"]
end

subgraph group_account["Account lifecycle"]
  node_login["QR login<br/>[login.js]"]
  node_refresher["Token refresh<br/>[tokenRefresher.js]"]
end

subgraph group_checkin["Check-in"]
  node_sign["Sign task<br/>[sign.js]"]
end

subgraph group_config["Configuration"]
  node_config["Config manager<br/>[Config.js]"]
  node_yaml["YAML reader<br/>[YamlReader.js]"]
  node_defaults["Default settings<br/>[config.yaml]"]
  node_userconfig["User settings"]
  node_guoba["Config interface<br/>[guoba.support.js]"]
end

node_user(("Chat user"))
node_scheduler(("Task scheduler"))
node_bot(("Bot framework"))
node_kugou(("Kugou API"))
node_redis[("User records")]

node_bot -->|"loads plugin"| node_index
node_index -->|"loads app"| node_login
node_index -->|"loads app"| node_refresher
node_index -->|"loads app"| node_sign
node_index -->|"loads app"| node_update
node_user -->|"requests login"| node_login
node_user -->|"requests refresh"| node_refresher
node_user -->|"requests check-in"| node_sign
node_scheduler -->|"runs refresh"| node_refresher
node_scheduler -->|"runs check-in"| node_sign
node_login -->|"requests API"| node_apiutil
node_refresher -->|"requests API"| node_apiutil
node_sign -->|"requests API"| node_apiutil
node_apiutil -->|"starts service"| node_api
node_apiutil -->|"sends requests"| node_kugou
node_login -->|"stores account"| node_redis
node_refresher -->|"reads and updates"| node_redis
node_sign -->|"reads accounts"| node_redis
node_config -->|"uses reader"| node_yaml
node_config -->|"loads defaults"| node_defaults
node_config -->|"merges settings"| node_userconfig
node_guoba -->|"reads and updates"| node_config
node_config -->|"provides settings"| node_apiutil
node_config -->|"provides schedule"| node_sign
node_config -->|"provides schedule"| node_refresher
node_update -->|"delegates update"| node_update_service

click node_index "https://github.com/smr8890/kusign-plugin/blob/master/index.js"
click node_login "https://github.com/smr8890/kusign-plugin/blob/master/apps/login.js"
click node_refresher "https://github.com/smr8890/kusign-plugin/blob/master/apps/tokenRefresher.js"
click node_sign "https://github.com/smr8890/kusign-plugin/blob/master/apps/sign.js"
click node_update "https://github.com/smr8890/kusign-plugin/blob/master/apps/update.js"
click node_apiutil "https://github.com/smr8890/kusign-plugin/blob/master/utils/api.js"
click node_api "https://github.com/smr8890/kusign-plugin/tree/master/api"
click node_config "https://github.com/smr8890/kusign-plugin/blob/master/components/Config.js"
click node_yaml "https://github.com/smr8890/kusign-plugin/blob/master/components/YamlReader.js"
click node_defaults "https://github.com/smr8890/kusign-plugin/blob/master/config/default_config/config.yaml"
click node_userconfig "https://github.com/smr8890/kusign-plugin/tree/master/config/config"
click node_guoba "https://github.com/smr8890/kusign-plugin/blob/master/guoba.support.js"
click node_update_service "https://github.com/smr8890/kusign-plugin/blob/master/apps/update.js"

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_index,node_update,node_apiutil,node_api,node_update_service,node_user toneBlue
class node_login,node_refresher,node_redis toneAmber
class node_sign,node_kugou toneMint
class node_config,node_yaml,node_defaults,node_userconfig,node_guoba,node_scheduler toneRose
class node_bot toneIndigo
```

## Components

### Plugin entry

- [App loader](https://github.com/smr8890/kusign-plugin/blob/master/index.js): `index.js`
- [Plugin update](https://github.com/smr8890/kusign-plugin/blob/master/apps/update.js): `apps/update.js`
- [API service client](https://github.com/smr8890/kusign-plugin/blob/master/utils/api.js): `utils/api.js`
- [API service](https://github.com/smr8890/kusign-plugin/tree/master/api): `api`
- [Update service](https://github.com/smr8890/kusign-plugin/blob/master/apps/update.js): `apps/update.js`

### Account lifecycle

- [QR login](https://github.com/smr8890/kusign-plugin/blob/master/apps/login.js): `apps/login.js`
- [Token refresh](https://github.com/smr8890/kusign-plugin/blob/master/apps/tokenRefresher.js): `apps/tokenRefresher.js`

### Check-in

- [Sign task](https://github.com/smr8890/kusign-plugin/blob/master/apps/sign.js): `apps/sign.js`

### Configuration

- [Config manager](https://github.com/smr8890/kusign-plugin/blob/master/components/Config.js): `components/Config.js`
- [YAML reader](https://github.com/smr8890/kusign-plugin/blob/master/components/YamlReader.js): `components/YamlReader.js`
- [Default settings](https://github.com/smr8890/kusign-plugin/blob/master/config/default_config/config.yaml): `config/default_config/config.yaml`
- [User settings](https://github.com/smr8890/kusign-plugin/tree/master/config/config): `config/config`
- [Config interface](https://github.com/smr8890/kusign-plugin/blob/master/guoba.support.js): `guoba.support.js`

### Other components

- **Chat user**
- **Task scheduler**
- **Bot framework**
- **Kugou API**
- **User records**

## Connections

- Bot framework → App loader: loads plugin
- App loader → QR login: loads app
- App loader → Token refresh: loads app
- App loader → Sign task: loads app
- App loader → Plugin update: loads app
- Chat user → QR login: requests login
- Chat user → Token refresh: requests refresh
- Chat user → Sign task: requests check-in
- Task scheduler → Token refresh: runs refresh
- Task scheduler → Sign task: runs check-in
- QR login → API service client: requests API
- Token refresh → API service client: requests API
- Sign task → API service client: requests API
- API service client → API service: starts service
- API service client → Kugou API: sends requests
- QR login → User records: stores account
- Token refresh → User records: reads and updates
- Sign task → User records: reads accounts
- Config manager → YAML reader: uses reader
- Config manager → Default settings: loads defaults
- Config manager → User settings: merges settings
- Config interface → Config manager: reads and updates
- Config manager → API service client: provides settings
- Config manager → Sign task: provides schedule
- Config manager → Token refresh: provides schedule
- Plugin update → Update service: delegates update
