# rollphes/genshin-manager architecture

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

- Interactive diagram: https://gitdiagram.com/rollphes/genshin-manager
- Repository: https://github.com/rollphes/genshin-manager

## Overview

##### Project type and purpose
- This is a Node.js/TypeScript library (npm module) named “genshin-manager.”
- It wraps the Enka.network API and local Genshin Impact cache data, exposing a programmatic Client API for fetching user data, character/weapon stats, in-game notices, and automating cache updates.

##### File structure
- Top-level:
– src/ : core TS source
- src/client/ : Client entry point, AssetCacheManager, EnkaManager, NoticeManager
- src/models/ : domain models (characters, weapons, materials, notices, etc.)
- src/types/ : TS definitions for Enka API and cache formats
- src/utils/ : JSON parsing, event emitter, stream wrapper, converters
- src/errors/ : custom error classes
- src/index.ts : public exports
– scripts/ : installation & handbook generators
– examples/ : real-world usage examples
– docs/ : generated API docs (TypeDoc)
– config & CI: tsconfig.json, typedoc.json, ESLint, GitHub workflows

##### README for additional insights
- Main runtime components:
– Client: coordinates cache deployment, cron scheduling, fixer routines
– EnkaManager: fetches & parses user data from Enka.network
– NoticeManager: fetches & parses in-game notices
– CharacterInfo & Weapon: access static cache for names, stats, images
- Features: automatic cache download/update, image caching, defect auto-fix, cron scheduling

##### Diagramming conventions
– Initialization sequence (Client → AssetCacheManager → File System)
– Fetch sequence (EnkaManager → Enka.network → JsonParser → Models → Caller)
– Auto-update trigger (Cron → AssetCacheManager)
– Blue: internal modules
– Green: external services
– Gray: infrastructure (file system, HTTP)
– Orange: utilities & errors

##### Detailed component breakdown (optional detail layer)
- Client
– deploy(), config options
- AssetCacheManager
– downloadTextMap, downloadExcelBin, downloadImages, autoFix routines
- EnkaManager
– fetchAll(uid), fetchProfile, fetchStats
- NoticeManager
– fetchNotices(language, region)
- Models
– CharacterInfo, Weapon, Notice, Material, Artifact, Monster, etc.
- Utils & Errors
– JsonParser, ObjectKeyDecoder, PromiseEventEmitter, ReadableStreamWrapper
– Domain-specific error classes

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "External Services"
        EnkaAPI["Enka.network REST API"]:::external
        AnimeData["AnimeGameData\n(TextMap, ExcelBin, Images)"]:::external
    end

    subgraph "Infrastructure"
        HTTP["HTTP Client\n(fetch/axios)"]:::infra
        FS["File System\n(cache directory)"]:::infra
        Cron["Cron Scheduler"]:::infra
    end

    subgraph "Library Core"
        direction TB
        Client["Client\n(config: downloadLanguages, autoFetchLatestAssetsByCron, autoFixTextMap, autoFixExcelBin, autoCacheImage)"]:::internal
        AssetMgr["AssetCacheManager"]:::internal
        EnkaMgr["EnkaManager"]:::internal
        NoticeMgr["NoticeManager"]:::internal

        subgraph "Domain Models"
            direction TB
            Models["Models\n(CharacterInfo, Weapon, Notice, Material, Artifact, Monster, etc.)"]:::internal
        end

        subgraph "Utilities"
            direction TB
            JsonParser["JsonParser"]:::utils
            EventEmitter["PromiseEventEmitter"]:::utils
            StreamWrapper["ReadableStreamWrapper"]:::utils
            KeyDecoder["ObjectKeyDecoder"]:::utils
            TMapTransform["TextMapTransform\nTextMapEmptyWritable"]:::utils
            Promote["calculatePromoteLevel"]:::utils
            UTC["convertToUTC"]:::utils
        end

        subgraph "Errors"
            direction TB
            Errors["Error Classes"]:::utils
        end
    end

    subgraph "Consumer"
        Consumer["User Code"]:::internal
    end

    %% Connections
    Consumer --> Client
    Consumer --> EnkaMgr
    Consumer --> NoticeMgr
    Consumer --> Models

    Client --> AssetMgr
    Client --> EnkaMgr
    Client --> NoticeMgr

    Cron --> AssetMgr

    AssetMgr --> FS
    AssetMgr --> Models

    EnkaMgr --> HTTP
    NoticeMgr --> HTTP

    HTTP --> EnkaAPI
    HTTP --> AnimeData
    HTTP --> JsonParser

    JsonParser --> Models
    Models --> Client
    Models --> EnkaMgr
    Models --> NoticeMgr

    %% Click Events
    click Client "https://github.com/rollphes/genshin-manager/blob/main/src/client/Client.ts"
    click AssetMgr "https://github.com/rollphes/genshin-manager/blob/main/src/client/AssetCacheManager.ts"
    click EnkaMgr "https://github.com/rollphes/genshin-manager/blob/main/src/client/EnkaManager.ts"
    click NoticeMgr "https://github.com/rollphes/genshin-manager/blob/main/src/client/NoticeManager.ts"
    click Models "https://github.com/rollphes/genshin-manager/tree/main/src/models"
    click JsonParser "https://github.com/rollphes/genshin-manager/blob/main/src/utils/JsonParser.ts"
    click EventEmitter "https://github.com/rollphes/genshin-manager/blob/main/src/utils/PromiseEventEmitter.ts"
    click StreamWrapper "https://github.com/rollphes/genshin-manager/blob/main/src/utils/ReadableStreamWrapper.ts"
    click KeyDecoder "https://github.com/rollphes/genshin-manager/blob/main/src/utils/ObjectKeyDecoder.ts"
    click TMapTransform "https://github.com/rollphes/genshin-manager/blob/main/src/utils/TextMapTransform.ts"
    click Promote "https://github.com/rollphes/genshin-manager/blob/main/src/utils/calculatePromoteLevel.ts"
    click UTC "https://github.com/rollphes/genshin-manager/blob/main/src/utils/convertToUTC.ts"
    click Errors "https://github.com/rollphes/genshin-manager/tree/main/src/errors"

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#075CAB,color:#000;
    classDef external fill:#C8FACC,stroke:#1B8A00,color:#000;
    classDef infra fill:#EEEEEE,stroke:#888888,color:#000;
    classDef utils fill:#FFE8CC,stroke:#DB7B09,color:#000;
```
