# salaron/sunlight architecture

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

- Interactive diagram: https://gitdiagram.com/salaron/sunlight
- Repository: https://github.com/salaron/sunlight

## Overview

re:Light is a server emulator for Love Live! School Idol Festival. Its principal workflow is a client request entering an API endpoint, passing request checks, invoking account or game services, and returning a response; login authenticates credentials and establishes a session. Other visible product areas include downloads, login bonuses, live play, units, rewards, and user inventory. The graph reflects documented capabilities and source-index references; unsampled handler implementations and runtime wiring are not assumed beyond those references.

Main entry points: [`Server.Database/Server/ServerContext.cs`](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/ServerContext.cs) (Player database), [`Server.Common/Units/UnitService.cs`](https://github.com/salaron/sunlight/blob/master/Server.Common/Units/UnitService.cs) (Unit service), [`Server.Endpoints/Handlers`](https://github.com/salaron/sunlight/tree/master/Server.Endpoints/Handlers) (API endpoints), [`Server/Startup/WebApplicationBuilderExtensions.cs`](https://github.com/salaron/sunlight/blob/master/Server/Startup/WebApplicationBuilderExtensions.cs) (Server startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_api["API endpoints<br/>[Handlers]"]
  node_authfilter["Authorization filter"]
  node_versionfilter["Version filter"]
  node_authheader["Auth header<br/>[AuthorizeHeader.cs]"]
end

subgraph group_account["Accounts &amp; Progress"]
  node_login["Login<br/>[Login.cs]"]
  node_authkeys["Auth key repository"]
  node_usersvc["User service<br/>[UserService.cs]"]
  node_bonus["Login bonuses"]
end

subgraph group_game["Game Features"]
  node_unitservice["Unit service<br/>[UnitService.cs]"]
  node_deckservice["Deck service<br/>[UnitDeckService.cs]"]
  node_inventory["Items &amp; rewards<br/>[Items]"]
  node_addtype["Item categories<br/>[AddType.cs]"]
  node_lives["Live features<br/>[Live]"]
  node_downloads["Content downloads<br/>[Update.cs]"]
end

subgraph group_data["Persistence &amp; Runtime"]
  node_user["User record<br/>[User.cs]"]
  node_serverdb[("Player database<br/>[ServerContext.cs]")]
  node_unitdb[("Unit catalog<br/>[UnitContext.cs]")]
  node_unitowning["Owned units<br/>[UnitOwning.cs]"]
  node_unitalbum["Unit album<br/>[UnitAlbum.cs]"]
  node_deckrecord["Saved decks<br/>[UserUnitDeck.cs]"]
  node_config["Server configuration<br/>[ServerConfig.cs]"]
  node_startup["Server startup"]
end

node_client(("Game client"))

node_client -.->|"sends requests"| node_api
node_api -.->|"checks authorization"| node_authfilter
node_api -.->|"checks version"| node_versionfilter
node_authfilter -->|"reads header"| node_authheader
node_login -->|"gets auth key"| node_authkeys
node_login -->|"looks up user"| node_serverdb
node_usersvc -->|"reads and updates"| node_serverdb
node_usersvc -->|"maps user data"| node_user
node_bonus -->|"reads and records"| node_serverdb
node_bonus -->|"reads bonus settings"| node_config
node_unitservice -->|"reads unit data"| node_serverdb
node_unitservice -->|"queries ownership"| node_unitowning
node_unitservice -->|"queries album"| node_unitalbum
node_unitservice -->|"uses deck data"| node_deckrecord
node_deckservice -->|"reads deck data"| node_serverdb
node_deckservice -->|"uses saved decks"| node_deckrecord
node_inventory -->|"classifies items"| node_addtype
node_downloads -.->|"uses download settings"| node_config
node_startup -->|"configures database"| node_serverdb
node_startup -->|"configures database"| node_unitdb
node_startup -.->|"registers API"| node_api

click node_api "https://github.com/salaron/sunlight/tree/master/Server.Endpoints/Handlers"
click node_authfilter "https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Filters/AuthorizationFilter.cs"
click node_versionfilter "https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Filters/ClientVersionFilter.cs"
click node_authheader "https://github.com/salaron/sunlight/blob/master/Server.Common/AuthorizeHeader.cs"
click node_login "https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Handlers/Login/Login.cs"
click node_authkeys "https://github.com/salaron/sunlight/blob/master/Server.Common/Login/AuthKeyRepository.cs"
click node_usersvc "https://github.com/salaron/sunlight/blob/master/Server.Common/Users/UserService.cs"
click node_user "https://github.com/salaron/sunlight/blob/master/Server.Database/Server/User.cs"
click node_bonus "https://github.com/salaron/sunlight/blob/master/Server.Common/LoginBonus/LoginBonusService.cs"
click node_unitservice "https://github.com/salaron/sunlight/blob/master/Server.Common/Units/UnitService.cs"
click node_deckservice "https://github.com/salaron/sunlight/blob/master/Server.Common/Units/UnitDeckService.cs"
click node_inventory "https://github.com/salaron/sunlight/tree/master/Server.Common/Items"
click node_addtype "https://github.com/salaron/sunlight/blob/master/Server.Database/Enums/AddType.cs"
click node_lives "https://github.com/salaron/sunlight/tree/master/Server.Endpoints/Handlers/Live"
click node_downloads "https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Handlers/Download/Update.cs"
click node_serverdb "https://github.com/salaron/sunlight/blob/master/Server.Database/Server/ServerContext.cs"
click node_unitdb "https://github.com/salaron/sunlight/blob/master/Server.Database/Game/UnitContext.cs"
click node_unitowning "https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UnitOwning.cs"
click node_unitalbum "https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UnitAlbum.cs"
click node_deckrecord "https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UserUnitDeck.cs"
click node_config "https://github.com/salaron/sunlight/blob/master/Server.Common/Config/ServerConfig.cs"
click node_startup "https://github.com/salaron/sunlight/blob/master/Server/Startup/WebApplicationBuilderExtensions.cs"

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_api,node_authfilter,node_versionfilter,node_authheader,node_client toneBlue
class node_login,node_authkeys,node_usersvc,node_bonus toneAmber
class node_unitservice,node_deckservice,node_inventory,node_addtype,node_lives,node_downloads toneMint
class node_user,node_serverdb,node_unitdb,node_unitowning,node_unitalbum,node_deckrecord,node_config,node_startup toneRose
```

## Components

### HTTP API

- [API endpoints](https://github.com/salaron/sunlight/tree/master/Server.Endpoints/Handlers): `Server.Endpoints/Handlers`
- [Authorization filter](https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Filters/AuthorizationFilter.cs): `Server.Endpoints/Filters/AuthorizationFilter.cs`
- [Version filter](https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Filters/ClientVersionFilter.cs): `Server.Endpoints/Filters/ClientVersionFilter.cs`
- [Auth header](https://github.com/salaron/sunlight/blob/master/Server.Common/AuthorizeHeader.cs): `Server.Common/AuthorizeHeader.cs`

### Accounts & Progress

- [Login](https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Handlers/Login/Login.cs): `Server.Endpoints/Handlers/Login/Login.cs`
- [Auth key repository](https://github.com/salaron/sunlight/blob/master/Server.Common/Login/AuthKeyRepository.cs): `Server.Common/Login/AuthKeyRepository.cs`
- [User service](https://github.com/salaron/sunlight/blob/master/Server.Common/Users/UserService.cs): `Server.Common/Users/UserService.cs`
- [Login bonuses](https://github.com/salaron/sunlight/blob/master/Server.Common/LoginBonus/LoginBonusService.cs): `Server.Common/LoginBonus/LoginBonusService.cs`

### Game Features

- [Unit service](https://github.com/salaron/sunlight/blob/master/Server.Common/Units/UnitService.cs): `Server.Common/Units/UnitService.cs`
- [Deck service](https://github.com/salaron/sunlight/blob/master/Server.Common/Units/UnitDeckService.cs): `Server.Common/Units/UnitDeckService.cs`
- [Items & rewards](https://github.com/salaron/sunlight/tree/master/Server.Common/Items): `Server.Common/Items`
- [Item categories](https://github.com/salaron/sunlight/blob/master/Server.Database/Enums/AddType.cs): `Server.Database/Enums/AddType.cs`
- [Live features](https://github.com/salaron/sunlight/tree/master/Server.Endpoints/Handlers/Live): `Server.Endpoints/Handlers/Live`
- [Content downloads](https://github.com/salaron/sunlight/blob/master/Server.Endpoints/Handlers/Download/Update.cs): `Server.Endpoints/Handlers/Download/Update.cs`

### Persistence & Runtime

- [User record](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/User.cs): `Server.Database/Server/User.cs`
- [Player database](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/ServerContext.cs): `Server.Database/Server/ServerContext.cs`
- [Unit catalog](https://github.com/salaron/sunlight/blob/master/Server.Database/Game/UnitContext.cs): `Server.Database/Game/UnitContext.cs`
- [Owned units](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UnitOwning.cs): `Server.Database/Server/UnitOwning.cs`
- [Unit album](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UnitAlbum.cs): `Server.Database/Server/UnitAlbum.cs`
- [Saved decks](https://github.com/salaron/sunlight/blob/master/Server.Database/Server/UserUnitDeck.cs): `Server.Database/Server/UserUnitDeck.cs`
- [Server configuration](https://github.com/salaron/sunlight/blob/master/Server.Common/Config/ServerConfig.cs): `Server.Common/Config/ServerConfig.cs`
- [Server startup](https://github.com/salaron/sunlight/blob/master/Server/Startup/WebApplicationBuilderExtensions.cs): `Server/Startup/WebApplicationBuilderExtensions.cs`

### Other components

- **Game client**

## Connections

- Game client → API endpoints: sends requests
- API endpoints → Authorization filter: checks authorization (evidence: `Server.Endpoints/Filters/AuthorizationFilter.cs`)
- API endpoints → Version filter: checks version
- Authorization filter → Auth header: reads header (evidence: `Server.Endpoints/Filters/AuthorizationFilter.cs`)
- Login → Auth key repository: gets auth key (evidence: `Server.Endpoints/Handlers/Login/Login.cs`)
- Login → Player database: looks up user (evidence: `Server.Endpoints/Handlers/Login/Login.cs`)
- User service → Player database: reads and updates (evidence: `Server.Common/Users/UserService.cs`)
- User service → User record: maps user data (evidence: `Server.Common/Users/UserService.cs`)
- Login bonuses → Player database: reads and records (evidence: `Server.Common/LoginBonus/LoginBonusService.cs`)
- Login bonuses → Server configuration: reads bonus settings (evidence: `Server.Common/LoginBonus/LoginBonusService.cs`)
- Unit service → Player database: reads unit data (evidence: `Server.Common/Units/UnitService.cs`)
- Unit service → Owned units: queries ownership (evidence: `Server.Common/Units/UnitService.cs`)
- Unit service → Unit album: queries album (evidence: `Server.Common/Units/UnitService.cs`)
- Unit service → Saved decks: uses deck data (evidence: `Server.Common/Units/UnitService.cs`)
- Deck service → Player database: reads deck data (evidence: `Server.Common/Units/UnitDeckService.cs`)
- Deck service → Saved decks: uses saved decks (evidence: `Server.Common/Units/UnitDeckService.cs`)
- Items & rewards → Item categories: classifies items (evidence: `Server.Database/Enums/AddType.cs`)
- Content downloads → Server configuration: uses download settings
- Server startup → Player database: configures database (evidence: `Server/Startup/WebApplicationBuilderExtensions.cs`)
- Server startup → Unit catalog: configures database (evidence: `Server/Startup/WebApplicationBuilderExtensions.cs`)
- Server startup → API endpoints: registers API
