How herochessvn/herochessbackend works
HeroChess is a server-authoritative Xiangqi game with hero lineups, matchmaking, persistent matches, special skills, and shop/profile features. The principal workflow is matchmaking → lineup selection and freezing → match commands → rule resolution and settlement, with saved state and realtime updates. The graph preserves documented API capabilities and background match operations, but several controller and service implementations were not excerpted; dashed edges mark relationships whose exact runtime calls could not be verified.
Main entry points: Program.cs REST API · MatchCommandService.cs Match commands · AppDbContext.cs PostgreSQL data · MatchmakingService.cs Matchmaking
Components 20
API and accounts
- REST API
HeroChess.Api/Program.cs - Account policies
HeroChess.Api/Auth/AccountPolicies.cs - Catalog
HeroChess.Api/Controllers/CatalogController.cs - Profile and shop
HeroChess.Api/Controllers/ProfileController.cs - Database bootstrap
HeroChess.Api/Data/Bootstrap/DatabaseBootstrapHostedService.cs
Game setup
- Matchmaking
HeroChess.Api/Services/MatchmakingService.cs - Lineup management
HeroChess.Api/Services/LineupService.cs - Match selection
HeroChess.Api/Services/MatchSelectionService.cs
Match runtime
- Match commands
HeroChess.Api/Services/MatchCommandService.cs - Match reads
HeroChess.Api/Services/MatchReadService.cs - Realtime hub
HeroChess.Api/Services/MatchConnectionHub.cs - Match workers
HeroChess.Api/Services/MatchRecoveryHostedService.cs - Settlement
HeroChess.Api/Services/SettlementService.cs
Rules engine
- Xiangqi rules
HeroChess.Rules/XiangqiRulesEngine.cs - Turn lifecycle
HeroChess.Rules/TurnLifecycle.cs - Skill dispatch
HeroChess.Rules/Skills/CommandSkillDispatcher.cs - Skill handlers
HeroChess.Rules/Skills/VanCocTranGiangHandler.cs - Effect model
HeroChess.Rules/Effects/EffectFactory.cs
Other components
- Player
- PostgreSQL data
HeroChess.Api/Data/AppDbContext.cs
Connections 27
- Player → REST API: uses API
- REST API → Account policies: configures
HeroChess.Api/Program.cs - REST API → Matchmaking: registers
HeroChess.Api/Program.cs - REST API → Match workers: starts workers
HeroChess.Api/Program.cs - REST API → Database bootstrap: starts bootstrap
HeroChess.Api/Program.cs - REST API → Catalog: routes requests
- REST API → Profile and shop: routes requests
- REST API → Lineup management: routes requests
HeroChess.Api/Program.cs - REST API → Match selection: routes requests
HeroChess.Api/Program.cs - REST API → Match commands: routes requests
HeroChess.Api/Program.cs - Matchmaking → PostgreSQL data: writes matches
HeroChess.Api/Services/MatchmakingService.cs - Matchmaking → Catalog: checks version
- Lineup management → PostgreSQL data: reads and writes
HeroChess.Api/Services/LineupService.cs - Match selection → PostgreSQL data: loads lineups
HeroChess.Api/Services/MatchSelectionService.cs - Match selection → Lineup management: validates lineup
HeroChess.Api/Services/MatchSelectionService.cs - Match commands → PostgreSQL data: saves actions
HeroChess.Api/Services/MatchCommandService.cs - Match commands → Xiangqi rules: resolves moves
HeroChess.Api/Services/MatchCommandService.cs - Match commands → Turn lifecycle: applies lifecycle
HeroChess.Api/Services/MatchCommandService.cs - Match commands → Skill dispatch: dispatches skills
HeroChess.Api/Services/MatchCommandService.cs - Match commands → Settlement: completes matches
HeroChess.Api/Services/MatchCommandService.cs - Match commands → Realtime hub: broadcasts events
HeroChess.Api/Services/MatchCommandService.cs - Match reads → PostgreSQL data: reads snapshots
HeroChess.Api/Services/MatchReadService.cs - Match workers → Match commands: submits bot turns
- Match workers → PostgreSQL data: recovers matches
- Skill dispatch → Skill handlers: dispatches handlers
- Skill handlers → Effect model: creates effects
HeroChess.Rules/Skills/VanCocTranGiangHandler.cs - Database bootstrap → PostgreSQL data: initializes
HeroChess.Api/Data/Bootstrap/DatabaseBootstrapHostedService.cs