How danven-ong/nusgyms works
NUSGyms is a full-stack workout companion for NUS gym users. A signed-in user can manage workout templates, log sessions, review history and analytics, check gym capacity, and build a schedule-aware training plan. The frontend routes users through protected pages; the backend exposes API routes, applies authentication where configured, and delegates domain work to controllers and services backed by PostgreSQL. The source excerpts establish several backend call paths, but do not show most frontend API requests or the full analytics and capacity implementations, so those links are omitted.
Main entry points: App.tsx Frontend routes · authMiddleware.ts Token guard · workoutTemplateController.ts Template handlers · workoutSessionController.ts Session handlers
Components 23
Web application
- Frontend routes
frontend/src/App.tsx - Account pages
frontend/src/pages - Workout pages
frontend/src/pages - Planner pages
frontend/src/pages/PlannerPage.tsx
Accounts and settings
- Auth routes
backend/src/routes/authRoutes.ts - Account handlers
backend/src/controllers/authController.ts - Identity service
backend/src/services/auth.ts - Token guard
backend/src/middleware/authMiddleware.ts - Account settings
backend/src/controllers/settingsController.ts
Workout tracking
- Template handlers
backend/src/controllers/workoutTemplateController.ts - Session handlers
backend/src/controllers/workoutSessionController.ts - Workout service
backend/src/services/workout.ts - Session service
backend/src/services/workoutSession.ts - Template service
backend/src/services/workoutTemplate.ts
Planning and capacity
- Planner routes
backend/src/routes/plannerRoutes.ts - Planner handlers
backend/src/controllers/plannerController.ts - Planner services
backend/src/services - Gym capacity
backend/src/services/gymCapacity.ts
Progress and profile
- Workout analytics
backend/src/controllers/analyticsController.ts - Profile and weight
backend/src/controllers/profileController.ts
Other components
- Gym user
- API application
backend/src/app.ts - PostgreSQL
backend/src/db/index.ts
Connections 26
- Gym user → Frontend routes: uses
frontend/src/App.tsx - Frontend routes → Account pages: routes to
frontend/src/App.tsx - Frontend routes → Workout pages: routes to
frontend/src/App.tsx - Frontend routes → Planner pages: routes to
frontend/src/App.tsx - Frontend routes → API application: requests
- API application → Auth routes: mounts
backend/src/app.ts - API application → Planner routes: mounts
backend/src/app.ts - Auth routes → Account handlers: dispatches
backend/src/routes/authRoutes.ts - Auth routes → Token guard: authenticates
backend/src/routes/authRoutes.ts - Account handlers → Identity service: calls
backend/src/controllers/authController.ts - Account handlers → Token guard: uses identity
backend/src/controllers/authController.ts - Account settings → Identity service: sends OTP
backend/src/controllers/settingsController.ts - Planner routes → Planner handlers: dispatches
backend/src/routes/plannerRoutes.ts - Planner routes → Token guard: authenticates
backend/src/routes/plannerRoutes.ts - Planner handlers → Planner services: delegates
backend/src/controllers/plannerController.ts - Template handlers → Template service: calls
backend/src/controllers/workoutTemplateController.ts - Template handlers → Session service: calls
backend/src/controllers/workoutTemplateController.ts - Template handlers → Workout service: calls
backend/src/controllers/workoutTemplateController.ts - Session handlers → Template service: loads template
backend/src/controllers/workoutSessionController.ts - Session handlers → Session service: creates session
backend/src/controllers/workoutSessionController.ts - Session handlers → Workout service: stores sets
backend/src/controllers/workoutSessionController.ts - Workout service → PostgreSQL: reads and writes
backend/src/services/workout.ts - Session service → PostgreSQL: reads and writes
backend/src/services/workoutSession.ts - Template service → PostgreSQL: reads and writes
backend/src/services/workoutTemplate.ts - Profile and weight → Token guard: requires identity
backend/src/controllers/profileController.ts - Planner services → Gym capacity: may consult