# GYM Locker Management System — Setup Guide

## Prerequisites
- PHP 8.2+
- Composer
- Node.js 20+
- MySQL 8.0+ or MariaDB 10.6+

---

## Backend (Laravel)

```bash
cd backend

# 1. Install dependencies
composer install

# 2. Copy env file
cp .env.example .env

# 3. Generate app key
php artisan key:generate

# 4. Edit .env — set DB_DATABASE, DB_USERNAME, DB_PASSWORD

# 5. Run migrations + seed
php artisan migrate --seed

# 6. Create storage symlink
php artisan storage:link

# 7. Start development server
php artisan serve
# Runs on http://localhost:8000
```

**Default admin credentials:**
- Email: `admin@gymlocker.com`
- Password: `Admin@1234`

---

## Frontend (React + Vite)

```bash
cd frontend

# 1. Install dependencies
npm install

# 2. Start development server
npm run dev
# Runs on http://localhost:3000
# API calls proxied to http://localhost:8000
```

---

## Project Structure

```
backend/
├── app/
│   ├── Http/
│   │   ├── Controllers/Api/   ← All API controllers
│   │   ├── Requests/          ← FormRequest validation
│   │   └── Resources/         ← API Resource transformers
│   ├── Models/                ← Eloquent models
│   └── Services/              ← Business logic (RentalService, etc.)
├── database/
│   ├── migrations/            ← All DB migrations
│   └── seeders/               ← DatabaseSeeder (roles, users, lockers)
└── routes/api.php             ← All API routes

frontend/
├── src/
│   ├── api/                   ← Axios instance + all API calls
│   ├── components/
│   │   └── layout/            ← Sidebar, TopBar, AppLayout
│   ├── pages/                 ← All page components
│   ├── store/                 ← Zustand auth store
│   └── hooks/                 ← Custom hooks (useDebounce, etc.)
```

---

## Roles & Permissions

| Role         | Access                                                   |
|-------------|----------------------------------------------------------|
| super_admin  | Full access to everything                                |
| manager      | Clients, Lockers, Rentals, Payments, Reports, Settings   |
| front_desk   | Clients, view Lockers, create Rentals & Payments         |
| accountant   | View only + Payments + Reports                           |

---

## API Endpoints (summary)

| Method   | Endpoint                         | Description              |
|----------|----------------------------------|--------------------------|
| POST     | /api/auth/login                  | Login                    |
| GET      | /api/dashboard                   | KPI summary              |
| GET/POST | /api/clients                     | List / create clients    |
| GET/POST | /api/lockers                     | List / create lockers    |
| POST     | /api/rentals                     | Create rental            |
| POST     | /api/rentals/{id}/renew          | Renew rental             |
| POST     | /api/rentals/{id}/lost-key       | Report lost key          |
| GET      | /api/rentals/{id}/invoice/pdf    | Download invoice PDF     |
| GET      | /api/reports/revenue             | Revenue report           |
| GET      | /api/reports/occupancy           | Occupancy report         |

Full route list: `backend/routes/api.php`
