# krex381/token-onliner architecture

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

- Interactive diagram: https://gitdiagram.com/krex381/token-onliner
- Repository: https://github.com/krex381/token-onliner

## Overview

##### Project type and purpose
- This is a Node.js-based background service / CLI utility whose sole purpose is to keep multiple Discord tokens “online” with customized activity (game status, Spotify status), to manage reconnections, and to handle errors gracefully.

##### File structure
- All files live at the top level; there are no subdirectories.
- index.js is the single entry point.
- package.json / package-lock.json define dependencies and startup scripts.
- config data: game.json, spotify.json.
- token store: tokens.txt.
- user-agent store: useragents.txt.
- start.bat is a convenience wrapper for Windows.
- LICENSE and README.md are documentation.

##### README for additional insights
- The README confirms the Node.js requirement, installation steps, the runtime behavior (token management, automatic reconnect, activity customization), and data formats.

##### Detail
- That index.js ties everything together.
- Event loop: WebSocket events → Activity Updater / Reconnect Handler.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "On-Disk Data"
        G[(“game.json”)]:::data
        S[(“spotify.json”)]:::data
        T[(“tokens.txt”)]:::data
        U[(“useragents.txt”)]:::data
        P1[(“package.json”)]:::data
        P2[(“package-lock.json”)]:::data
        SB[(“start.bat”)]:::data
        R[(“README.md”)]:::data
        L[(“LICENSE”)]:::data
    end

    subgraph "Runtime Modules"
        OR["Orchestrator (index.js)"]:::logic
        CL["Config Loader"]:::io
        TM["Token Manager"]:::io
        DCM["Discord Client Module"]:::logic
        AU["Activity Updater"]:::logic
        GM["Game Sub-module"]:::logic
        SM["Spotify Sub-module"]:::logic
        RE["Reconnect/Error Handler"]:::error
        LG["Logger/Metrics"]:::io
    end

    subgraph "External Service"
        API["Discord API"]:::external
    end

    OR -->|"load()"| CL
    CL -->|"reads settings"| G
    CL -->|"reads settings"| S

    OR -->|"load()"| TM
    TM -->|"reads tokens"| T
    TM -->|"reads user-agents"| U

    TM -->|"connect()"| DCM
    DCM -->|"WebSocket/REST"| API

    OR -->|"setActivity()"| AU
    AU -->|"game logic"| GM
    AU -->|"spotify logic"| SM
    GM -->|"setGame()"| DCM
    SM -->|"setSpotify()"| DCM

    DCM -->|"onDisconnect"| RE
    RE -->|"reconnect()"| DCM

    OR -->|“log events”| LG
    CL -->|“log events”| LG
    TM -->|“log events”| LG
    DCM -->|“log events”| LG
    AU -->|“log events”| LG
    RE -->|“log events”| LG

    click OR "https://github.com/krex381/token-onliner/blob/main/index.js"
    click G "https://github.com/krex381/token-onliner/blob/main/game.json"
    click S "https://github.com/krex381/token-onliner/blob/main/spotify.json"
    click T "https://github.com/krex381/token-onliner/blob/main/tokens.txt"
    click U "https://github.com/krex381/token-onliner/blob/main/useragents.txt"
    click P1 "https://github.com/krex381/token-onliner/blob/main/package.json"
    click P2 "https://github.com/krex381/token-onliner/blob/main/package-lock.json"
    click SB "https://github.com/krex381/token-onliner/blob/main/start.bat"
    click R "https://github.com/krex381/token-onliner/blob/main/README.md"
    click L "https://github.com/krex381/token-onliner/tree/main/LICENSE"

    classDef io fill:#85C1E9,stroke:#333,stroke-width:1px
    classDef logic fill:#F8C471,stroke:#333,stroke-width:1px
    classDef error fill:#EC7063,stroke:#333,stroke-width:1px
    classDef data fill:#ABEBC6,stroke:#333,stroke-width:1px
    classDef external fill:#D7DBDD,stroke:#333,stroke-width:1px
```
