# 🎯 FINAL CHECKLIST - READY TO DEPLOY

## ✅ Application Status

| Item | Status | Note |
|------|--------|------|
| Assets Built | ✅ | `npm run build` completed |
| Admin Dashboard | ✅ | Broadcasting working |
| User Monitor | ✅ | Real-time alerts working |
| Reverb Server | ✅ | Running on localhost:8080 |
| API Endpoints | ✅ | `/api/alert/send` tested |
| Database | ✅ | SQLite database.sqlite ready |
| Vendor Dependencies | ✅ | All installed via composer |

---

## 📦 Deployment Checklist

### Pre-Upload Steps (Do Locally First)

- [x] Assets built: `npm run build` ✓
- [x] Database ready: `database.sqlite` ✓  
- [x] .env.production created ✓
- [x] All code tested and working ✓
- [ ] Backup created locally (zip entire project)

### Upload to cPanel

- [ ] Create directory structure in public_html
- [ ] Upload `app/` folder
- [ ] Upload `bootstrap/` folder
- [ ] Upload `config/` folder
- [ ] Upload `database/` folder (with database.sqlite)
- [ ] Upload `public/` folder (with build assets)
- [ ] Upload `resources/` folder
- [ ] Upload `routes/` folder
- [ ] Upload `storage/` folder
- [ ] Upload `vendor/` folder
- [ ] Upload `artisan` file
- [ ] Upload `composer.json` & `composer.lock`
- [ ] Create `.env` file with production config

### Post-Upload Configuration

- [ ] Set permissions:
  - `chmod -R 755 public/`
  - `chmod -R 775 storage/`
  - `chmod -R 775 bootstrap/cache/`
- [ ] Run migrations: `php artisan migrate`
- [ ] Cache config: `php artisan config:cache`
- [ ] Update `.env` with:
  - APP_URL = https://sensors.moscamp.site
  - REVERB_HOST = sensors.moscamp.site
  - REVERB_SCHEME = https
- [ ] Start Reverb: `php artisan reverb:start` (via Supervisor)
- [ ] Test: Visit https://sensors.moscamp.site/admin

---

## 🔑 Production .env Template

Gunakan konfigurasi ini ketika membuat `.env` di cPanel:

```env
APP_NAME=AlertCommand
APP_ENV=production
APP_KEY=base64:RTRCJYEuAe/oHh7AMCOkVy/IAcwgvr0rbFkUhC5r38s=
APP_DEBUG=false
APP_URL=https://sensors.moscamp.site

APP_LOCALE=id
APP_FALLBACK_LOCALE=id

LOG_CHANNEL=stack
LOG_LEVEL=info

DB_CONNECTION=sqlite

SESSION_DRIVER=database
SESSION_LIFETIME=120

BROADCAST_CONNECTION=reverb
FILESYSTEM_DISK=local

CACHE_STORE=database
QUEUE_CONNECTION=database

MAIL_MAILER=log
MAIL_FROM_ADDRESS=noreply@sensors.moscamp.site

REVERB_APP_ID=sensors-prod-001
REVERB_APP_KEY=your-secure-key-here
REVERB_APP_SECRET=your-secure-secret-here
REVERB_HOST=sensors.moscamp.site
REVERB_PORT=443
REVERB_SCHEME=https

VITE_REVERB_APP_KEY=your-secure-key-here
VITE_REVERB_HOST=sensors.moscamp.site
VITE_REVERB_PORT=443
VITE_REVERB_SCHEME=https
```

---

## 📁 Folder Structure di cPanel

```
public_html/
├── app/                          # Application code
├── bootstrap/                    # Framework bootstrap
├── config/                       # Configuration files
├── database/
│   ├── migrations/
│   ├── factories/
│   ├── seeders/
│   └── database.sqlite           # ⚠️ Make sure writable!
├── public/
│   ├── build/                    # Vite compiled assets
│   ├── index.php                 # Entry point
│   └── ...
├── resources/
│   ├── views/
│   ├── js/
│   ├── css/
│   └── ...
├── routes/
│   ├── web.php
│   ├── api.php
│   ├── channels.php
│   └── console.php
├── storage/                      # ⚠️ Make sure writable!
│   ├── app/
│   ├── framework/
│   ├── logs/
│   └── ...
├── vendor/                       # Composer packages
├── .env                          # Production config (create new)
├── .env.production              # Template for production
├── artisan                       # CLI tool
├── composer.json
├── composer.lock
└── ...
```

---

## ⚡ Quick Deploy Commands (Run in cPanel SSH)

```bash
# Navigate to public_html
cd /home/username/public_html

# Create .env from template
cp .env.production .env

# Set permissions
chmod -R 755 public/
chmod -R 775 storage/ bootstrap/cache/
chmod 644 .env

# Generate key (if needed)
php artisan key:generate

# Cache configuration
php artisan config:cache
php artisan route:cache
php artisan view:cache

# Optimize
composer install --optimize-autoloader --no-dev

# Start Reverb (background)
php artisan reverb:start &

# Test
php artisan tinker
# Type: DB::table('sqlite_master')->get()
```

---

## 🚨 Important Notes

1. **Database**: SQLite bersifat file-based. Pastikan folder `storage/` writable!
2. **Reverb**: WebSocket server harus tetap running di background. Gunakan Supervisor atau cron jobs.
3. **Assets**: Sudah di-build locally, tinggal upload folder `public/build/`
4. **SSL**: Pastikan domain punya SSL certificate (gunakan Let's Encrypt di cPanel)
5. **DNS**: Ensure DNS records pointing ke cPanel nameservers

---

## 📞 If Something Goes Wrong

1. Check logs: `tail -f storage/logs/laravel.log`
2. Check permissions: `ls -la storage/` (harus 775)
3. Check Reverb: `php artisan reverb:status`
4. Clear cache: `php artisan cache:clear && php artisan config:clear`
5. Restart Reverb: `pkill php && php artisan reverb:start`

---

**Status: ✅ READY TO DEPLOY**

Good luck! 🚀
