Skip to content

Game server overview (AcidBoy.Server)

An ASP.NET Core (.NET 10) application with PostgreSQL. It serves four things from one process:

Part Path Technology Docs
REST API /auth/*, /me/*, /matches/*, /leaderboards/*, /accounts Minimal APIs, JWT bearer REST API
Lobby /hubs/lobby SignalR Lobby hub
Link relay /relay/{matchId} WebSockets Link relay
Admin dashboard /admin Blazor Server, Tailwind CSS v4, cookie auth Admin dashboard
flowchart TB
    subgraph Server["AcidBoy.Server"]
        direction TB
        Auth["Auth/<br/>TokenService · OAuthSetup · AccountService<br/>ModerationCache · LoginCodes"]
        Lobby["Lobby/<br/>LobbyHub · LobbyState (in memory)<br/>FriendService · PresenceNotifier"]
        Relay["Relay/<br/>LinkRelay · RelayTickets"]
        Matches["Matches/<br/>MatchService · LeaderboardService"]
        Admin["Admin/<br/>AdminSetup · AdminService · Blazor pages"]
        Data["Data/<br/>AcidBoyDb (EF Core) · Migrations"]
    end
    Lobby --> Matches
    Relay --> Matches
    Relay --> Lobby
    Admin --> Lobby & Relay & Matches & Auth
    Auth & Lobby & Matches & Admin --> Data
    Data --> PG[(PostgreSQL)]
In PostgreSQL (survives restarts) In memory (lost on restart)
Accounts, linked sign-ins, roles, bans, mutes Who is online and which lobby they are in
Refresh tokens (hashed) Private rooms
Channels Recent chat (last 50 messages per lobby)
Friendships Open challenges
Matches, results, player records Relay sessions in progress
Audit log One-time sign-in codes, used relay tickets

Because the live lobby is in memory, run a single server instance. On startup the server:

  1. applies migrations;
  2. closes matches a previous run left open;
  3. decides finished matches that have results but no outcome yet;
  4. promotes bootstrap admins.

Settings come from appsettings.json, appsettings.{Environment}.json, user-secrets (in Development) and environment variables (Auth__SigningKey and so on).

Setting Default Meaning
ConnectionStrings:AcidBoy dev: Host=localhost;Port=5432;Database=acidboy;Username=acidboy;Password=acidboy PostgreSQL connection
Database:MigrateOnStartup true Apply EF Core migrations at startup
Auth:SigningKey dev key in appsettings.Development.json Base64, 32+ bytes. Signs access tokens and relay tickets. Required: the server refuses to start without it
Auth:Issuer acidboy JWT issuer and audience
Auth:AccessTokenLifetime 00:15:00
Auth:RefreshTokenLifetime 60.00:00:00
Auth:EnableDevLogin true in Development Name-only sign-in. Never enable on a public server
Auth:Providers:{github,discord,google}:ClientId/ClientSecret empty OAuth apps; a provider without both is hidden
Admin:Bootstrap empty Identities that are always Admins, e.g. ["github:580551"]
Relay:WaitForPartner 00:00:30 How long the first player waits for the second at the relay
Relay:IdleTimeout 00:10:00 A relayed match with no traffic for this long ends

Generate a signing key with openssl rand -base64 32 (or any 32 random bytes in base64). Keep secrets in user-secrets or environment variables, never in appsettings.json.

Terminal window
docker compose -f src/server/docker-compose.yml up -d # PostgreSQL 17, volume acidboy-db
dotnet run --project src/server/AcidBoy.Server # http://localhost:5280 (launchSettings)
  1. Put it behind HTTPS. A reverse proxy (nginx, Caddy, a cloud load balancer) is fine:
    • X-Forwarded-For and X-Forwarded-Proto are honored;
    • the proxy must pass WebSockets through for /hubs/lobby, /relay/* and /admin/_blazor.
  2. Set production configuration:
    • ASPNETCORE_ENVIRONMENT=Production;
    • a real Auth:SigningKey;
    • the connection string;
    • OAuth credentials whose callbacks point at https://<host>/auth/callback/<provider>;
    • Admin:Bootstrap.
  3. Leave Auth:EnableDevLogin off, which is its default outside Development.
  4. Run one instance; see above.
  5. Building the server needs network access once per Tailwind version, to download the CLI (or build with -p:AcidBoySkipTailwind=true and ship a previously generated wwwroot/admin.css).

WebSocket keep-alives ping every 10 s and drop a peer that hasn’t answered for 20 s more, so a crashed or unplugged PC is noticed within about half a minute.

The server logs at Information level:

  • matches starting and ending, with the reason, who ended it and the bytes relayed;
  • bans;
  • relay failures.

EF Core’s command log is at Warning. The “Failed executing DbCommand” line on a brand-new database is EF probing for its migrations table, and is harmless.