florida_gym/ai-context.md
2026-03-11 11:03:12 +05:30

4.7 KiB

GymPro - Gym Management System Context

  1. Project Overview GymPro is a comprehensive, multi-branch Gym Management System. It features a responsive web dashboard for Owners and Receptionists, and mobile-optimized views for Owners, Trainers, and Members. The frontend is built with React, Vite, Tailwind CSS, and Framer Motion. It currently relies on mock data and needs a robust backend to handle relational data, authentication, and complex business logic.

  2. User Roles & Access Owner (Super Admin): Full access to all branches. Can view global reports, manage investors, process branch-wise payrolls, and configure system masters. Receptionist: Branch-specific access. Can handle POS/billing, record collections/expenses, manage local inventory, register members, and view branch-specific reports. Trainer: Mobile-first access. Can view assigned clients, manage their schedule/bookings, mark attendance, and view their commission/earnings. Member: Mobile-first access. Can view their active plans, remaining sessions, book PT/Group sessions, and view their access/payment history.

  3. Core Entities & Required Database Schema The backend needs to support the following relational entities:

A. Users & Authentication (users table) Fields: id, name, email, phone, role (Owner, Receptionist, Trainer, Member), branch_id, status (Active, Inactive, Blocked), avatar_url, joining_date. Staff Specific: designation, member_count (for trainers). Member Specific: dob, gender, address, emergency_contact. Related Tables: user_documents: type, number, expiry_date, auto_notify, reminder_days. user_family: name, relationship, contact. user_plans (Plan History): plan_id, start_date, end_date, status, used_sessions, total_sessions. B. Branches (branches table) Fields: id, name, location, manager_name, status, start_date, salary_release_date. C. Payroll & Salaries (salaries & salary_history tables) Salary Config: user_id, type (Monthly/Daily), amount, frequency, cycle_start_date. Salary Advance: total_amount, months, monthly_deduction, remaining_amount, repay_mode (full/divide). Commission: amount_per_member (Flat rate per assigned member/session). Salary Release History: Tracks bulk salary releases per branch (date, total_amount, staff_count, releasor_name). D. Inventory & POS (products & stock_history tables) Products: id, name, category, branch_id, cost_price, selling_price, stock, reorder_level, sku, status. Stock History: Tracks every addition, deduction, or POS sale (product_id, qty_change, new_stock, action_type, date). E. Financials (collections & expenses tables) Collections (Income): id, date, branch_id, type (Product sale, Gym fee, PT fee), amount, method (Cash/Card/Online), items (JSON array of products sold if applicable). Expenses: id, date, branch_id, category, amount, type (Internal, Petty cash, ROI Payout), remarks. F. Investors & ROI (investors & investor_payouts tables) Investors: id, name, investment_date, amount, roi_percent, roi_period (Monthly/Yearly), profit_sharing_percent, branch_ids (Array or 'All'), status (Active/Closed). Payouts: investor_id, due_date, paid_date, expected_amount, paid_amount, adjustment (carry-over from previous under/over payments), status (Pending/Paid). G. CRM / Enquiries (enquiries table) Fields: id, name, contact, email, programs (Array), goal, source, assigned_trainer_id, status (New, Follow-up, Converted), next_follow_up_date. H. Scheduling & Calendar (sessions table) Fields: id, member_id, trainer_id, date_time, session_type (Personal/Group), status (Confirmed, Completed, Cancelled), cancellation_reason. 4. Key Business Logic & Backend Processes The backend API must handle the following complex logic:

Salary Calculation Engine: Formula: Net Payable = Base Salary + (Assigned Members * Commission Rate) - Monthly Advance Deduction. When a bulk "Salary Release" is triggered, the backend must generate individual payslips, deduct the monthly_deduction from the staff's remaining_advance, and log the total in expenses. Inventory Management: When a POS Collection is created (type: 'Product sale'), the backend must automatically deduct the sold quantities from the products table and log the changes in stock_history. Investor Payout Carry-over: If an investor is paid less or more than their expected_amount for a given month, the difference (adjustment) must automatically be added/subtracted from their next scheduled payout. Session Deductions: When a session is marked as "Completed" (or cancelled late), it must decrement the used_sessions count on the Member's currently active user_plan. Automated Cron Jobs / Background Tasks: Document Expiry: Daily check. If expiry_date - reminder_days is reached, trigger a notification. Plan Expiry: Automatically change user_plans status to 'Expired' when end_date passes.