# Laravel + React (Vite) Boilerplate

This project uses:

- Laravel (backend, API, MySQL connection)
- React + Vite in a separate `frontend` folder
- Production frontend build output in `public/app` (served by Laravel)

## Project Structure

- `frontend` - standalone React app (Vite)
- `routes/api.php` - backend health API (`/api/health`)
- `routes/web.php` - serves `public/app/index.html` for frontend routes
- `public/app` - built frontend assets (generated)

## One-Time Setup

From the Laravel root folder:

```bash
composer run setup
```

This will:

- install PHP dependencies
- create `.env` if missing
- generate app key
- run migrations
- install frontend dependencies
- build frontend into `public/app`

## One Command For Dev

```bash
composer run dev
```

This runs both:

- Laravel API/server (`http://127.0.0.1:8000`)
- Vite frontend dev server (`http://127.0.0.1:5173`)

In dev mode, frontend API calls to `/api/*` are proxied to Laravel.

## One Command For Production Build

```bash
composer run build
```

This builds React into `public/app` and runs migrations.

After build, serve Laravel only (Apache/Nginx/XAMPP or `php artisan serve`) and the frontend loads directly from Laravel.

## Database Health Check

`GET /api/health` returns:

- app status
- database connection name
- database connection state and message

The React homepage calls this endpoint and shows whether DB is connected.

## Login Credentials (Seeded)

After running seeders, you can log in with:

- Admin: `admin@example.com` / `admin12345`
- User: `user1@example.com` / `user12345`
- User: `user2@example.com` / `user12345`

## Referral Link Note

Referral links are generated from `APP_URL`. If link host/port is wrong, update `.env` and clear config:

```bash
php artisan config:clear
```

## Error Logs

Backend errors are now written to:

- `storage/logs/laravel.log` (all levels)
- `storage/logs/error.log` (error and above)
