How xuantruong5/be-fitlife works
1. Overall shape
- This is a Laravel 11-style monolith for a fitness/gym management system branded FITLIFE.
- The main architecture is classic Laravel: HTTP routes → middleware/request validation → controllers → Eloquent models → MySQL-style relational persistence via migrations/seeders.
2. Primary business domains
- The repo centers on managing members, trainers, branches, packages, schedules, attendance, reschedules, trainer notes, and trainer salaries.
- The controllers and migrations line up closely, so these are the core bounded areas the diagram should show.
3. Entry points
- routes/web.php is the main application surface for browser-based flows.
- routes/api.php exists as a separate API boundary, and config/sanctum.php plus personal_access_tokens migration indicate token-based API auth is supported.
- public/index.php is the Laravel front controller; resources/views contains the only obvious server-rendered templates.
4. Role-based access boundaries
- There are explicit middleware classes for members and trainers: MemberMiddleware and TrainerMiddleware.
- Separate request classes exist for admin login and member registration/profile updates, which suggests role-specific auth and validation rules.
- The app distinguishes at least three actor types: admin, member, and trainer, with admin-specific controllers and an Admin model.
5. Admin and operational management
- AdminController likely handles admin authentication/administrative dashboard flows.
- Operational CRUD controllers manage the system’s master data: BranchController, PackageController, TrainerController, MemberController/MembersController.
- This is the administrative control plane for setting up the gym’s data before member-facing workflows use it.
6. Scheduling and attendance flow
- Scheduling is split into dedicated parts: TrainerScheduleController, ScheduleMemberController, and RescheduleController.
- AttendanceController sits downstream of scheduling, implying attendance is recorded against a member’s scheduled sessions.
- The related models/migrations (TrainerSchedule, ScheduleMember, Attendance, Reschedule) show a relational workflow from planned sessions to check-ins and exceptions.
7. Trainer-centric payroll and notes
- TrainerSalaryController and TrainerNoteController indicate the system also supports internal trainer administration, not just member booking.
- This adds an HR/operations branch to the architecture: trainer schedules generate salary-related records, while notes likely capture performance or session details.
8. Persistence model
- The data layer is Eloquent-based with one migration per business table under database/migrations.
- Seeders populate baseline entities such as admins, branches, packages, trainers, trainer schedules, and members.
- There are some duplicated/lowercase model files (branches.php, packages.php, etc.), which suggests legacy naming or compatibility artifacts; the canonical models appear to be the capitalized classes.
9. Communication and email
- app/Mail/MasterMail.php plus resources/views/view_mail_register.blade.php show a mail notification path, likely used during member registration.
- This is the only explicit asynchronous/external communication visible beyond the database, so email is a small but important side channel.
10. Frontend and assets
- UI is minimal and server-rendered: resources/views/welcome.blade.php plus the mail template.
- resources/js, resources/css, and vite.config.js indicate the app uses Vite for asset bundling, but the repository is still predominantly backend-driven.
11. Runtime and infrastructure
- Standard Laravel runtime components are present: cache, session, logging, filesystem, queue, and mail config.
- storage and bootstrap/cache are normal framework runtime stores; queue support exists, but no custom job-heavy subsystem is visible in the tree.
12. Testing and delivery
- PHPUnit tests are present under tests/.
- GitHub Actions workflows cover tests, pull requests, issues, and changelog updates, so CI/CD is part of the project’s operational boundary.
- README links to external FITLIFE documentation, which likely serves as the higher-level product/spec reference for this codebase.
13. Architecture summary for a diagram
- Draw the system as a Laravel monolith with three actor lanes: admin, trainer, member.
- Show the request path through middleware and validation into controllers, then into Eloquent models and relational tables.
- Put scheduling/attendance as the central domain workflow, with branch/package/member/trainer master data feeding it, and email as an outward notification edge.
Main entry points: web.php Web routes · migrations Migrations · seeders Seed data · MemberController.php Members
Components 32
Actors
Primary user roles and entry surfaces
- Front controller · Main web entry point for all browser requests
public/index.php
HTTP Layer
Laravel request handling and policy boundaries
- Web routes · Primary browser-facing routing boundary
routes/web.php - API routes · Separate token-based API boundary
routes/api.php - Member guard · Restricts member-only flows
app/Http/Middleware/MemberMiddleware.php - Trainer guard · Restricts trainer-only flows
app/Http/Middleware/TrainerMiddleware.php - Admin login · Validates admin authentication input
app/Http/Requests/Admin/LoginAdminRequest.php - Member requests · Validates member registration and profile updates
app/Http/Requests/Member/RegisterMemberRequest.php - Sanctum auth · Token-based API authentication support
config/sanctum.php
Core Domain
Business controllers and workflows
- Admin panel · Admin authentication and operational dashboard flows
app/Http/Controllers/AdminController.php - Members · Member-facing and admin member management
app/Http/Controllers/MemberController.php - Trainers · Trainer management and related admin flows
app/Http/Controllers/TrainerController.php - Branches · Branch master data management
app/Http/Controllers/BranchController.php - Packages · Membership package management
app/Http/Controllers/PackageController.php - Schedules · Trainer schedule creation and member assignment
app/Http/Controllers/TrainerScheduleController.php - Enrollments · Links members to scheduled sessions
app/Http/Controllers/ScheduleMemberController.php - Attendance · Records session check-ins against schedules
app/Http/Controllers/AttendanceController.php - Reschedules · Handles schedule changes and exceptions
app/Http/Controllers/RescheduleController.php - Trainer notes · Captures trainer session notes and observations
app/Http/Controllers/TrainerNoteController.php - Trainer salary · Manages trainer compensation records
app/Http/Controllers/TrainerSalaryController.php - Mail notify · Registration email notification path
app/Mail/MasterMail.php
Data Layer
Eloquent models and relational tables
- Admin · Administrative actor model
app/Models/Admin.php - Member · Member account and profile model
app/Models/Member.php - Trainer · Trainer account and profile model
app/Models/Trainer.php - Branch · Gym branch model
app/Models/Branch.php - Package · Membership package model
app/Models/Package.php - Schedule member · Member-to-schedule linkage model
app/Models/ScheduleMember.php - Attendance · Check-in record model
app/Models/Attendance.php - Reschedule · Schedule exception and change model
app/Models/reschedule.php - Trainer note · Trainer note model
app/Models/TrainerNote.php - Trainer salary · Trainer salary model
app/Models/TrainerSalary.php - Migrations · Relational tables for users, admins, trainers, members, packages, branches, schedules, attendance, reschedules, notes, salaries, and tokens
database/migrations - Seed data · Baseline admins, branches, packages, trainers, members, and schedules
database/seeders
Connections 48
- Front controller → Web routes: boots · Laravel front controller dispatches web traffic
- Front controller → API routes: serves · Front controller also supports API entry through Laravel routing
- Web routes → Admin panel: admin flows · Web routes send admin requests to the admin controller
- Web routes → Members: member flows · Web routes expose member management and profile flows
- Web routes → Trainers: trainer flows · Web routes expose trainer management flows
- Web routes → Branches: master data · Web routes expose branch administration
- Web routes → Packages: master data · Web routes expose package administration
- Web routes → Schedules: scheduling · Web routes expose schedule management
- Web routes → Enrollments: booking · Web routes expose member-to-schedule assignment
- Web routes → Attendance: check-in · Web routes expose attendance capture
- Web routes → Reschedules: changes · Web routes expose reschedule handling
- Web routes → Trainer notes: notes · Web routes expose trainer note capture
- Web routes → Trainer salary: payroll · Web routes expose trainer salary management
- API routes → Sanctum auth: auth · API routes rely on token-based authentication
- Member guard → Members: protects · Member-only middleware guards member operations
- Trainer guard → Trainers: protects · Trainer-only middleware guards trainer operations
- Admin login → Admin panel: validates · Admin login request validates controller input
- Member requests → Members: validates · Member request classes validate registration and profile updates
- Admin panel → Admin: uses · Admin controller reads and authenticates admin accounts
- Members → Member: uses · Member controller manages member records
- Trainers → Trainer: uses · Trainer controller manages trainer records
- Branches → Branch: uses · Branch controller manages branch records
- Packages → Package: uses · Package controller manages package records
- Schedules → Schedule member: uses · Schedule controller creates trainer-to-member sessions
- Enrollments → Schedule member: uses · Enrollment controller links members to schedules
- Attendance → Attendance: uses · Attendance controller records check-ins
- Reschedules → Reschedule: uses · Reschedule controller manages schedule exceptions
- Trainer notes → Trainer note: uses · Trainer note controller stores session notes
- Trainer salary → Trainer salary: uses · Salary controller manages compensation records
- Members → Mail notify: notifies · Member registration can trigger email notification
- Admin → Migrations: persisted by · Admin records are defined in schema migrations
- Member → Migrations: persisted by · Member records are defined in schema migrations
- Trainer → Migrations: persisted by · Trainer records are defined in schema migrations
- Branch → Migrations: persisted by · Branch records are defined in schema migrations
- Package → Migrations: persisted by · Package records are defined in schema migrations
- Schedule member → Migrations: persisted by · Schedule-member links are defined in schema migrations
- Attendance → Migrations: persisted by · Attendance records are defined in schema migrations
- Reschedule → Migrations: persisted by · Reschedule records are defined in schema migrations
- Trainer note → Migrations: persisted by · Trainer notes are defined in schema migrations
- Trainer salary → Migrations: persisted by · Trainer salaries are defined in schema migrations
- Seed data → Admin: seeds · Seeder set bootstraps admin data
- Seed data → Branch: seeds · Seeder set bootstraps branches
- Seed data → Package: seeds · Seeder set bootstraps packages
- Seed data → Trainer: seeds · Seeder set bootstraps trainers
- Seed data → Member: seeds · Seeder set bootstraps members
- Seed data → Schedule member: seeds · Seeder set bootstraps trainer schedules
- Schedules → Trainer: depends on · Schedules are built around trainers
- Schedules → Branch: depends on · Schedules likely depend on branch placement