Skip to content

zaka41a/MyGym

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‹οΈ MyGym – Gym Management System

Professional gym management application with React frontend (modern) and PHP backend (REST APIs).

MyGym Documentation

🎨 Architecture

Frontend React (Modern - Recommended)

  • Framework: React 18 + TypeScript
  • Build: Vite 5.4
  • Styling: TailwindCSS with red/black theme
  • State: Zustand (authentication, navigation)
  • Router: React Router v6
  • Animations: Framer Motion

Backend PHP

  • REST APIs: JSON format with CORS
  • Auth: PHP Sessions + bcrypt hashing
  • Database: MySQL via XAMPP/PDO
  • Security: CSRF protection, input validation

πŸš€ Quick Start

Development Mode (⭐ Recommended)

1. Start XAMPP

# Launch Apache and MySQL from XAMPP Control Panel

2. Start React

cd /Applications/XAMPP/xamppfiles/htdocs/MyGym/frontend
npm install    # First time only
npm run dev    # Starts on http://localhost:5173

3. Access the application

  • React Frontend: http://localhost:5173
  • Backend APIs: http://localhost/MyGym/backend/api/

Production Mode

# Build React
cd frontend && npm run build

# Access via XAMPP
# http://localhost/MyGym/frontend/

πŸ“‘ API Endpoints

Authentication

Endpoint Method Description
/backend/api/auth/login.php POST Login with identifier + password
/backend/api/auth/register.php POST Registration (fullName, email, password)
/backend/api/auth/logout.php POST Logout
/backend/api/auth/me.php GET Get current user

Contact

Endpoint Method Description
/backend/api/contact.php POST Submit contact form

πŸ”— React + PHP Integration

How does it work?

In development:

  • React (port 5173) β†’ Vite proxy β†’ PHP Backend (port 80)
  • Proxy configuration in frontend/vite.config.ts
  • Environment variables in frontend/.env

In production:

  • React build in frontend/dist/
  • frontend/index.php serves the build via Apache
  • APIs accessible directly

Configuration

frontend/.env

VITE_API_BASE_URL=http://localhost/MyGym/backend/api

frontend/vite.config.ts

server: {
  proxy: {
    '/MyGym/backend': {
      target: 'http://localhost',
      changeOrigin: true
    }
  }
}

🎨 Red/Black Theme

Main Colors

--color-primary: #dc2626      /* Red */
--color-secondary: #7f1d1d    /* Dark Red */
--color-bg: #0a0a0a           /* Black */
--color-bg-muted: #1a1a1a     /* Medium Black */

Location

  • React: frontend/src/styles/global.css
  • PHP: Inline CSS in index.php, login.php, register.php

πŸš€ Features

βœ… Implemented

  • πŸ”‘ Complete Authentication

    • Login/Register React + PHP
    • Secure PHP Sessions
    • Automatic verification (whoami)
    • 3 roles: ADMIN, COACH, MEMBER
  • 🎨 Modern Interface

    • Professional red/black design
    • Smooth animations (Framer Motion)
    • Mobile-first responsive
    • Glassmorphism effects
  • 🏠 Main Pages

    • Home with hero, features, pricing, testimonials
    • Login/Register with validation
    • About, Services, Contact
  • πŸ“Š Complete Dashboards ⭐ NEW!

    • ADMIN Dashboard (KPIs, activity, stats)
    • COACH Dashboard (sessions, members, actions)
    • MEMBER Dashboard (upcoming sessions, progress, recovery)
    • Role-based sidebar navigation
    • Navbar automatically hidden on dashboard
  • πŸ”Œ REST APIs

    • Complete Auth (login, register, logout, me)
    • Contact form
    • CORS configured

πŸ“‹ Next Steps

  • πŸ’³ Subscription management pages (CRUD)
  • πŸ“… Course management pages (CRUD)
  • πŸ‘€ User profile pages (edit)
  • πŸ‘₯ User management pages (ADMIN)

πŸ“ Project Structure

MyGym/
β”œβ”€β”€ frontend/                 # React App
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/           # Pages (Home, Login, Dashboard)
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”‚   β”œβ”€β”€ api/         # API clients
β”‚   β”‚   β”‚   β”œβ”€β”€ store/       # Zustand stores
β”‚   β”‚   β”‚   └── types/       # TypeScript types
β”‚   β”‚   └── styles/          # global.css (theme)
β”‚   β”œβ”€β”€ dist/                # Production build
β”‚   β”œβ”€β”€ index.php            # XAMPP entry point
β”‚   β”œβ”€β”€ .htaccess            # Apache routing
β”‚   β”œβ”€β”€ vite.config.ts       # Vite config
β”‚   └── package.json
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ api/                 # REST APIs
β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication
β”‚   β”‚   β”œβ”€β”€ bootstrap.php    # Init (CORS, JSON)
β”‚   β”‚   β”œβ”€β”€ helpers.php      # Utils
β”‚   β”‚   └── contact.php
β”‚   β”œβ”€β”€ auth.php             # Session management
β”‚   β”œβ”€β”€ db.php               # MySQL connection
β”‚   └── *.php                # Classic endpoints
β”‚
β”œβ”€β”€ admin/                   # Admin Dashboard PHP
β”œβ”€β”€ coach/                   # Coach Dashboard PHP
β”œβ”€β”€ member/                  # Member Dashboard PHP
β”‚
β”œβ”€β”€ doc/                     # πŸ“¦ Archived files
β”‚   β”œβ”€β”€ old_styles/          # Old themes and styles
β”‚   β”œβ”€β”€ test_files/          # Test and diagnostic files
β”‚   β”œβ”€β”€ backups/             # File backups
β”‚   └── doc.png              # Documentation image
β”‚
β”œβ”€β”€ .htaccess                # Apache redirects
β”œβ”€β”€ README.md                # This file
└── QUICKSTART.md            # Quick guide

πŸ“¦ doc/ Folder

The doc/ folder contains archived files not used in the current version:

  • old_styles/ - Old themes and designs (legacy styles, red theme, special designs)
  • test_files/ - Test and diagnostic files (colors_summary, diagnose, test_*.php)
  • backups/ - File backups (index_backup.php)
  • doc.png - Project documentation image

πŸ› οΈ Useful Commands

Development

cd frontend
npm install          # Install dependencies
npm run dev          # Dev server (http://localhost:5173)
npm run lint         # Linter
npm run test         # Tests

Production

npm run build        # Build for production
npm run preview      # Preview the build

πŸ› Troubleshooting

Port 5173 busy

# Vite will automatically choose 5174
# Or free the port:
lsof -ti:5173 | xargs kill -9

"Build Required" Error

cd frontend && npm run build
ls -la frontend/dist/  # Check that the build exists

APIs return 404

  • βœ“ XAMPP Apache started
  • βœ“ Correct path: http://localhost/MyGym/backend/api/...
  • βœ“ mod_rewrite enabled in Apache

CORS errors

  • CORS headers in backend/api/bootstrap.php
  • Allowed origins: localhost:5173, localhost:5174

πŸ“š Technologies

Frontend

  • React 18.2, TypeScript 5.6
  • Vite 5.4, TailwindCSS 3.4
  • Framer Motion, React Router 6
  • Zustand, React Hook Form, Zod

Backend

  • PHP 7.4+, MySQL
  • PDO, Native Sessions
  • Password hashing (bcrypt)

DevOps

  • XAMPP (Apache + MySQL)
  • npm, ESLint, Prettier, Vitest

🎯 Next Steps

  1. Migrate dashboards to React

    • Create React Dashboard pages
    • APIs for users, courses, subscriptions
    • Tables and forms
  2. Security

    • Rate limiting
    • Refresh tokens
    • CSRF for all APIs
  3. Performance

    • Cache API queries
    • Image optimization
    • Lazy loading routes

πŸ“ Important URLs


About

MyGym a PHP based web application for managing gym members, subscriptions, and activities. Built with XAMPP for local development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors