Professional gym management application with React frontend (modern) and PHP backend (REST APIs).
- 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
- REST APIs: JSON format with CORS
- Auth: PHP Sessions + bcrypt hashing
- Database: MySQL via XAMPP/PDO
- Security: CSRF protection, input validation
1. Start XAMPP
# Launch Apache and MySQL from XAMPP Control Panel2. Start React
cd /Applications/XAMPP/xamppfiles/htdocs/MyGym/frontend
npm install # First time only
npm run dev # Starts on http://localhost:51733. Access the application
- React Frontend:
http://localhost:5173 - Backend APIs:
http://localhost/MyGym/backend/api/
# Build React
cd frontend && npm run build
# Access via XAMPP
# http://localhost/MyGym/frontend/| 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 |
| Endpoint | Method | Description |
|---|---|---|
/backend/api/contact.php |
POST | Submit contact form |
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.phpserves the build via Apache- APIs accessible directly
frontend/.env
VITE_API_BASE_URL=http://localhost/MyGym/backend/apifrontend/vite.config.ts
server: {
proxy: {
'/MyGym/backend': {
target: 'http://localhost',
changeOrigin: true
}
}
}--color-primary: #dc2626 /* Red */
--color-secondary: #7f1d1d /* Dark Red */
--color-bg: #0a0a0a /* Black */
--color-bg-muted: #1a1a1a /* Medium Black */- React:
frontend/src/styles/global.css - PHP: Inline CSS in
index.php,login.php,register.php
-
π 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
- π³ Subscription management pages (CRUD)
- π Course management pages (CRUD)
- π€ User profile pages (edit)
- π₯ User management pages (ADMIN)
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
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
cd frontend
npm install # Install dependencies
npm run dev # Dev server (http://localhost:5173)
npm run lint # Linter
npm run test # Testsnpm run build # Build for production
npm run preview # Preview the build# Vite will automatically choose 5174
# Or free the port:
lsof -ti:5173 | xargs kill -9cd frontend && npm run build
ls -la frontend/dist/ # Check that the build exists- β XAMPP Apache started
- β Correct path:
http://localhost/MyGym/backend/api/... - β mod_rewrite enabled in Apache
- CORS headers in
backend/api/bootstrap.php - Allowed origins: localhost:5173, localhost:5174
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
-
Migrate dashboards to React
- Create React Dashboard pages
- APIs for users, courses, subscriptions
- Tables and forms
-
Security
- Rate limiting
- Refresh tokens
- CSRF for all APIs
-
Performance
- Cache API queries
- Image optimization
- Lazy loading routes
- React Application β: http://localhost:5173 (development)
- React Dashboard: http://localhost:5173/dashboard (after login)
- Production: http://localhost/MyGym/ (after build)
- Backend APIs: http://localhost/MyGym/backend/api/
- PHP Admin Dashboard: http://localhost/MyGym/admin/ (legacy, to be replaced)
