Skip to content
ChessRealmsPublic

Repository files navigation

ChessRealms Platform

An open-source chess platform focused on playing chess against other players or the computer.

Scope and status

The first milestone is a complete private chess game between two people who connect through an invitation. See how to play and the delivery plan. A computer opponent is a possible follow-up.

The repository contains a .NET 10 backend, an Angular frontend, and Aspire orchestration with PostgreSQL and an EF Core migration worker.

Technology

  • C# and .NET 10 for the backend, EF Core with PostgreSQL for persistence.
  • Aspire for local orchestration and observability.
  • xUnit v3 for tests.
  • Angular for the frontend.

Repository layout

  • src/ — backend and frontend application source code.
  • src/cr-platform-web-app/ — Angular frontend.
  • tests/ — automated tests.
  • docs/ — project documentation.
  • orchestration/ — application orchestration configuration.
  • scripts/ — repository development and maintenance scripts.
  • .github/ — GitHub configuration and CI workflows.

Empty directories may not appear in a fresh clone until files are added.

Development setup

Install the SDK specified in global.json. The repository uses the .NET 11 SDK and allows newer patches in the same SDK feature band. The backend and test projects target net10.0, so also install the ASP.NET Core 10 runtime to run the platform locally.

AppHost uses DnxPinned to run the Aspire CLI version paired with its Aspire.AppHost.Sdk through dnx. A global Aspire CLI installation is optional. The first run can download the pinned CLI and prepare its dashboard and orchestration bundle. CLI bundle setup can still run with --no-restore.

Install a Node.js version supported by Angular 22: Node.js 22.22.3+, 24.15.0+, or 26+ (see the frontend's package.json engines). npm is used for frontend dependencies; package-lock.json is checked in for reproducible installs.

Shared configuration includes:

  • .editorconfig for formatting and C# style conventions.
  • .gitattributes for Git line ending normalization.
  • Directory.Build.props for shared build settings and NuGet lock file generation.
  • Directory.Packages.props for central NuGet package version management.
  • NuGet.Config for package sources.
  • .config/dotnet-tools.json for repository-local .NET tools.

Backend structure

All projects use the ChessRealms.Platform prefix:

  • src/ChessRealms.Platform.Domain — domain model; no project dependencies.
  • src/ChessRealms.Platform.Application — application layer; references Domain.
  • src/ChessRealms.Platform.Infrastructure — persistence and external integrations; references Application.
  • src/ChessRealms.Platform.Api — HTTP entry point; references Application, Infrastructure, and ServiceDefaults.
  • src/ChessRealms.Platform.MigrationWorker — console host that applies migrations and exits; references Infrastructure and ServiceDefaults.
  • orchestration/ChessRealms.Platform.AppHost — PostgreSQL, migration worker, API, and Angular frontend orchestration.
  • orchestration/ChessRealms.Platform.ServiceDefaults — shared telemetry, health checks, service discovery, and HTTP resilience.
  • tests/ — xUnit v3 projects for API, Application, Domain, Infrastructure, and browser E2E tests.

PlatformDbContext stores private standard-chess games and their move history in PostgreSQL. See the games API for creation, acceptance, moves, and revision conflicts.

The isolated Infrastructure/Identity module provides ASP.NET Core Identity stores in a separate IdentityDbContext, using the identity schema in the same PostgreSQL database. See architecture decisions for boundaries and scope.

Registration, confirmation sessions, status/resend, SMTP delivery, and confirmation links are described in registration and email confirmation. Without SMTP configuration, email delivery reports ProviderNotConfigured.

Email/password login issues RS256 JWT access tokens for confirmed users. See login and JWT authentication for the /api/identity routes and required signing-key setup. Rotating refresh tokens use persistent login sessions with an absolute 30-day lifetime and strict reuse detection.

Build and test

Run from the repository root:

dotnet tool restore
dotnet restore ChessRealms.Platform.slnx --locked-mode
dotnet build ChessRealms.Platform.slnx --no-restore
dotnet test ChessRealms.Platform.slnx --no-build --no-restore
  • Application.Tests and Domain.Tests cover game lifecycle rules such as deadlines, rejected moves, timeouts, and rematches. These tests run without Docker.
  • Api.Tests covers HTTP contracts and authentication. Its games integration tests and the Testcontainers tests in Infrastructure.Tests require Docker with Linux containers. They start temporary PostgreSQL containers, and the SMTP pipeline test also starts Mailpit. These tests run independently of AppHost.
  • The separate Identity and Games browser tests use Chromium, Aspire AppHost, PostgreSQL, and Mailpit to cover account and session flows, invitations, and live games. Follow the browser setup, then run pwsh -File scripts/test-identity-e2e.ps1 from the repository root.

For the frontend:

cd src/cr-platform-web-app
npm ci
npm run build
npm test -- --watch=false

Use the npm version pinned in the frontend's package.json. npm rejects dependency install scripts without an allowScripts decision. The current entries skip scripts for packages that ship prebuilt binaries. Review new install scripts before updating the policy, and pin any approvals to the reviewed package version.

AppHost runs the Angular app from its own directory and supplies the API endpoint to the Angular development server. To run Angular separately at http://localhost:4200, start the API and set PLATFORM_API_TARGET to its origin (for example, https://localhost:7011) before npm start. The development proxy forwards /api/** and the WebSocket traffic at /api/games/live. See the frontend setup.

Continuous integration

The CI workflow runs on pull requests, pushes to main, and manual dispatch. It has three jobs on Ubuntu:

  • Backend uses the SDK from global.json, restores locked dependencies with NuGet auditing enforced, builds the solution, and runs the .NET tests. Its integration tests use Docker for temporary PostgreSQL and Mailpit containers.
  • Frontend uses Node.js 26 and the npm version from package.json, installs with npm ci, builds the development configuration, and runs Vitest once.
  • Identity and Games browser tests starts AppHost and runs the Chromium suite.

Run locally

Provision the API's JWT signing key using the development setup in login configuration. Missing or invalid JWT configuration prevents the API from starting; migrations do not require the key.

Start Docker Desktop with Linux containers, then run:

dotnet dev-certs https --trust
dotnet run --project orchestration/ChessRealms.Platform.AppHost

Open the dashboard URL printed in the terminal. AppHost starts PostgreSQL with a persistent Docker volume, waits for database readiness, runs migrations, then starts api only if the worker exits successfully. Connection strings are supplied by Aspire; no database password is stored in source control. The API exposes /openapi/v1.json, /health (including database connectivity), and /alive in Development.

AppHost also installs the frontend's npm dependencies and starts web after api is healthy. Open the HTTPS endpoint for web in the dashboard. In Development, AppHost enables registration auto-confirmation by default. See the frontend registration flow.

To test real confirmation emails locally, enable the optional Mailpit resource before starting AppHost with $env:Mailpit__Enabled = 'true'. Its local Web UI appears in the dashboard. AppHost then disables registration auto-confirmation and configures SMTP and a working HTTPS confirmation link. See local Mailpit.

The worker has a two-minute timeout, configurable through Migration__Timeout (for example, 00:05:00). Failure or cancellation returns a nonzero exit code and prevents the API from starting. Restart AppHost to run migrations again after changing the model.

Start with a clean PostgreSQL database

For an isolated manual test in Development, pass --Postgres:Ephemeral=true to AppHost. PostgreSQL starts in a temporary tmpfs mount and the migration worker initializes the schema before the API starts. Data from this run is discarded when the PostgreSQL container stops.

dotnet run --project orchestration/ChessRealms.Platform.AppHost -- --Postgres:Ephemeral=true

In PowerShell, $env:Postgres__Ephemeral = 'true' is the equivalent environment setting. Use --Mailpit:Enabled=true as a separate AppHost argument if you want to test email delivery. For a run with previously saved data, omit the ephemeral argument and unset Postgres__Ephemeral if you set it. The ephemeral run leaves the default Docker volume available for your next persistent run.

Add a migration

dotnet ef migrations add MigrationName --context PlatformDbContext --project src/ChessRealms.Platform.Infrastructure --output-dir Persistence/Migrations

For Identity migrations, use --context IdentityDbContext --output-dir Identity/Persistence/Migrations instead.

The design-time factories allow scaffolding without starting PostgreSQL or AppHost. For EF commands that connect to a database, set ConnectionStrings__platform to the connection string shown in the Aspire dashboard. Apply migrations through MigrationWorker, which migrates both contexts; the API does not migrate the database on startup.

Documentation is maintained in English.

Working with coding agents

AGENTS.md contains concise project conventions and verification commands. Codex uses your app settings; no project-specific permission profile or command rules are required.

Contributing

Contribution guidelines are maintained at the organization level. Consult those guidelines before submitting a contribution.

License

Licensed under the Apache License, Version 2.0.

Releases

Packages

Used by

Contributors

Languages