# AHA Training Website - Quick Start Guide

## 🚀 5-Minute Deployment

### Option 1: Automated Deployment (Recommended)

```bash
# 1. Upload files to server
scp -r "aha training" root@198.211.114.12:/var/www/

# 2. Connect to server
ssh root@198.211.114.12

# 3. Run deployment script
cd /var/www/aha\ training/
chmod +x DEPLOY.sh
./DEPLOY.sh

# 4. Follow prompts - Done!
```

### Option 2: Manual Deployment

```bash
# 1. Set permissions
cd /var/www/aha\ training/
chmod 700 private/
chmod 755 private/nda_records/
chmod 666 private/aha_training.db

# 2. Initialize database
touch private/aha_training.db private/security.log
chmod 666 private/*.db private/*.log

# 3. Configure web server (see README.md)

# 4. Test
curl http://your-domain.com/aha training/public/
```

---

## 🎯 First Test

1. **Visit Homepage**
   ```
   https://aha.adampowell.pro/public/
   ```

2. **Navigate to NDA Page**
   - Click "Contact (NDA Required)" in navigation

3. **Sign NDA**
   - Enter your name and email
   - Choose signature type (drawn or typed)
   - Sign and submit

4. **Check Email**
   - You should receive notification at `t3h28@gmail.com`

5. **Access Contact Form**
   - After NDA signing, you'll be redirected to contact page
   - Send a test message

6. **Verify Database**
   ```bash
   sqlite3 /var/www/aha\ training/private/aha_training.db
   SELECT * FROM nda_records;
   .exit
   ```

---

## 📧 Email Configuration

**Default:** Uses PHP `mail()` function

**To test email:**
```bash
echo "Test email" | mail -s "Test Subject" t3h28@gmail.com
```

**If emails not working:**
1. Check postfix/sendmail is installed: `which sendmail`
2. Install if needed: `apt install postfix`
3. Configure: `dpkg-reconfigure postfix`

---

## 🔒 Security Checklist

Before going live:

```bash
# 1. Verify private directory is blocked
curl https://your-domain.com/aha training/private/
# Should return 403 Forbidden

# 2. Verify database is blocked
curl https://your-domain.com/aha training/private/aha_training.db
# Should return 403 Forbidden

# 3. Verify backend files are blocked
curl https://your-domain.com/aha training/app/database.php
# Should return 403 Forbidden

# 4. Verify SSL is working
curl -I https://your-domain.com/aha training/public/
# Should return 200 OK with HTTPS
```

---

## 🛠️ Common Issues & Quick Fixes

### Issue: "Database error"
```bash
chmod 666 /var/www/aha\ training/private/aha_training.db
```

### Issue: "Permission denied"
```bash
chown -R www-data:www-data /var/www/aha\ training/
```

### Issue: ".htaccess not working"
```bash
# Enable mod_rewrite
a2enmod rewrite
# Edit Apache config: AllowOverride All
systemctl restart apache2
```

### Issue: "Email not sending"
```bash
apt install postfix
systemctl restart postfix
```

---

## 📊 View Data

### View all NDA records
```bash
sqlite3 /var/www/aha\ training/private/aha_training.db "SELECT name, email, signed_at FROM nda_records ORDER BY signed_at DESC;"
```

### View all contact messages
```bash
sqlite3 /var/www/aha\ training/private/aha_training.db "SELECT name, email, created_at FROM contact_messages ORDER BY created_at DESC;"
```

### Count records
```bash
sqlite3 /var/www/aha\ training/private/aha_training.db "SELECT COUNT(*) FROM nda_records;"
```

---

## 🔄 Update/Redeploy

To update the website:

```bash
# 1. Backup database
cp /var/www/aha\ training/private/aha_training.db ~/backup_$(date +%Y%m%d).db

# 2. Upload new files (skip private/ directory to preserve data)
scp -r "aha training/public" "aha training/app" "aha training/assets" root@198.211.114.12:/var/www/aha\ training/

# 3. Reload web server
systemctl reload nginx
# or
systemctl reload apache2
```

---

## 📞 Need Help?

**Documentation:**
- Full guide: `README.md`
- This file: `QUICKSTART.md`

**Logs:**
```bash
# Application logs
tail -f /var/www/aha\ training/private/security.log

# PHP errors
tail -f /var/log/apache2/error.log

# Nginx errors
tail -f /var/log/nginx/error.log
```

**Contact:**
- Email: t3h28@gmail.com
- Server: root@198.211.114.12

---

## ✅ Done!

Your NDA-gated AHA training website is now live! 🎉

**Next steps:**
1. Customize content in `/public/*.php` files
2. Update email address in `app/email-notifier.php`
3. Set up automated backups (see README.md)
4. Test thoroughly before announcing

---

**Last Updated:** November 3, 2025
