# lovelyzy7/lunar-server architecture

> Architecture diagram of the GitHub repository lovelyzy7/lunar-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lovelyzy7/lunar-server
- Repository: https://github.com/lovelyzy7/lunar-server

## Overview

Lunar Server combines the lunar-tear game server, a FastAPI administration panel, and patch/master-data utilities. The main operator workflow is to enter the panel, select a player, perform an editing or upgrade action, and persist changes to game data; backups protect mutating operations. The server also provides gameplay, account authentication, and a resource CDN, while patch tools handle client and game-data assets. Links for unsampled server and panel subsystems are limited to capabilities and relationships explicitly documented in the README.

Main entry points: [`server/cmd/lunar-tear`](https://github.com/lovelyzy7/lunar-server/tree/main/server/cmd/lunar-tear) (Game Server), [`panel/web/app.py`](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/app.py) (Panel App), [`panel/web/routes`](https://github.com/lovelyzy7/lunar-server/tree/main/panel/web/routes) (Player Editors), [`panel/web/services/grant_service.py`](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/grant_service.py) (Grant Shim Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_panel["Admin Panel"]
  node_panel_app["Panel App<br/>[app.py]"]
  node_auth["Panel Access<br/>[auth_service.py]"]
  node_player_routes["Player Editors"]
  node_profile["Player Profile<br/>[profile.py]"]
  node_settings["Settings Admin<br/>[settings.py]"]
  node_edit_services["Editing Services"]
  node_grant["Grant Shim Client<br/>[grant_service.py]"]
  node_backup["Backup Service<br/>[backup_service.py]"]
  node_event["Event Manager<br/>[event_service.py]"]
  node_config["Panel Config<br/>[config.py]"]
  node_grant_shim["Grant Shim"]
end

subgraph group_game["Game Services"]
  node_game_server["Game Server"]
  node_gameplay["Gameplay Services"]
  node_quest_flow["Quest Flow"]
  node_gacha["Gacha"]
  node_masterdata["Master Data"]
  node_auth_cdn["Auth and CDN"]
end

subgraph group_data["Player Data"]
  node_game_db[("Game Database")]
  node_game_assets["Game Assets"]
end

subgraph group_tools["Patch Tools"]
  node_patch_tools["Client and Data Patches"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_panel_app
node_panel_app -->|"routes requests"| node_player_routes
node_panel_app -->|"routes requests"| node_settings
node_player_routes -->|"includes profile"| node_profile
node_profile -->|"uses"| node_edit_services
node_player_routes -->|"uses"| node_edit_services
node_panel_app -->|"checks access"| node_auth
node_settings -->|"manages credentials"| node_auth
node_grant -->|"backs up before writes"| node_backup
node_grant -->|"invokes"| node_grant_shim
node_operator -->|"runs patch tasks"| node_patch_tools
node_operator -->|"starts server"| node_game_server
node_game_server -->|"starts services"| node_auth_cdn
node_game_server -.->|"serves gameplay"| node_gameplay
node_game_server -.->|"handles quests"| node_quest_flow
node_game_server -.->|"handles draws"| node_gacha
node_gameplay -.->|"uses game data"| node_masterdata
node_game_server -.->|"persists player data"| node_game_db
node_grant_shim -.->|"updates player data"| node_game_db
node_event -->|"reads event data"| node_masterdata
node_patch_tools -->|"patches assets"| node_game_assets
node_panel_app -->|"configures paths"| node_config

click node_panel_app "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/app.py"
click node_auth "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/auth_service.py"
click node_player_routes "https://github.com/lovelyzy7/lunar-server/tree/main/panel/web/routes"
click node_profile "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/routes/profile.py"
click node_settings "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/routes/settings.py"
click node_edit_services "https://github.com/lovelyzy7/lunar-server/tree/main/panel/web/services"
click node_grant "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/grant_service.py"
click node_backup "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/backup_service.py"
click node_event "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/event_service.py"
click node_config "https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/config.py"
click node_grant_shim "https://github.com/lovelyzy7/lunar-server/tree/main/panel/tools/grant/src"
click node_game_server "https://github.com/lovelyzy7/lunar-server/tree/main/server/cmd/lunar-tear"
click node_gameplay "https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/service"
click node_quest_flow "https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/questflow"
click node_gacha "https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/gacha"
click node_masterdata "https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/masterdata"
click node_auth_cdn "https://github.com/lovelyzy7/lunar-server/tree/main/server/cmd"
click node_game_db "https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/store/sqlite"
click node_patch_tools "https://github.com/lovelyzy7/lunar-server/tree/main/panel/scripts"

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_panel_app,node_auth,node_player_routes,node_profile,node_settings,node_edit_services,node_grant,node_backup,node_event,node_config,node_grant_shim toneBlue
class node_game_server,node_gameplay,node_quest_flow,node_gacha,node_masterdata,node_auth_cdn toneAmber
class node_game_db,node_game_assets toneMint
class node_patch_tools toneRose
class node_operator toneIndigo
```

## Components

### Admin Panel

- [Panel App](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/app.py): `panel/web/app.py`
- [Panel Access](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/auth_service.py): `panel/web/services/auth_service.py`
- [Player Editors](https://github.com/lovelyzy7/lunar-server/tree/main/panel/web/routes): `panel/web/routes`
- [Player Profile](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/routes/profile.py): `panel/web/routes/profile.py`
- [Settings Admin](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/routes/settings.py): `panel/web/routes/settings.py`
- [Editing Services](https://github.com/lovelyzy7/lunar-server/tree/main/panel/web/services): `panel/web/services`
- [Grant Shim Client](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/grant_service.py): `panel/web/services/grant_service.py`
- [Backup Service](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/backup_service.py): `panel/web/services/backup_service.py`
- [Event Manager](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/services/event_service.py): `panel/web/services/event_service.py`
- [Panel Config](https://github.com/lovelyzy7/lunar-server/blob/main/panel/web/config.py): `panel/web/config.py`
- [Grant Shim](https://github.com/lovelyzy7/lunar-server/tree/main/panel/tools/grant/src): `panel/tools/grant/src`

### Game Services

- [Game Server](https://github.com/lovelyzy7/lunar-server/tree/main/server/cmd/lunar-tear): `server/cmd/lunar-tear`
- [Gameplay Services](https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/service): `server/internal/service`
- [Quest Flow](https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/questflow): `server/internal/questflow`
- [Gacha](https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/gacha): `server/internal/gacha`
- [Master Data](https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/masterdata): `server/internal/masterdata`
- [Auth and CDN](https://github.com/lovelyzy7/lunar-server/tree/main/server/cmd): `server/cmd`

### Player Data

- [Game Database](https://github.com/lovelyzy7/lunar-server/tree/main/server/internal/store/sqlite): `server/internal/store/sqlite`
- **Game Assets**

### Patch Tools

- [Client and Data Patches](https://github.com/lovelyzy7/lunar-server/tree/main/panel/scripts): `panel/scripts`

### Other components

- **Operator**

## Connections

- Operator → Panel App: uses (evidence: `README.md`)
- Panel App → Player Editors: routes requests (evidence: `panel/web/app.py`)
- Panel App → Settings Admin: routes requests (evidence: `panel/web/app.py`)
- Player Editors → Player Profile: includes profile (evidence: `panel/web/app.py`)
- Player Profile → Editing Services: uses (evidence: `panel/web/routes/profile.py`)
- Player Editors → Editing Services: uses (evidence: `panel/web/routes/upgrade_manager.py`)
- Panel App → Panel Access: checks access (evidence: `panel/web/app.py`)
- Settings Admin → Panel Access: manages credentials (evidence: `panel/web/routes/settings.py`)
- Grant Shim Client → Backup Service: backs up before writes (evidence: `panel/web/services/grant_service.py`)
- Grant Shim Client → Grant Shim: invokes (evidence: `panel/web/services/grant_service.py`)
- Operator → Client and Data Patches: runs patch tasks (evidence: `README.md`)
- Operator → Game Server: starts server (evidence: `README.md`)
- Game Server → Auth and CDN: starts services (evidence: `README.md`)
- Game Server → Gameplay Services: serves gameplay
- Game Server → Quest Flow: handles quests
- Game Server → Gacha: handles draws
- Gameplay Services → Master Data: uses game data
- Game Server → Game Database: persists player data
- Grant Shim → Game Database: updates player data
- Event Manager → Master Data: reads event data (evidence: `panel/web/services/event_service.py`)
- Client and Data Patches → Game Assets: patches assets (evidence: `README.md`)
- Panel App → Panel Config: configures paths (evidence: `panel/web/app.py`)
