# vantuankiet1239/hrksystem architecture

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

- Interactive diagram: https://gitdiagram.com/vantuankiet1239/hrksystem
- Repository: https://github.com/vantuankiet1239/hrksystem

## Overview

HRK is a multi-service backend with gateway, authentication, and game APIs. The visible user workflow enters an authenticated game endpoint, dispatches player or hero requests, and returns API responses; authentication separately supports registration, login, logout, refresh, and application-route discovery. The game tree also identifies battle, catalog, dungeon, formation, inventory, and metadata capabilities. The excerpts show selected controller dispatches, battle-engine collaborators, and formation-power reads; unsampled subsystem links are therefore shown as unverified rather than asserted calls.

Main entry points: [`Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs`](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs) (Game API), [`Services/AUTH/HRK.AUTH/Controllers/AuthController.cs`](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/HRK.AUTH/Controllers/AuthController.cs) (Auth API), [`Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs`](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs) (Formation features), [`Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs`](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs) (Battle simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry points"]
  node_gateway["API gateway<br/>[Program.cs]"]
  node_game_api["Game API"]
end

subgraph group_auth["Authentication"]
  node_auth_api["Auth API<br/>[AuthController.cs]"]
  node_auth_commands["Auth commands<br/>[Commands]"]
  node_route_config["Application routes"]
  node_identity["Identity service<br/>[IdentityService.cs]"]
end

subgraph group_game["Game capabilities"]
  node_player["Player features"]
  node_heroes["Hero features"]
  node_inventory["Inventory features<br/>[Inventory]"]
  node_catalog["Catalog features<br/>[Catalog]"]
  node_formation["Formation features"]
  node_formation_stats["Formation stats"]
  node_equipment_loader["Equipment loader"]
  node_battle["Battle simulation"]
  node_battle_skills["Skill handlers"]
  node_battle_effects["Effect handlers"]
  node_battle_reactions["Battle reactions"]
  node_dungeon["Dungeon features<br/>[DungeonService.cs]"]
  node_metadata["Metadata features<br/>[MetadataService.cs]"]
end

subgraph group_core["Shared runtime"]
  node_auth_tokens["Token service<br/>[JwtCoreService.cs]"]
  node_mediator["Request mediator"]
  node_uow["Unit of work<br/>[UnitOfWork.cs]"]
  node_readonly_repo["Read repositories"]
  node_game_db[("Game database<br/>[GameDbContext.cs]")]
  node_responses["API responses<br/>[BaseResponse.cs]"]
end

node_client(("API client"))

node_client -.->|"sends requests"| node_gateway
node_gateway -.->|"routes requests"| node_auth_api
node_gateway -.->|"routes requests"| node_game_api
node_client -.->|"calls auth"| node_auth_api
node_auth_api -->|"dispatches commands"| node_auth_commands
node_auth_api -->|"loads routes"| node_route_config
node_auth_commands -.->|"uses identity"| node_identity
node_auth_commands -.->|"issues tokens"| node_auth_tokens
node_client -.->|"calls game API"| node_game_api
node_game_api -->|"dispatches queries"| node_mediator
node_game_api -->|"calls player service"| node_player
node_game_api -.->|"calls hero routes"| node_heroes
node_game_api -.->|"serves inventory"| node_inventory
node_game_api -.->|"serves catalog"| node_catalog
node_game_api -.->|"serves formation"| node_formation
node_game_api -.->|"serves battles"| node_battle
node_game_api -.->|"serves dungeons"| node_dungeon
node_game_api -.->|"serves metadata"| node_metadata
node_battle -->|"resolves skills"| node_battle_skills
node_battle -->|"creates registry"| node_battle_effects
node_battle -->|"creates registry"| node_battle_reactions
node_formation -->|"queries entities"| node_uow
node_formation -->|"loads equipment"| node_equipment_loader
node_formation -->|"calculates power"| node_formation_stats
node_uow -.->|"provides repositories"| node_readonly_repo
node_readonly_repo -.->|"reads entities"| node_game_db
node_auth_api -->|"returns responses"| node_responses

click node_gateway "https://github.com/vantuankiet1239/hrksystem/blob/master/ApiGateway/ApiGateway/Program.cs"
click node_auth_api "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/HRK.AUTH/Controllers/AuthController.cs"
click node_auth_commands "https://github.com/vantuankiet1239/hrksystem/tree/master/Services/AUTH/AUTH.Application/Features/Commands"
click node_route_config "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/AUTH.Application/Interfaces/IApplicationRouteConfigService.cs"
click node_identity "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/AUTH.Infrastructure/Identity/IdentityService.cs"
click node_auth_tokens "https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/JwtHandler/JwtCoreService.cs"
click node_game_api "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs"
click node_player "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Application/Interfaces/IGamePlayerService.cs"
click node_heroes "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerHeroesController.cs"
click node_inventory "https://github.com/vantuankiet1239/hrksystem/tree/master/Services/HRKGAME/GAME.Application/Features/Commands/Inventory"
click node_catalog "https://github.com/vantuankiet1239/hrksystem/tree/master/Services/HRKGAME/GAME.Application/Features/Queries/Catalog"
click node_formation "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs"
click node_formation_stats "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Application/Interfaces/IFormationStatService.cs"
click node_equipment_loader "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/EquipmentBatchLoader.cs"
click node_battle "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs"
click node_battle_skills "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Skills/SkillHandlerRegistry.cs"
click node_battle_effects "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Effects/BattleEffectHandlerRegistry.cs"
click node_battle_reactions "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Reactions/BattleCombatantReactionRegistry.cs"
click node_dungeon "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/DungeonService.cs"
click node_metadata "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/MetadataService.cs"
click node_mediator "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs"
click node_uow "https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Repositories/UnitOfWork.cs"
click node_readonly_repo "https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Repositories/ReadOnlyRepository.cs"
click node_game_db "https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Data/GameDbContext.cs"
click node_responses "https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Entity/BaseResponse.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_gateway,node_game_api,node_client toneBlue
class node_auth_api,node_auth_commands,node_route_config,node_identity toneAmber
class node_player,node_heroes,node_inventory,node_catalog,node_formation,node_formation_stats,node_equipment_loader,node_battle,node_battle_skills,node_battle_effects,node_battle_reactions,node_dungeon,node_metadata toneMint
class node_auth_tokens,node_mediator,node_uow,node_readonly_repo,node_game_db,node_responses toneRose
```

## Components

### API entry points

- [API gateway](https://github.com/vantuankiet1239/hrksystem/blob/master/ApiGateway/ApiGateway/Program.cs): `ApiGateway/ApiGateway/Program.cs`
- [Game API](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs): `Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs`

### Authentication

- [Auth API](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/HRK.AUTH/Controllers/AuthController.cs): `Services/AUTH/HRK.AUTH/Controllers/AuthController.cs`
- [Auth commands](https://github.com/vantuankiet1239/hrksystem/tree/master/Services/AUTH/AUTH.Application/Features/Commands): `Services/AUTH/AUTH.Application/Features/Commands`
- [Application routes](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/AUTH.Application/Interfaces/IApplicationRouteConfigService.cs): `Services/AUTH/AUTH.Application/Interfaces/IApplicationRouteConfigService.cs`
- [Identity service](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/AUTH/AUTH.Infrastructure/Identity/IdentityService.cs): `Services/AUTH/AUTH.Infrastructure/Identity/IdentityService.cs`

### Game capabilities

- [Player features](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Application/Interfaces/IGamePlayerService.cs): `Services/HRKGAME/GAME.Application/Interfaces/IGamePlayerService.cs`
- [Hero features](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerHeroesController.cs): `Services/HRKGAME/HRK.GAME/Controllers/PlayerHeroesController.cs`
- [Inventory features](https://github.com/vantuankiet1239/hrksystem/tree/master/Services/HRKGAME/GAME.Application/Features/Commands/Inventory): `Services/HRKGAME/GAME.Application/Features/Commands/Inventory`
- [Catalog features](https://github.com/vantuankiet1239/hrksystem/tree/master/Services/HRKGAME/GAME.Application/Features/Queries/Catalog): `Services/HRKGAME/GAME.Application/Features/Queries/Catalog`
- [Formation features](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs): `Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs`
- [Formation stats](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Application/Interfaces/IFormationStatService.cs): `Services/HRKGAME/GAME.Application/Interfaces/IFormationStatService.cs`
- [Equipment loader](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/EquipmentBatchLoader.cs): `Services/HRKGAME/GAME.Infrastructure/Services/EquipmentBatchLoader.cs`
- [Battle simulation](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs): `Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs`
- [Skill handlers](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Skills/SkillHandlerRegistry.cs): `Services/HRKGAME/GAME.Domain/Battle/Skills/SkillHandlerRegistry.cs`
- [Effect handlers](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Effects/BattleEffectHandlerRegistry.cs): `Services/HRKGAME/GAME.Domain/Battle/Effects/BattleEffectHandlerRegistry.cs`
- [Battle reactions](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Domain/Battle/Reactions/BattleCombatantReactionRegistry.cs): `Services/HRKGAME/GAME.Domain/Battle/Reactions/BattleCombatantReactionRegistry.cs`
- [Dungeon features](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/DungeonService.cs): `Services/HRKGAME/GAME.Infrastructure/Services/DungeonService.cs`
- [Metadata features](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Services/MetadataService.cs): `Services/HRKGAME/GAME.Infrastructure/Services/MetadataService.cs`

### Shared runtime

- [Token service](https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/JwtHandler/JwtCoreService.cs): `CoreEngine/Core.Common/JwtHandler/JwtCoreService.cs`
- [Request mediator](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs): `Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs`
- [Unit of work](https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Repositories/UnitOfWork.cs): `CoreEngine/Core.Common/Repositories/UnitOfWork.cs`
- [Read repositories](https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Repositories/ReadOnlyRepository.cs): `CoreEngine/Core.Common/Repositories/ReadOnlyRepository.cs`
- [Game database](https://github.com/vantuankiet1239/hrksystem/blob/master/Services/HRKGAME/GAME.Infrastructure/Data/GameDbContext.cs): `Services/HRKGAME/GAME.Infrastructure/Data/GameDbContext.cs`
- [API responses](https://github.com/vantuankiet1239/hrksystem/blob/master/CoreEngine/Core.Common/Entity/BaseResponse.cs): `CoreEngine/Core.Common/Entity/BaseResponse.cs`

### Other components

- **API client**

## Connections

- API client → API gateway: sends requests
- API gateway → Auth API: routes requests
- API gateway → Game API: routes requests
- API client → Auth API: calls auth
- Auth API → Auth commands: dispatches commands (evidence: `Services/AUTH/HRK.AUTH/Controllers/AuthController.cs`)
- Auth API → Application routes: loads routes (evidence: `Services/AUTH/HRK.AUTH/Controllers/AuthController.cs`)
- Auth commands → Identity service: uses identity
- Auth commands → Token service: issues tokens
- API client → Game API: calls game API
- Game API → Request mediator: dispatches queries (evidence: `Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs`)
- Game API → Player features: calls player service (evidence: `Services/HRKGAME/HRK.GAME/Controllers/PlayerController.cs`)
- Game API → Hero features: calls hero routes
- Game API → Inventory features: serves inventory
- Game API → Catalog features: serves catalog
- Game API → Formation features: serves formation
- Game API → Battle simulation: serves battles
- Game API → Dungeon features: serves dungeons
- Game API → Metadata features: serves metadata
- Battle simulation → Skill handlers: resolves skills (evidence: `Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs`)
- Battle simulation → Effect handlers: creates registry (evidence: `Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs`)
- Battle simulation → Battle reactions: creates registry (evidence: `Services/HRKGAME/GAME.Domain/Battle/BattleSimulationEngine.cs`)
- Formation features → Unit of work: queries entities (evidence: `Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs`)
- Formation features → Equipment loader: loads equipment (evidence: `Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs`)
- Formation features → Formation stats: calculates power (evidence: `Services/HRKGAME/GAME.Infrastructure/Services/FormationPowerQueryService.cs`)
- Unit of work → Read repositories: provides repositories
- Read repositories → Game database: reads entities
- Auth API → API responses: returns responses (evidence: `Services/AUTH/HRK.AUTH/Controllers/AuthController.cs`)
