Leonard Surac

Back to the start page

In development · since 2026

Inkmate

In league chess, games are recorded on paper. Inkmate turns the photo of a scoresheet into a checked, analysed game on the club's website, as SaaS for chess clubs instead of part of one club's software.

ASP.NET Core 11 · EF Core · PostgreSQL · Event Sourcing · Angular 22 PWA · Node.js · Claude API

Problem

After every team match the games exist only on handwritten scoresheets. I had already solved this for my own club, but as part of its club software. Other clubs have the same problem and no software of their own, and a pipeline tied to a single club's website cannot be shared.

My role

I cut the domain with domain storytelling and event storming, designed the architecture and build Inkmate on my own.

Case study

My solution

After the game a player photographs their scoresheet. Inkmate reads it, rebuilds the game move by move against the rules, asks the scorer about unclear moves, has an engine analyse the game and publishes it once the team captain approves. The opposing club gets its games sent over.

  • Multi-tenant: a club is a tenant, and every query is filtered to it
  • A PWA instead of an app store, sign-in by magic link or passkey
  • Games can be embedded in any club website with a script
  • Moves appear in the notation of the interface language, with German piece letters in the German app

Implementation

Before writing code I cut the domain into nine bounded contexts and modelled the core process with event storming. Two of them, capturing a game and publishing it, are event-sourced: there it matters who read, corrected or approved which move and when. The other seven simply store their state.

Every aggregate is two pure functions, Decide and Evolve, without a database and without a clock. I built the event store myself: one table in PostgreSQL, optimistic concurrency through the stream version and an advisory lock per append, so a subscription never skips an event that commits after a later one.

Inkmate.Api/Shared/Infrastructure/Events/EventStore.cs
await LockAppendsAsync(cancellationToken);

var actualVersion = await dbContext.Set<StoredEvent>()
    .Where(e => e.StreamId == streamId)
    .MaxAsync(e => (int?)e.Version, cancellationToken) ?? 0;
if (actualVersion != expectedVersion)
{
  throw new ConcurrencyConflictException(streamId, expectedVersion, actualVersion);
}

A Node worker reads the scoresheets with the Claude API, the API checks every move against the rules of chess, and Stockfish analyses the finished game. Events hold no personal data, only ids, moves and results, so I can meet erasure duties without ever changing history.

Decisions

Event sourcing only where the history matters
Only capturing and publishing a game are event-sourced; the other seven contexts store their state. That means two styles in one project, but the cost of streams, projections and versioning only where I really need the history.
A small event store of my own instead of a framework
Instead of Marten or KurrentDB I use one table in the application database, mapped through EF Core. An advisory lock serialises every append so positions become visible in order. That costs throughput far above Inkmate's volume and saves a second database and a large dependency.
Projections run in the same transaction
Read models for the user interface are written in the transaction of the append. Whoever saves something sees it immediately, and the interface has no eventual consistency to handle. In exchange every append is slower by its projection.

Outcome

Inkmate runs on a staging server in my homelab and is measured against real games of my club. Of the readings the system rates as sure, 6.9 % are wrong, against 13.6 % in the club software's pipeline, measured over 1,541 plies. Behind it are around 320 backend and 90 front-end tests.