# Smooth Moves UK - Backend Setup Guide

## Quick Start

### 1. Start XAMPP
- Open XAMPP Control Panel
- Start **Apache** and **MySQL** services

### 2. Start Laravel Backend
```bash
cd d:/Project/Rapiddrop/Backend
php artisan serve
```
The backend will run at: **http://localhost:8000**

### 3. Start Frontend
```bash
cd d:/Project/Rapiddrop/smooth-moves-uk
npm run dev
```
The frontend will run at: **http://localhost:5173**

## Testing the Integration

### Submit a Quote
1. Visit: http://localhost:5173/quote
2. Fill out the quote form
3. Click "Get My Free Quote"
4. You should see a success message

### Admin Panel (Protected)
Access the quote management interface at: `http://localhost:5173/admin/quotes`
- **Login URL**: `http://localhost:5173/login`
- **Email**: `Saqib@admin.com`
- **Password**: `admin@123@`

### View Submitted Quotes
1. Visit: http://localhost:5173/admin/quotes
2. You'll see all submitted quotes
3. You can delete quotes by clicking the trash icon

### Check Database
```bash
C:\xampp\mysql\bin\mysql.exe -u root -e "USE smooth_moves; SELECT * FROM quotes;"
```

## API Testing with cURL

### Create a Quote
```bash
curl -X POST http://localhost:8000/api/quotes \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "Test User",
    "email": "test@example.com",
    "phone": "07700900000",
    "move_from": "London",
    "move_to": "Manchester",
    "move_date": "2026-02-15",
    "property_size": "3bed",
    "services": ["Packing service"],
    "message": "Test message"
  }'
```

### Get All Quotes
```bash
curl http://localhost:8000/api/quotes
```

### Delete a Quote
```bash
curl -X DELETE http://localhost:8000/api/quotes/1
```

## Database Connection Details

- **Database Name**: smooth_moves
- **Host**: 127.0.0.1
- **Port**: 3306
- **Username**: root
- **Password**: (empty)

## Troubleshooting

### Laravel Server Won't Start
- Check if port 8000 is already in use
- Try: `php artisan serve --port=8001`

### Database Connection Failed
1. Ensure XAMPP MySQL is running
2. Check `.env` file in Backend folder
3. Verify database exists: `C:\xampp\mysql\bin\mysql.exe -u root -e "SHOW DATABASES;"`

### CORS Errors in Frontend
- Ensure Laravel server is running on port 8000
- Check browser console for specific error messages
- Verify `config/cors.php` allows all origins

### Frontend Can't Connect to API
1. Check Laravel server is running: http://localhost:8000
2. Test API directly: http://localhost:8000/api/quotes
3. Check browser network tab for failed requests

## File Structure

```
Backend/
├── app/
│   ├── Http/Controllers/
│   │   └── QuoteController.php    # API endpoints
│   └── Models/
│       └── Quote.php               # Quote model
├── config/
│   └── cors.php                    # CORS configuration
├── database/
│   └── migrations/
│       └── 2026_01_19_120716_create_quotes_table.php
├── routes/
│   └── api.php                     # API routes
└── .env                            # Environment config

smooth-moves-uk/
└── src/
    └── pages/
        ├── Quote.tsx               # Quote form
        └── QuoteAdmin.tsx          # Admin panel
```

## Next Steps

1. **Add Authentication**: Protect the admin panel with login
2. **Email Notifications**: Send email when quote is submitted
3. **Export Data**: Add CSV export functionality
4. **Search & Filter**: Add search and filtering to admin panel
5. **Production Deployment**: Configure for production environment
