How rollphes/genshin-manager works
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