Case study · 2026 · Solo build

IronForge

Agentic, multi-tenant gym management SaaS, with governed AI agents, offline check-in passes and billing-aware fingerprint terminals.

Role
Solo developer: product, architecture, backend, frontend, mobile, AI, DevOps
Status
Feature-complete v1, being hardened for its first gyms
Markets
Pakistan and Malaysia first, multi-currency per gym
Core stack
.NET 10 · Blazor · .NET MAUI · EF Core · PostgreSQL
projects in the solution
15
lines of C# and Razor
~70k
automated tests
~300
client platforms
5
AI agents · governed tools
3 · 24

The problem

Gyms run on spreadsheets, paper and WhatsApp

  • Memberships lapse unnoticed; overdue members keep walking in.
  • Front-desk check-in is slow, and members share passes.
  • Fingerprint terminals know nothing about who has paid.
  • Trainers can't easily hand out routines or follow progress.
  • Owners can't answer “how much did we make this month?”

The solution

An isolated workspace per gym, with four connected apps

Billing, reminders and expiry run themselves. Members check in with an offline QR pass or an existing fingerprint terminal that now refuses unpaid members, even with the internet down. AI agents take on routine admin and coaching, inside the same permission rules as people.

Four apps, one platform

Every audience gets its own front end, all on one back end

Owners · Admins · Trainers

Gym dashboard

Members, plans, billing, check-ins, fingerprint terminals, training content, staff and approvals.

Members

Member app

Offline QR pass, invoices with Pay now, routines, workout logging and progress charts on Android, iOS, Windows and macOS.

SaaS operator

Platform console

Onboard gyms, manage plans and add-on modules, AI token budgets, agent rollout and a cross-tenant audit log.

Staff · Members · External agents

AI agents and MCP

Governed assistants, plus the same tool catalogue exposed to external agents over the Model Context Protocol.

Feature highlight

Four ways in, and none of them can be shared

The member's phone computes a rotating, HMAC-signed pass offline every 30 seconds, after a biometric unlock. The pass is bound to one phone and protected against replay. Admins choose which methods each gym allows.

  • Front deskCheck in by name
  • Staff scanScan the member's pass
  • KioskCamera or USB scanner
  • Entrance QRSigned code at the door
ZKTeco terminals

Refuses unpaid members by itself, even offline.

Push-protocol sync of access windows, user import and attendance logs. No fingerprints are ever stored.

AI governance

An agent never has more authority than the person it acts for

Agents call the same permission-checked services as the UI, so tenant isolation, validation and auditing are identical.

  1. 01User requestAdmin, trainer or member asks in chat
  2. 02AgentAdmin, Coach or Insights template
  3. 03Tool filteruser ∩ agent ∩ module permissions
  4. 04Risk checkLow · Medium · High · Critical
  5. 05ApprovalConfirm, or four-eyes review
  6. 06Domain serviceSame service the UI uses
  7. 07Audit logEvery action recorded
  • Medium risk: requester confirms
  • High / Critical: second admin approves (four-eyes)
  • Payments: amount caps
  • Per gym: monthly token quota
  • MCP: same tools for external agents; approval-gated tools blocked
Admins · Trainers

Gym Admin Agent

Searches members, attendance, revenue and overdue invoices. With approval, it can freeze memberships, send reminders and record cash payments up to a cap.

Members

Fitness Coach

Logs workouts, records measurements, sets goals and builds routines. It can only ever see the signed-in member.

Admins

Insights Agent

A read-only analyst over the activity log and key business numbers.

Architecture

Clean layers, one UI codebase, and tenant isolation by default

Multi-tenancy

  • One PostgreSQL database with row-level isolation by TenantId
  • EF Core global query filter driven by the JWT's tenant claim
  • No tenant in context means no data returned (secure by default)
  • Integration tests prove isolation on real PostgreSQL

Challenges and solutions

The hard parts

01

Isolating many gyms in one database

Global EF Core query filters keyed on the token's tenant, empty-by-default results and a handful of explicit cross-tenant stores, backed by integration tests.

02

Letting AI take real actions safely

Agents only get tools both they and the user may use, and risky actions go through approval or four-eyes review, with amount caps, token quotas and an audit trail.

03

Offline passes that can't be shared

TOTP-style HMAC passes from a per-member derived key, server-side replay protection, key versioning, one phone per pass and biometric unlock before display.

04

Making fingerprint terminals billing-aware

Implemented the ZKTeco push protocol to sync access end dates, so terminals refuse unpaid members by themselves, even offline. Plus a browser simulator.

05

Billing that never double-charges

An idempotent rules engine, a single-instance job via Postgres advisory locks, atomic invoice numbers, idempotent webhooks and the outbox pattern.

06

One UI for web and native mobile

Pages in Razor class libraries hosted by Blazor Server and MAUI BlazorWebView, with native camera, biometrics and secure storage bridged in.

Security

  • Custom JWT: 15-minute access tokens, rotating refresh-token families
  • TOTP two-factor built from scratch, required for admins and operators
  • Every request re-validated; removed staff lose access immediately
  • Account lockout with back-off and per-IP rate limiting
  • Device authentication for kiosks and terminals with minimal rights
  • No biometric data stored; GDPR-style member anonymisation

Reliability

  • Transactional outbox for email with exponential backoff
  • Hourly billing job, single-instance via PostgreSQL advisory locks
  • Signed, idempotent Stripe webhooks with amount and currency checks
  • Optimistic concurrency with PostgreSQL xmin
  • CD with pre-migration backup, health checks and automatic rollback
  • Daily backups, missed-backup alert and a scripted restore test

Tech stack

Backend
  • .NET 10
  • ASP.NET Core
  • EF Core 10
  • PostgreSQL 17
  • Stripe.net
  • MailKit
  • QRCoder
Frontend & mobile
  • Blazor
  • .NET MAUI Blazor Hybrid
  • Razor class libraries
  • SVG charts
AI
  • Microsoft.Extensions.AI
  • OpenAI
  • Model Context Protocol
Testing
  • xUnit
  • Moq
  • Testcontainers
  • coverlet
DevOps
  • Docker
  • Caddy
  • GitHub Actions
  • GHCR
  • OpenTelemetry
  • Grafana Cloud

Status: production-grade and deployed with CI/CD, being prepared for its first gyms in Pakistan and Malaysia. No paying customers yet. Local payment gateways (Easypaisa, Touch 'n Go) are planned.

Need a platform like this built?

Multi-tenant SaaS, governed AI agents or a .NET MAUI app. Let's talk.