How rienierborong/20241_t172_buksu-fitness-gym-management-system works
Project type and purpose
• This is a full-stack web application (“BukSU Fitness Gym – Digital Logging System”) consisting of:
• A React single-page application (client/)
• A Node.js/Express REST API server (server/)
• A database (via server/db/db.js, e.g., MongoDB with Mongoose models)
• External services (Gmail SMTP for emails, biometric fingerprint scanner hardware)
File structure to derive the architecture
• client/
• src/components, pages, assets → React components and views
• build/ and public/ → packaged static assets, fonts, CSS
• protected routes (ProtectedRoute.js) and front-end routing (React Router)
• server/
• routes/ → Express route definitions (auth.js, captchaRoutes.js, history.js, reportgen.js, etc.)
• controllers/ → business logic for captcha, email, report generation
• models/ → Mongoose models (User, LoginHistory)
• utils/ → middleware (authMiddleware), tokenService, cleanup jobs
• config/passport.js → Passport.js local or JWT configuration
• db/db.js → database connection setup
README for additional insights
• Uses biometric fingerprint scanning to log entries
• Limits three gym visits per week, auto-reset via a scheduled cleanup utility
• Sends emails (Gmail SMTP) for sign-up, reports, notifications
• No .env included; credentials supplied externally
Main components & their interactions
a. Frontend (React SPA)
• Users log in/sign up, scan fingerprint, view history, leaderboards, admin pages
• Routes protected by ProtectedRoute → checks valid JWT or session cookie
b. Backend API (Node/Express)
• Exposes REST endpoints for authentication, fingerprint data (captcha), history, reports, misc
• Uses Passport.js + tokenService for JWT/session issuance
• Controllers implement logic: validate fingerprint input, enforce visit limits, generate reports
• cleanup.js runs weekly job to reset visit counts
c. Database
• Stores User documents and LoginHistory entries
d. External services
• Biometric scanner hardware → frontend sends scanned data (via driver or USB interface) to backend /captchaRoutes
• Gmail SMTP (emailService route) → sends confirmation and report emails
Architectural patterns & design principles
• MVC-style backend separation (routes → controllers → models)
• RESTful API layer between front and back
• Stateless authentication with JWT (or sessions) via Passport.js
• Scheduled background job (cleanup) for weekly limit resets
• Component-based front-end with protected routes
• Each component clearly labeled (e.g., “React SPA,” “Express API,” “MongoDB”)
• Notes on authentication flow and scheduled cleanup