Back to home
GymOS logo

GymOS

A multi-tenant gym management SaaS for the Kenyan market — every gym gets its own subdomain, bills in KES and collects through M-Pesa. Five deployables: one FastAPI backend serving three API surfaces, a Next.js marketing site, and three React apps for the platform, gym staff and members.

Visit live site

Demo

Architecture

Backend & Tenancy

FastAPIPython 3.12SQLAlchemy 2 (async)asyncpgAlembicPostgreSQLPostgres RLSJWT + email OTPRedisSwagger / OpenAPI
–
One FastAPI codebase serving three independent surfaces from a single image and database — platform admin, gym staff and members — so each audience gets only its own routes and its own Swagger docs.
–
Tenancy resolved from the Host subdomain: JWTs carry gym_id and role, a token whose tenant does not match the host is rejected, and reserved slugs (www, app, admin, api, mail, static, support) are blocked at signup.
–
Every tenant-owned table carries gym_id, isolation is enforced in the app layer and again with Postgres row-level security, and every endpoint ships with a tenant-isolation test.
–
A role and permission engine seeded per gym across seven roles — Super Admin, Gym Owner, Branch Manager, Front Desk, Accountant, Trainer, Member — enforced per route on the backend, with the frontend only hiding UI.
–
Async SQLAlchemy 2 models with Alembic migrations covering tenants, members, catalogue, billing, CRM, operations, training, POS, compliance and reporting.
–
Staff and Super Admin authentication over email OTP on top of JWT, with an audit log of every privileged action.

Billing, M-Pesa & Compliance

M-Pesa Daraja (STK Push)PaymentProvider interfaceMockMpesaProviderNUMERIC(12,2) KESfpdf2 receipts16% VAT / eTIMSKenya DPA toolingFernet-encrypted credentials
–
Subscriptions, renewals and invoices with partial payments, voids and credit notes — a paid invoice is never edited — with money stored as NUMERIC(12,2) in KES, never as floats.
–
Payments run through a PaymentProvider interface: a mock M-Pesa provider drives the whole flow end to end in development, and the real Daraja adapter drops into a single branch once Safaricom approve credentials, with nothing upstream changing.
–
M-Pesa callbacks are idempotent on MpesaReceiptNumber and CheckoutRequestID, raw payloads are always stored, and a payment is only marked successful from a callback or a status query — never from the client. Each gym collects on its own Paybill or Till, with credentials encrypted at rest.
–
Receipt PDFs generated with fpdf2 and emailed on payment, alongside expenses, POS counter sales and report exports on the same ledger.
–
Kenya-first data shapes throughout: phone numbers normalised to 2547xxxxxxxx, county and town instead of a pincode, and 16% VAT configurable per gym with an eTIMS path.
–
Data-protection tooling for the Kenyan DPA — recorded member consent, plus data export and erasure requests handled from the staff dashboard.

Four Frontends

Next.js 16React 19Vite 5React 18TypeScriptReact Router 6Tailwind CSSvite-plugin-pwaqrcode
–
Public marketing site in Next.js 16 and React 19 — features, pricing, how-it-works, why-Kenya and FAQ pages, with a signup form wired to the live API, plus sitemap and robots routes.
–
Platform admin console: gym creation and provisioning, the gym list, pricing tiers, usage measured against each gym's caps, and the platform audit trail.
–
Club dashboard, the staff app and largest surface — overview, front desk, members and member detail, enquiries, plans, subscriptions, invoices, payments, expenses, POS, classes, training, branches, staff, reports, audit log, branding and settings, plus a check-in kiosk with QR scanning and device pairing.
–
Member PWA, installable and offline-capable: home, QR check-in, classes, training programmes, payments, self-renewal and profile.
–
A shared hand-rolled design system across the three Vite apps — data tables, toasts, page headers, theming, formatting and validation — with a typed API client and hooks per app and no component library.

Jobs, Infrastructure & Deployment

Celery + RabbitMQRedisDockerdocker-composenginxGitHub ActionspytestVercelCloudflare R2
–
A Celery worker and beat run the nightly sweeps that keep the business logic real: memberships expire, invoices age to overdue, expiry, birthday and win-back reminders go out, and a lapsed gym is suspended. Without them the API looks fine while the business quietly stops happening.
–
A ten-service docker-compose stack — Postgres, Redis, RabbitMQ, a one-shot migrate job that runs alembic upgrade head to completion before any surface starts, the three API surfaces, worker, beat and nginx.
–
nginx routes by hostname rather than by path, because tenancy comes from the Host header — the apex, two-label subdomains and the admin surface on a gym's hostname all return 404 on purpose.
–
Covered by pytest: a tenant-isolation suite, and a full journey test from enquiry to member, subscription, invoice, simulated M-Pesa payment, receipt and expiry reminder. CI runs on GitHub Actions.
–
A four-tier SaaS layer (Foundation, Advanced, Professional, Enterprise) with per-tier member, staff and branch caps and feature entitlements gating WhatsApp reminders, the member app, classes, trainer tools, multi-branch, POS and full reporting.
–
The member PWA is deployed on Vercel; the backend and the internal consoles stay in private repositories, so only the live app is linked.

Screenshots

GymOS screenshot
GymOS screenshot
GymOS screenshot
GymOS screenshot
GymOS screenshot