Back to projectsesc fig. 00 — the trailer
gymflow_trailer.mp4now playing · 1:26
1280×720 · 30 fpsrendered from the live demo17 screens · real workflowscode typed liveno sound
endpoints68builtsolo
Live demoSolo buildFirst full-stack project

GymFlow

A full-stack management system for a three-location gym: members, staff and shifts, inventory, reorders, vendors and analytics, all behind a REST API I designed and built myself.

ROLESolo · design, frontend, backend, database, deploy
WHENJan 3 → Feb 2, 2026 · 31 days
STACKHTML/CSS · vanilla JS · Node · Express 5 · MySQL
WHYMy first full-stack build, for a gym I'd actually want to run
68REST endpoints
16MySQL tables
120+SQL queries
53commits, solo

This is the project where I learned the fundamentals: semantic HTML, CSS architecture, the DOM, async JavaScript, Node and Express, and relational design in MySQL. I built it because I love the gym, and I wanted to understand what actually happens between clicking "Check in" and a row landing in a database.

01 —

The live tour

17 screens from the deployed app, including the real member and staff workflows (side panels, check-in, payments, an admin-gated delete and shift scheduling), with the network requests each one makes and the SQL behind them. The demo database is real, and it rebuilds itself every night (more on that in chapter 08).

8admin pages
17screens in the tour
1request to load the whole dashboard
js/pages/admin-dashboard.js
12const API_BASE_URL = window.location.hostname === 'localhost'
13 || window.location.hostname === '127.0.0.1'
14 ? 'http://127.0.0.1:5000/api'
15 : '/api';
Fun detailThe dashboard fires a single GET /api/dashboard. The server runs 8 queries and answers with one JSON payload, so the page renders in one round trip instead of eight.
Honest noteAll member and staff records are generated demo data. Response times in the network panel are illustrative.
02 —

Architecture

A classic three-tier app with no framework on the front: static HTML pages served by Express, vanilla JavaScript calling a JSON API, and MySQL underneath. Every layer is something I wrote by hand, which is exactly why I learned so much from it.

3tiers
8routers
10pooled DB connections
backend/server.js
52app.use(cors());
53app.use(express.json());
54app.set('trust proxy', true); // Railway sits in front of us
55…
56app.use('/api/', apiLimiter);
57app.use('/api/members', memberRoutes);
58app.use('/api/inventory', inventoryRoutes);
59app.use(express.static(path.join(__dirname, '..')));
backend/config/database.js
1const pool = mysql.createPool({
2 host: process.env.DB_HOST,
3 user: process.env.DB_USER,
4 password: process.env.DB_PASSWORD,
5 database: process.env.DB_NAME,
6 connectionLimit: 10
7});
Why it mattersOne Express app serves both the API and the static pages, so there's one deploy, one origin and no CORS headaches in production.
03 —

The API, mapped

68 endpoints across 8 resource routers, plus a manual reset endpoint in server.js. Everything follows REST conventions: nouns for resources, HTTP verbs for actions, and status codes that mean something (201 on create, 400 on validation, 401 for admin, 429 for rate limits).

36GET
16POST
12PUT
4DELETE
routerendpointshighlights
/api/members16CRUD, freeze, payments, check-ins
/api/inventory27products, stock, reorders, vendors, charts
/api/staff8CRUD, reactivate, trainers
/api/locations7details, capacity, comparison
/api/shifts5schedule CRUD + overlap guard
/api/settings2read + update
/api/dashboard1one call, 8 queries
/api/admin2verify password, reset demo
Trade-offState changes like freeze, approve and receive are verbs in the URL (POST /:id/freeze) rather than a generic PATCH. Less "pure" REST, but every action is explicit, easy to rate-limit and easy to read in logs.
04 —

Life of a request

Follow one check-in from the click to the toast. Before the handler ever touches the database, the request passes two rate limiters and a validator that itself queries MySQL to make sure the member exists and is active.

4gates before the handler
2SQL round trips
201on success
backend/routes/members.js
1005router.post('/:id/check-in', checkInLimiter, validateCheckIn,
1006 handleValidationErrors, (req, res) => {
1007 const insertQuery = `INSERT INTO check_ins (member_id, location_id)
1008 VALUES (?, ?)`;
1009 db.query(insertQuery, [memberId, location_id], (err, result) => {
1010 const checkInId = result.insertId;
1011 // …SELECT with JOINs, then:
1012 res.status(201).json({ success: true, check_in: checkIn });
Edge casesFrozen or cancelled member → 400 with the reason. Unknown member → 400 "Member not found". Spamming the button → 429 after 500 check-ins in 15 minutes. The INSERT succeeds but the follow-up SELECT fails → a distinct 500 that says the check-in was recorded.
05 —

The database

16 tables, normalized, with 14 foreign keys. Locations sit at the centre: members, staff, shifts, stock, revenue and reorders all hang off them. The delete rules were deliberate choices, not defaults.

16tables
14foreign keys
195seed statements
relationshipon deletewhy
check_ins → membersCASCADEhistory goes with the member
check_ins → locationsRESTRICTcan't delete a branch with visits
shifts → staffCASCADEno orphaned schedule rows
reorder_requests → vendorsSET NULLkeep the order, lose the vendor
payment_methods → membersCASCADEcard on file leaves with them
Why it matterspayment_methods stores only card_type, last_four and expiry, never a full card number. Even in a demo I wanted the schema to look like something a real business could ship.
06 —

SQL that does real work

About 120 queries, all written by hand and all parameterized with ? placeholders so user input never becomes SQL. Some of the most interesting logic lives in the database rather than in JavaScript.

120+hand-written queries
0string-built SQL
3overlap cases checked
backend/middleware/validation.js
949SELECT id, start_time, end_time FROM shifts
950WHERE staff_id = ? AND shift_date = ?
951 AND (
952 (? >= start_time AND ? < end_time) -- starts during
953 OR (? > start_time AND ? <= end_time) -- ends during
954 OR (? <= start_time AND ? >= end_time) -- swallows it
955 )
Lesson learnedQueries that worked on my machine failed in production, because MySQL on Linux treats table names as case-sensitive. The Jan 30 fixes lowercased the table names in the SQL (and caught a stale inventory_products reference along the way).
07 —

Security & validation

No login system yet, so I focused on what an admin tool can't ship without: throttling, strict input validation, and a second check before anything destructive.

4rate-limit tiers
23validator chains
2132lines of validation
backend/middleware/adminAuth.js
16async function requireAdmin(req, res, next) {
17 const adminUsername = req.headers['x-admin-username'];
18 const adminPassword = req.headers['x-admin-password'];
19 …
20 const isMatch = await bcrypt.compare(adminPassword, admin.password_hash);
limiterlimitwindow
apiLimiter100015 min
checkInLimiter50015 min
paymentLimiter1001 hour
authLimiter2015 min
Lesson learnedRailway puts a proxy in front of the app, so the rate limiter needs Express to trust it to see each visitor's real IP from X-Forwarded-For. The Jan 30 fix moved app.set('trust proxy', true) onto the Express app itself and relaxed the limits for the public demo.
08 —

Ship it: deploy & self-healing demo

Pushing to main triggers a Railway build and deploy, so the live site always matches the repo. Because anyone can click Delete on a public demo, a cron job rebuilds the whole database from seed.sql every night at 3 AM Toronto time.

195statements per reset
0errors
3AMdaily, Toronto
backend/server.js
67cron.schedule('0 0 3 * * *', async () => {
68 const result = await resetDatabase();
69}, { timezone: "America/Toronto" });
backend/utils/resetDatabase.js
26const statements = seedSQL
27 .split(';')
28 .map(stmt => stmt.trim())
29 .filter(stmt => stmt.length > 0 && !stmt.startsWith('---'));
30for (const statement of statements) { await run(statement); }
Honest noteThe pipeline is push-to-deploy with no automated test stage yet. Adding a Jest + Supertest suite in GitHub Actions that has to pass before Railway deploys is next on my list.
09 —

Frontend, by hand

No React and no bundler. Eight HTML pages share a sidebar, modal system and design tokens, and each page has its own script that fetches from the API and paints the DOM. Doing it the hard way taught me what frameworks are actually saving you from.

8HTML pages
21CSS files
12JS files
js/pages/admin-dashboard.js
401const response = await fetch(`${API_BASE_URL}/dashboard`);
402if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
403const data = await response.json();
404updateKPIs(data.kpis);
405updateBranches(data.branches);
406createMembershipChart(data.membershipGrowth);
407createRevenueChart(data.revenueByLocation);
admin/dashboard.html
1<link rel="stylesheet" href="../css/variables.css">
2<link rel="stylesheet" href="../css/base.css">
3<link rel="stylesheet" href="../css/layout.css">
4<link rel="stylesheet" href="../css/components/cards.css">
5<link rel="stylesheet" href="../css/pages/admin-dashboard.css">
Why it mattersCSS is split into tokens → base → layout → components → pages. Changing the accent red in variables.css recolours all 8 pages at once.
10 —

The build, and what I learned

31 days, 53 commits, one person. It started as a members table and grew into eight modules. The busiest day, Jan 27, was launch day: 10 commits that added input validation and rate limiting, the demo auto-reset, the locations and settings pages, an Express 5 migration and the Railway deploy fixes.

53commits
31days
10commits on the peak day
✓Designing a REST API and a normalized schema from scratch
✓Thinking in requests: middleware order, status codes, error paths
✓Shipping to a real host and debugging production-only bugs
○Next: real auth (sessions or JWT) to replace header credentials
○Next: Jest + Supertest in CI, then async/await across all routes