Architecture design
Multi-tenant gym management SaaS
One platform serving many independent gyms, each with its own members, trainers and class schedule. Scheduling is the core feature; billing and reminders build on it.
- Node.js
- Express
- MongoDB
- Redis
- React
- Member app → Node.js API
- Owner dashboard → Node.js API
- Node.js API → Auth & tenants
- Node.js API → Scheduling
- Node.js API → Memberships
- Node.js API → Notifications
- Auth & tenants → MongoDB
- Scheduling → MongoDB
- Memberships → MongoDB
- Notifications → Redis queue
- Redis queue → SMS / WhatsApp
- Memberships → Payment gateway
Scroll sideways to see the whole diagram.
Key decisions
01One shared database, tenantId on every document
- Why
- Hundreds of small gyms means cheap onboarding, one schema to migrate and one thing to back up.
- Trade-off
- Isolation depends on code. All queries go through a tenant-scoped repository and are covered by tests; a large chain can later move to its own database.
02Modular monolith, not microservices
- Why
- A small team ships faster with one deployable. Modules (scheduling, billing, notifications) have clear boundaries so they can be split out later.
- Trade-off
- Everything scales together. That is fine for this load, and cheaper to run until it is not.
03Scheduling first, with atomic bookings
- Why
- Class and trainer scheduling is the wedge feature. A booking decrements capacity in a single conditional update, so two members can never take the last spot.
- Trade-off
- Waitlist promotion adds logic (who gets a freed spot, and when). It is worth it: full classes are where gyms lose money.
04Background queue for reminders and renewals
- Why
- Reminders and subscription renewals must not slow down requests or be lost on a restart.
- Trade-off
- One more piece of infrastructure to run and monitor.
05Payments behind an interface
- Why
- Gyms in Tunisia often take cash or local payment methods. The billing module records payments first and talks to a gateway through an interface, so a local provider can be added without touching the rest.
- Trade-off
- Reconciling cash and online payments needs clear states per invoice.