Why Did I Build This?
"Developed as a commercial freelance contract, this project required a low-latency infrastructure for turn-based multiplayer board games where traditional HTTP request-response cycles fall short. To prevent client-side (Unity) manipulation and cheating, I needed to build a strictly authoritative server where all game logic, tile distribution, and win validations execute back-end. Modularity was crucial to support various game modes (Classic, 101, Bowl) without degrading into monolithic spaghetti code."
Architecture & Decisions
The core runs on .NET 9.0, utilizing SignalR Hubs (`SocialHub`, `TableHub`) for full-duplex real-time communication. To completely bypass database I/O bottlenecks during high-frequency gameplay events, active game states (`GameMatchState`) are managed in RAM using a thread-safe `ConcurrentDictionary`. Diverse game rules are strictly decoupled via the Strategy Pattern implementing the `IGameRuleHandler` interface. Persistence (inventory, transactional ledgers, chat) is handled by PostgreSQL via Entity Framework Core, while heavy aggregate tasks like calculating leaderboards are offloaded to an asynchronous `PeriodicTimer`-based `BackgroundService` worker.
Key Features
- 01.Production-ready economy and progression system enforcing transactional integrity across inventory, XP, and ledgers
- 02.Isolated matchmaking tables and clan/private chat rooms orchestrated via the SignalR Group API
- 03.Strategy Pattern implementation dynamically injecting diverse game rule constraints (Okey 101, Classic, 1v1) at runtime via DI
- 04.Server-side signaling relay infrastructure to support WebRTC-based in-game voice chat
- 05.Asynchronous background workers periodically computing and caching daily, weekly, and monthly leaderboards