# AHA Training Website - Complete Deployment Guide

**Website URL:** https://adampowell.pro/aha/
**Deployed:** November 3, 2025
**Status:** ✅ LIVE & OPERATIONAL

---

## 📋 Table of Contents

1. [Overview](#overview)
2. [Website Structure](#website-structure)
3. [How It Works](#how-it-works)
4. [Daily Operations](#daily-operations)
5. [Maintenance & Updates](#maintenance--updates)
6. [Troubleshooting](#troubleshooting)
7. [Security Features](#security-features)
8. [Database Management](#database-management)
9. [Future Enhancements](#future-enhancements)

---

## 🎯 Overview

### What Was Built

A **complete NDA-gated website** for AHA (ACLS, BLS, PALS) training exclusively for advanced healthcare providers. The site features:

- ✅ Professional public-facing pages
- 🔐 Mandatory NDA signature system with legal enforceability
- ✏️ Dual signature capture (typed & hand-drawn)
- 📄 Automated PDF generation with corporate letterhead
- 🗄️ SQLite database for all records
- 📧 Email notifications for admin
- 🛡️ Enterprise-level security features
- 🚫 Session-based access control

### Target Audience

- Nurse Anesthesiologists (CRNAs)
- Anesthesiologists
- Physicians
- Advanced Practice Registered Nurses (APRNs)
- Physician Assistants
- Critical Care Specialists

---

## 📂 Website Structure

### Live URLs

| Page | URL | Access |
|------|-----|--------|
| Home | https://adampowell.pro/aha/ | Public |
| About | https://adampowell.pro/aha/about.php | Public |
| Courses | https://adampowell.pro/aha/courses.php | Public |
| Schedule | https://adampowell.pro/aha/schedule.php | Public |
| Privacy | https://adampowell.pro/aha/privacy.php | Public |
| NDA | https://adampowell.pro/aha/nda.php | Public |
| Contact | https://adampowell.pro/aha/contact.php | **NDA Required** |

### Server Directory Structure

```
/var/www/aha-training/               # Main application directory
├── public/                          # Public-facing PHP pages
│   ├── index.php                   # Homepage
│   ├── about.php                   # About page
│   ├── courses.php                 # Course details
│   ├── schedule.php                # Schedule info
│   ├── privacy.php                 # Privacy policy
│   ├── nda.php                     # NDA signature page
│   └── contact.php                 # Contact form (gated)
│
├── app/                            # Backend logic
│   ├── includes/
│   │   ├── header.php             # Shared header
│   │   └── footer.php             # Shared footer
│   ├── database.php               # SQLite handler
│   ├── pdf-generator.php          # PDF creation
│   ├── security.php               # Security utilities
│   ├── email-notifier.php         # Email system
│   ├── process-nda.php            # NDA processor
│   └── process-contact.php        # Contact processor
│
├── assets/                         # Frontend assets
│   ├── css/style.css              # Main stylesheet
│   └── js/signature.js            # Signature capture
│
├── private/                        # Restricted (web-blocked)
│   ├── nda_records/               # PDF storage
│   ├── aha_training.db            # SQLite database
│   └── security.log               # Security events
│
└── Docs (README, QUICKSTART, etc.)

/var/www/adampowell.pro/html/aha/   # Web-accessible (copied files)
├── *.php files                     # Copied from public/
├── assets/                         # Copied from assets/
└── app/                            # Copied from app/
```

---

## ⚙️ How It Works

### User Flow

```
1. User visits homepage
   └─> Views public information (courses, schedule, about)

2. User clicks "Contact (NDA Required)"
   └─> Redirected to NDA page

3. User reads NDA agreement
   └─> Signs electronically (typed OR drawn signature)
   └─> Submits form

4. System processes NDA
   ├─> Validates signature
   ├─> Checks rate limits
   ├─> Captures IP, location, browser fingerprint
   ├─> Generates SHA256 hash
   ├─> Creates PDF document
   ├─> Stores in database
   ├─> Creates session
   └─> Sends email notification to admin

5. User gains access
   └─> Contact form now accessible
   └─> Session persists until browser closes

6. User submits contact message
   ├─> Message stored in database
   └─> Email notification sent to admin
```

### NDA System Details

**Legal Strength:**
- Governed by Florida law
- Perpetual confidentiality obligations
- Includes non-compete, non-use, non-circumvent clauses
- Legally binding electronic signature (E-SIGN Act compliant)

**Data Captured:**
- Full name and email
- Signature (typed or drawn image)
- IP address + geolocation (city, state, country)
- Browser fingerprint hash
- Timestamp with timezone
- SHA256 tamper-proof hash

**PDF Output:**
- Corporate black letterhead design
- All signer information
- Digital signature display
- Watermark: "CONFIDENTIAL - DO NOT DISTRIBUTE"
- Stored in `/var/www/aha-training/private/nda_records/`
- Filename format: `NDA_JohnSmith_20251103_154532_a4f3b2c1.pdf`

### Security Features

| Feature | Implementation |
|---------|---------------|
| CSRF Protection | Tokens on all forms |
| Rate Limiting | 3 NDA/hour, 5 messages/hour per IP |
| Session Control | Contact only accessible after NDA |
| IP Tracking | With geolocation via ip-api.com |
| Browser Fingerprinting | Device/browser hash for validation |
| Private Directory | Blocked via .htaccess (403) |
| Input Sanitization | SQL injection prevention |
| File Access Protection | PDFs not web-accessible |

---

## 📊 Daily Operations

### Checking New NDA Signatures

**Via Database:**
```bash
# SSH into server
ssh root@198.211.114.12

# View all NDA records
sqlite3 /var/www/aha-training/private/aha_training.db "SELECT name, email, signed_at, location FROM nda_records ORDER BY signed_at DESC LIMIT 10;"

# Count total NDAs signed
sqlite3 /var/www/aha-training/private/aha_training.db "SELECT COUNT(*) FROM nda_records;"
```

**Via Email:**
You receive automatic email notifications at `t3h28@gmail.com` every time someone signs the NDA.

### Checking Contact Messages

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

# View unread messages
sqlite3 /var/www/aha-training/private/aha_training.db "SELECT * FROM contact_messages WHERE read_status = 0;"
```

**Via Email:**
You receive email notifications for each contact form submission.

### Accessing PDF Records

```bash
# List all NDA PDFs
ls -lah /var/www/aha-training/private/nda_records/

# Download specific PDF to your computer
scp root@198.211.114.12:/var/www/aha-training/private/nda_records/NDA_*.pdf ~/Downloads/
```

---

## 🔧 Maintenance & Updates

### Updating Content

**To update text on any page:**

```bash
# SSH into server
ssh root@198.211.114.12

# Edit any public page
nano /var/www/adampowell.pro/html/aha/index.php
nano /var/www/adampowell.pro/html/aha/courses.php
# etc.

# Changes are immediate - no need to restart anything
```

**To update styles:**

```bash
nano /var/www/adampowell.pro/html/aha/assets/css/style.css

# Clear browser cache after changes (Ctrl+F5)
```

### Updating from Source

If you make changes on your local Windows machine and want to deploy:

```powershell
# From Windows PowerShell
cd "c:\ADAMANT\ADAMPOWELL PRO\adampowell.pro\aha-training"

# Upload changed files
scp -r public/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/
scp -r assets/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/assets/
scp -r app/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/app/
```

### Database Backup

```bash
# Create backup
cp /var/www/aha-training/private/aha_training.db ~/backups/aha_training_$(date +%Y%m%d).db

# Or download to Windows
scp root@198.211.114.12:/var/www/aha-training/private/aha_training.db "c:\ADAMANT\Backups\aha_training_backup.db"

# Automated daily backup (add to crontab)
0 2 * * * cp /var/www/aha-training/private/aha_training.db ~/backups/aha_training_$(date +\%Y\%m\%d).db
```

### Log Monitoring

```bash
# View security events
tail -f /var/www/aha-training/private/security.log

# View nginx access logs
tail -f /var/log/nginx/access.log | grep "/aha/"

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

---

## 🛠️ Troubleshooting

### Issue: CSS/Styling Not Loading

**Fix:**
```bash
# Check file permissions
ls -la /var/www/adampowell.pro/html/aha/assets/css/

# Fix permissions if needed
chmod 755 /var/www/adampowell.pro/html/aha/assets
chmod 644 /var/www/adampowell.pro/html/aha/assets/css/style.css

# Clear Cloudflare cache
# Go to Cloudflare dashboard > Caching > Purge Everything

# Hard refresh browser (Ctrl+F5)
```

### Issue: NDA Submission Fails

**Check:**
```bash
# 1. Database permissions
ls -la /var/www/aha-training/private/aha_training.db
chmod 666 /var/www/aha-training/private/aha_training.db

# 2. Check PHP errors
tail -f /var/log/nginx/error.log

# 3. Test database connection
sqlite3 /var/www/aha-training/private/aha_training.db "SELECT 1;"

# 4. Check rate limits
sqlite3 /var/www/aha-training/private/aha_training.db "SELECT * FROM rate_limits;"
```

### Issue: Email Notifications Not Sending

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

# Check postfix status
systemctl status postfix

# Restart postfix if needed
systemctl restart postfix

# Verify email address in code
grep "adminEmail" /var/www/aha-training/app/email-notifier.php
```

### Issue: Contact Form Not Accessible After NDA

**Fix:**
```bash
# Check session configuration
grep "session" /etc/php/7.3/fpm/php.ini

# Verify session directory is writable
ls -la /var/lib/php/sessions/

# Test session in browser
# Open browser console > Application > Cookies
# Look for PHPSESSID cookie
```

### Issue: PDF Not Generating

**Fix:**
```bash
# Check directory permissions
ls -la /var/www/aha-training/private/nda_records/
chmod 755 /var/www/aha-training/private/nda_records/

# Check PHP error log
tail -20 /var/log/nginx/error.log | grep -i pdf
```

---

## 🗄️ Database Management

### Database Schema

**Tables:**

1. **nda_records** - All NDA signatures
   - id, name, email, signature_type, signature_data
   - ip_address, location, browser_fingerprint
   - user_agent, pdf_path, nda_hash
   - signed_at, created_at

2. **contact_messages** - Contact form submissions
   - id, name, email, message
   - ip_address, nda_hash, read_status
   - created_at

3. **rate_limits** - Rate limiting tracking
   - id, ip_address, action_type
   - attempt_count, last_attempt, blocked_until

### Useful Database Queries

```bash
# Enter database
sqlite3 /var/www/aha-training/private/aha_training.db

# View table structure
.schema nda_records

# Export to CSV
.mode csv
.output nda_records.csv
SELECT * FROM nda_records;
.output stdout

# Search by email
SELECT * FROM nda_records WHERE email LIKE '%@example.com%';

# Count messages per day
SELECT DATE(created_at) as date, COUNT(*) as count
FROM contact_messages
GROUP BY DATE(created_at)
ORDER BY date DESC;

# Exit
.exit
```

### Database Maintenance

```bash
# Vacuum database (optimize)
sqlite3 /var/www/aha-training/private/aha_training.db "VACUUM;"

# Check database integrity
sqlite3 /var/www/aha-training/private/aha_training.db "PRAGMA integrity_check;"

# Clear old rate limits
sqlite3 /var/www/aha-training/private/aha_training.db "DELETE FROM rate_limits WHERE datetime(blocked_until) < datetime('now');"
```

---

## 🚀 Future Enhancements (Phase 2)

### Admin Dashboard
- Web-based interface to view NDA records
- Read/respond to contact messages
- View analytics and statistics
- Export data to CSV/Excel

### Payment Integration
- Stripe/PayPal for course payments
- Online registration system
- Automatic receipt generation

### Course Management
- Student enrollment tracking
- Certificate issuance system
- Course completion records

### Advanced Features
- SMS 2FA for NDA signing
- Automated NDA PDF emailed to signers
- reCAPTCHA v3 integration
- User account system for returning students

---

## 📞 Support & Resources

### Quick Reference

**Website:** https://adampowell.pro/aha/
**Server:** 198.211.114.12
**SSH:** `ssh root@198.211.114.12`
**Database:** `/var/www/aha-training/private/aha_training.db`
**PDFs:** `/var/www/aha-training/private/nda_records/`
**Logs:** `/var/www/aha-training/private/security.log`

### Important Files

- **Nginx Config:** `/etc/nginx/sites-available/adampowell.pro`
- **PHP Config:** `/etc/php/7.3/fpm/php.ini`
- **Web Root:** `/var/www/adampowell.pro/html/aha/`
- **Source:** `/var/www/aha-training/`

### Common Commands

```bash
# Restart web services
systemctl restart nginx php7.3-fpm

# Check nginx config
nginx -t

# View real-time access logs
tail -f /var/log/nginx/access.log | grep "/aha/"

# Count visitors today
grep "$(date +%d/%b/%Y)" /var/log/nginx/access.log | grep "/aha/" | wc -l
```

---

## ✅ Deployment Checklist

- [x] All files uploaded to server
- [x] Permissions set correctly
- [x] Database initialized
- [x] Nginx configured and tested
- [x] SSL working (via existing cert)
- [x] PHP processing NDAs successfully
- [x] Email notifications configured
- [x] Contact form accessible after NDA
- [x] CSS and styling loading correctly
- [x] Private directory blocked from web access
- [x] Database recording signatures
- [x] PDFs being generated
- [x] Session management working
- [x] Rate limiting active
- [x] All navigation links working
- [x] Mobile responsive design
- [x] Cloudflare integration working

---

## 🔄 Sync Between Local & Server

### Deploy Changes from Local to Server

When you update files locally, deploy with:

```powershell
# From: c:\ADAMANT\ADAMPOWELL PRO\adampowell.pro\aha-training

# Upload all changes
scp -r public/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/
scp -r assets/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/assets/
scp -r app/* root@198.211.114.12:/var/www/adampowell.pro/html/aha/app/
```

### Pull Database from Server (for backup)

```powershell
scp root@198.211.114.12:/var/www/aha-training/private/aha_training.db "c:\ADAMANT\Backups\aha_training.db"
```

---

**Status: ✅ FULLY OPERATIONAL**
**Last Updated:** November 3, 2025
**Maintained By:** Adam Powell
**Contact:** t3h28@gmail.com

---

*This website was built with Claude Code and deployed in under 2 hours.*
