Personal Fitness Tracker
One API behind three front ends — members, trainers and admin — on hosting that cannot run Node
- 40+REST endpoints, under one OpenAPI contract
- 20database entities behind members, trainers and admin
- 0Node processes on the server — the member app is static
Challenge
Three audiences needed different views of the same data. A member logs a workout and watches a chart move. A trainer answers that member's question and adjusts their plan. An admin publishes the routine both of them are looking at. Building three applications would have meant writing the rules about who may see and change what three times, and keeping them in step forever. The hosting made it harder. Shared hosting runs PHP and MySQL and nothing else — no Node process, no background worker, no container. That rules out the way a Next.js application is normally deployed, and it is not a constraint you can design around later. Payment was the third problem. A membership gate that lives in the interface is not a gate: the API is still there, and anyone who has opened developer tools can call it. Two providers had to be supported, and both had to be verified somewhere a browser cannot reach.
Solution
The API came first, and everything else is a client of it. Forty-plus REST endpoints in PHP over MySQL, described in one OpenAPI document, so the member app, the admin panel and any future mobile client read the same contract rather than each inventing their own. Roles — admin, trainer, member — are enforced at that layer, once. The member app is Next.js 16, built as a static export. It compiles to files, which is precisely what shared hosting is good at serving, so it needs no Node process at runtime. CI builds it and copies the output into the PHP application's public directory, so a deployment is one bundle rather than two coordinated ones. The admin panel is PHP, running where PHP already runs. Content, users, categories, classes, challenges, moderation and settings are managed there, with TOTP available on admin accounts. Stripe Checkout and PayPal both settle server-side, through webhooks the browser never touches, and the membership gate is checked in the API on every protected request. The interface hides what a non-member cannot use; the API is what actually refuses it.
Results
Twenty core entities and forty-plus endpoints run the whole platform — activities, goals, plans, challenges, feedback, trainer Q&A, favourites, achievements, classes, notifications and the audit trail behind them — from one documented contract. The member app ships as static files. Nothing on the server runs Node, which is what makes the whole thing deployable on ordinary shared hosting rather than requiring a VPS. Playwright covers the paths that matter end to end: signing in, browsing content, the member flows, and the return journey from a payment provider. PHPUnit, PHPStan and a dependency audit run alongside them, and GitHub Actions builds the deployable bundle on every change. Security was built in rather than added: CSRF protection, rate limiting, HTML sanitisation on everything the CMS accepts, a content security policy, token authentication on the API, and TOTP for admin accounts.
A members' fitness platform built API-first: one PHP and MySQL backend, a Next.js member app, and a PHP admin CMS, all reading the same documented contract.
For members
- Log workouts against a routine, meals with calories, and water intake
- Daily, weekly and monthly goals for steps, water and calories, with week and month charts
- Community challenges in cumulative or daily modes, with day-by-day progress
- Assigned workout and diet plans, saved favourites, and achievement badges
- Ask trainers questions in threads, leave feedback on routines and plans, and read the replies
For trainers
- Answer member questions and reply to feedback on routines and plans
- Send personalised suggestions to assigned members
- Create and maintain routines attributed to their profile
For administrators
- CMS for tips, routines and nutrition guides — rich content, images, categories and slugs
- User management across admin, trainer and member roles
- Scheduled classes with type, capacity and meeting links; challenges and participants
- Moderation for questions and feedback, an activity audit trail, and site and payment settings
- TOTP two-factor on admin accounts, and database migrations from the panel
Public
- Fitness tips, workout routines by difficulty, nutrition guides and a trainer directory
- Scheduled classes — online, in person or hybrid
- Registration, sign-in and password reset
Engineering
- Forty-plus REST endpoints with pagination, search and filters, documented in OpenAPI
- Next.js member app as a static export, so no Node process runs on the server
- Stripe Checkout and PayPal, both verified by webhook, with the membership gate enforced in the API
- Playwright end-to-end tests, PHPUnit, PHPStan and dependency auditing in GitHub Actions
- CSRF protection, rate limiting, HTML sanitisation, a content security policy and API token auth