#4 Tenant isolation in AI exercise lookup:
- Split OR query into two separate lookups: gym-specific first, then global
- Prevents cross-tenant exercise reference in workout generation
N2 workoutJobs memory leak:
- Add TTL-based cleanup (30 min expiry) to in-memory job Map
- Expired entries cleaned on every write to prevent unbounded growth
N3 attendance pagination for member/coach endpoints:
- listForMember and listForCoach now accept skip/take params
- myAttendance and coachAttendance return paginated responses
- Frontend updated to extract .items from Paginated<Attendance>
N4 coaches getMembers pagination:
- getMembers now accepts skip/take, returns [items, total]
- Controller uses getPagination() and returns paginated envelope
- Frontend updated to extract .items from Paginated<Member>
feat: Architecture & security improvements for scale
Phase 1 - Security:
- Protect /auth/login-accounts with authenticate + authorize('superAdmin')
- Implement refresh token revocation with DB persistence + token rotation
- Add per-endpoint rate limiting for /auth/login and /auth/forgot-password
- Enforce gymId + id compound where clauses for tenant isolation
Phase 2 - Database:
- Add RefreshToken model with revocation support
- Add isDemoAccount flag to User (replaces N+1 bcrypt in loginAccounts)
- Add missing indexes: Member.qrToken, Member.barcodeId,
Attendance.memberId+checkIn, Notification.gymId+status+createdAt
Phase 3 - Performance:
- Add Redis caching layer (cached/invalidateCache utilities)
- Cache gym hours with 5min TTL in sessions controller
- Add pagination to sessions list endpoint (was fetching ALL sessions)
- Optimize QR check-in to single CTE query (was 3-4 sequential queries)
- Cache active subscription status for 5min in attendance service
- Add MAX_LIMIT=100 validation to pagination utility
- Create sessions repos…