# Local Development Setup

## Requirements

| Tool | Version |
|------|---------|
| PHP | 8.2+ |
| Composer | 2.x |
| Node.js | 20+ |
| MySQL | 8.0+ |
| Redis | 7+ (optional, recommended) |

## Backend Setup

```bash
# Clone & install
git clone <repo-url> venuezy
cd venuezy
composer install
cp .env.example .env
php artisan key:generate

# Database
# Create MySQL database: venuezy
php artisan migrate
php artisan db:seed

# Storage
php artisan storage:link
```

### Seed Credentials

| Role | Email | Password |
|------|-------|----------|
| Super Admin | admin@venuezy.test | password |
| Owner | owner@venuezy.test | password |
| Customer | customer@venuezy.test | password |

### Run Backend

```bash
# All-in-one dev (server + queue + logs + vite)
composer dev

# Or separately:
php artisan serve          # http://localhost:8000
php artisan queue:listen   # process jobs
php artisan schedule:work  # scheduled tasks (dev)
```

API base URL: `http://localhost:8000/api/v1`

## Frontend Setup

```bash
cd booking-frontend
npm install
cp .env.example .env   # if exists
npm run dev            # http://localhost:5173
```

Ensure `.env` backend has:
```
CORS_ALLOWED_ORIGINS=http://localhost:5173
SANCTUM_STATEFUL_DOMAINS=localhost:5173
```

## Generate API Docs

```bash
php artisan scribe:generate
# View at: http://localhost:8000/docs/index.html
```

## Run Tests

```bash
# Backend
php artisan test

# Frontend
cd booking-frontend && npm run test
```

## Common Issues

**CORS error:** Check `CORS_ALLOWED_ORIGINS` and `SANCTUM_STATEFUL_DOMAINS`.

**Queue not processing:** Run `php artisan queue:listen`.

**Midtrans sandbox:** Set keys in `.env`, use `MIDTRANS_IS_PRODUCTION=false`.

**Migration error:** Run `php artisan migrate:fresh --seed` (⚠️ wipes data).

## IDE Setup

- **PHP:** Enable Intelephense / PHPStorm Laravel plugin
- **Frontend:** ESLint + TypeScript strict mode
- **Format:** `./vendor/bin/pint` (PHP), `npm run lint` (frontend)
