# 🏔️ BlueMountainsConnect — Complete Deployment Checklist
# ==========================================================

## PRE-DEPLOYMENT CHECKLIST

### 1. Domain & Hosting
- [ ] Domain purchased: bluemountainsconnect.com.au
- [ ] Domain pointed to cPanel hosting nameservers
- [ ] SSL certificate installed (cPanel > SSL/TLS > AutoSSL)
- [ ] cPanel login confirmed

### 2. Upload Files
- [ ] Upload `bluemountainsconnect/` folder to server
      - Recommended path: /home/youraccount/bluemountainsconnect/
      - NOT inside public_html
- [ ] Upload `.htaccess` to public_html/

---

## STEP-BY-STEP DEPLOYMENT

### STEP 1 — MySQL Database Setup
1. cPanel → MySQL Databases
2. Create Database: youraccount_bmconnect
3. Create User: youraccount_dbuser (strong password)
4. Add User to Database → ALL PRIVILEGES
5. Note down: host (localhost), db name, username, password

### STEP 2 — Run Web Installer
1. Temporarily place `installer/` folder inside public_html
2. Visit: https://yourdomain.com.au/installer/
3. Follow 4-step installation wizard
4. ✅ Database tables created
5. ✅ Super admin account created
6. ⚠️  DELETE the installer folder from public_html after completion!

### STEP 3 — Backend Node.js App
1. cPanel → Setup Node.js App → Create Application
   - Version: 18.x
   - Root: /home/youraccount/bluemountainsconnect/backend
   - Startup file: src/server.js
   - URL: yourdomain.com.au
2. Add Environment Variables:
   ```
   DB_HOST=localhost
   DB_NAME=youraccount_bmconnect
   DB_USER=youraccount_dbuser
   DB_PASS=YOUR_PASSWORD
   JWT_SECRET=RUN: node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
   SITE_URL=https://yourdomain.com.au
   PORT=3001
   NODE_ENV=production
   ```
3. Click "Run NPM Install" → wait for completion
4. Click "Restart"
5. Test: https://yourdomain.com.au/api/health
   → Should return: {"status":"ok","app":"BlueMountainsConnect"}

### STEP 4 — Frontend Next.js App
1. Create `.env.local` in /bluemountainsconnect/frontend/:
   ```
   NEXT_PUBLIC_API_URL=https://yourdomain.com.au/api
   NEXT_PUBLIC_SITE_URL=https://yourdomain.com.au
   NODE_ENV=production
   PORT=3000
   ```
2. cPanel → Setup Node.js App → Create Application
   - Version: 18.x
   - Root: /home/youraccount/bluemountainsconnect/frontend
   - Startup file: server.js
   - URL: yourdomain.com.au
3. Click "Run NPM Install" → wait
4. Open cPanel Terminal (or SSH):
   ```bash
   cd /home/youraccount/bluemountainsconnect/frontend
   npm run build
   ```
   Wait for build to complete (5-10 minutes first time)
5. Back in cPanel Node.js → Restart frontend app
6. Test: https://yourdomain.com.au → Homepage loads

### STEP 5 — Configure .htaccess Routing
1. Upload `public_html/.htaccess` to your public_html folder
2. This routes /api/* → backend (3001), everything else → frontend (3000)
3. Test routing:
   - https://yourdomain.com.au → Frontend ✅
   - https://yourdomain.com.au/api/health → Backend ✅
   - https://yourdomain.com.au/town/katoomba → Town page ✅

### STEP 6 — First Login & Configuration
1. Go to https://yourdomain.com.au/login
2. Log in with your super admin credentials from the installer
3. Go to /admin → Settings
4. Configure:
   - Site email
   - Enable/disable registrations
   - Set admin approval requirement
5. Test registration flow from a different browser

---

## POST-DEPLOYMENT SEO SETUP

### Google Search Console
1. Go to search.google.com/search-console
2. Add property: https://bluemountainsconnect.com.au
3. Verify via DNS TXT record in cPanel → Zone Editor
4. Submit sitemap: https://yourdomain.com.au/sitemap.xml
5. Request indexing for homepage and town pages

### Google My Business
- Create a GMB listing for BlueMountainsConnect as a local platform
- This boosts local search visibility significantly

### Key URLs to Submit to Google
```
https://yourdomain.com.au
https://yourdomain.com.au/town/katoomba
https://yourdomain.com.au/town/lithgow
https://yourdomain.com.au/town/leura
https://yourdomain.com.au/businesses
https://yourdomain.com.au/events
https://yourdomain.com.au/jobs
```

---

## MAINTENANCE

### Restarting Apps
If the site goes down, in cPanel → Setup Node.js App:
1. Restart the backend app
2. Restart the frontend app

### Updating the App
1. Upload new files via File Manager or FTP
2. SSH: cd frontend && npm run build
3. Restart both Node.js apps in cPanel

### Database Backups
cPanel → Backup → Download MySQL Databases backup weekly

---

## TROUBLESHOOTING

| Issue | Solution |
|-------|----------|
| `/api/health` not working | Check backend Node.js app is running in cPanel |
| Frontend blank page | Run `npm run build` again, restart frontend app |
| Images not uploading | Check /backend/uploads/ folder has 755 permissions |
| Login not working | Check JWT_SECRET env var is set in backend app |
| Installer DB error | Verify DB user has ALL PRIVILEGES on the database |

---

## SUPPORT
Built by Waves Digital Solutions for BlueMountainsConnect
wavesdigitalsolutions.com.au
