═══════════════════════════════════════════════════════════════════════════════
SPROWTT DEMO SYSTEM - LARAVEL PHP + MYSQL
Quick Start Guide - InMotion VPS Deployment
═══════════════════════════════════════════════════════════════════════════════

Package: sprowtt-demo-laravel.zip
Version: 1.0
Built: March 2026
Technology: Laravel 10, PHP 8.1+, MySQL 8.0+

═══════════════════════════════════════════════════════════════════════════════
WHAT'S IN THIS PACKAGE
═══════════════════════════════════════════════════════════════════════════════

This is a COMPLETE, production-ready Laravel PHP application that includes:

✅ AI-Powered Demo Request System
   - Three demo tracks (Issuer, B2B, Contact Us)
   - Intelligent lead qualification with scoring (0-100)
   - Claude API integration for AI summaries
   - Automated routing (Calendly, Resources, AI Chat)

✅ MySQL Database System
   - Complete database migrations
   - demo_requests table with full schema
   - Eloquent ORM models
   - Indexing for performance

✅ Professional UI
   - Responsive design (desktop, tablet, mobile)
   - Landing page matching Sprowtt branding
   - Interactive funnel with JavaScript
   - Results page with AI analysis

✅ Production Ready
   - Security best practices
   - CSRF protection
   - SQL injection prevention
   - Environment-based configuration
   - Error handling and logging

✅ Complete Documentation
   - DEPLOYMENT_GUIDE.md (50+ pages, step-by-step)
   - README.md (quick reference)
   - Code comments throughout
   - Installation script included

═══════════════════════════════════════════════════════════════════════════════
FILE STRUCTURE
═══════════════════════════════════════════════════════════════════════════════

sprowtt-demo-laravel/
├── app/
│   ├── Http/Controllers/
│   │   └── DemoController.php          ← Main logic (questions, scoring, AI)
│   └── Models/
│       └── DemoRequest.php             ← Database model
│
├── database/migrations/
│   └── 2024_01_01_000001_create_demo_requests_table.php
│
├── resources/views/demo/
│   ├── landing.blade.php               ← Landing page (3 demo cards)
│   └── funnel.blade.php                ← Interactive funnel (wizard)
│
├── routes/
│   └── web.php                         ← URL routing configuration
│
├── public/
│   ├── index.php                       ← Laravel entry point
│   └── .htaccess                       ← Apache URL rewriting
│
├── .env.example                        ← Configuration template
├── composer.json                       ← PHP dependencies
├── artisan                             ← Laravel CLI tool
├── install.sh                          ← Automated installation script
├── DEPLOYMENT_GUIDE.md                 ← Complete deployment instructions
└── README.md                           ← Quick reference

═══════════════════════════════════════════════════════════════════════════════
REQUIREMENTS
═══════════════════════════════════════════════════════════════════════════════

SERVER:
✓ InMotion VPS (or similar Linux VPS)
✓ Ubuntu 20.04/22.04 or CentOS 7/8
✓ Root or sudo access

SOFTWARE:
✓ PHP 8.1 or higher
✓ MySQL 8.0 or MariaDB 10.3+
✓ Composer (PHP package manager)
✓ Apache 2.4+ or Nginx 1.18+

API KEYS:
✓ Anthropic Claude API key (https://console.anthropic.com)
✓ Calendly scheduling URL (https://calendly.com)

OPTIONAL:
✓ SSL certificate (Let's Encrypt - free)
✓ SMTP credentials (for email notifications)
✓ Git (for version control)

═══════════════════════════════════════════════════════════════════════════════
QUICK DEPLOYMENT (30 MINUTES)
═══════════════════════════════════════════════════════════════════════════════

1. UPLOAD & EXTRACT (5 minutes)
   ```bash
   cd /var/www
   unzip sprowtt-demo-laravel.zip
   mv sprowtt-demo-laravel demo.sprowtt.com
   cd demo.sprowtt.com
   ```

2. INSTALL DEPENDENCIES (5 minutes)
   ```bash
   ./install.sh
   # This installs PHP packages and sets up directories
   ```

3. CONFIGURE DATABASE (5 minutes)
   ```bash
   # Create MySQL database
   mysql -u root -p
   CREATE DATABASE sprowtt_demo;
   CREATE USER 'sprowtt_user'@'localhost' IDENTIFIED BY 'PASSWORD';
   GRANT ALL PRIVILEGES ON sprowtt_demo.* TO 'sprowtt_user'@'localhost';
   EXIT;
   
   # Edit .env file
   nano .env
   # Update DB_DATABASE, DB_USERNAME, DB_PASSWORD
   # Add ANTHROPIC_API_KEY and CALENDLY_URL
   
   # Run migrations
   php artisan migrate
   ```

4. CONFIGURE WEB SERVER (10 minutes)
   ```bash
   # Create Apache virtual host
   sudo nano /etc/apache2/sites-available/demo.sprowtt.com.conf
   
   # Add configuration (see DEPLOYMENT_GUIDE.md)
   # Enable site
   sudo a2ensite demo.sprowtt.com.conf
   sudo a2enmod rewrite
   sudo systemctl restart apache2
   ```

5. ADD SSL CERTIFICATE (5 minutes)
   ```bash
   sudo certbot --apache -d demo.sprowtt.com
   ```

6. TEST! (Go to https://demo.sprowtt.com)

═══════════════════════════════════════════════════════════════════════════════
DETAILED DEPLOYMENT
═══════════════════════════════════════════════════════════════════════════════

For complete step-by-step instructions with screenshots and troubleshooting:

📖 READ: DEPLOYMENT_GUIDE.md

This guide includes:
✓ Complete server preparation
✓ Database setup with SQL commands
✓ File upload methods (SCP, FTP, cPanel)
✓ Apache AND Nginx configuration
✓ SSL certificate installation
✓ Performance optimization
✓ Security checklist
✓ Troubleshooting section
✓ Multi-domain deployment
✓ Backup and maintenance procedures

═══════════════════════════════════════════════════════════════════════════════
CONFIGURATION
═══════════════════════════════════════════════════════════════════════════════

ENVIRONMENT FILE (.env):

Critical settings you MUST configure:

```
APP_NAME="Sprowtt Demo System"
APP_ENV=production               ← Set to production
APP_DEBUG=false                  ← MUST be false for security
APP_URL=https://demo.sprowtt.com ← Your actual domain

DB_DATABASE=sprowtt_demo         ← Your database name
DB_USERNAME=sprowtt_user         ← Your database user
DB_PASSWORD=STRONG_PASSWORD      ← Your database password

ANTHROPIC_API_KEY=sk-ant-xxx     ← Get from console.anthropic.com
CALENDLY_URL=https://calendly.com/your-link ← Your Calendly URL
```

OPTIONAL SETTINGS:

```
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
```

═══════════════════════════════════════════════════════════════════════════════
HOW IT WORKS
═══════════════════════════════════════════════════════════════════════════════

USER FLOW:

1. User visits https://demo.sprowtt.com
   → Sees landing page with 3 demo options

2. User clicks "Get Started" on a track (Issuer, B2B, or Contact)
   → Goes to /demo?track=issuer (or b2b/contact)

3. Funnel presents 4 qualification questions
   → User answers each question
   → System tracks answers with scores

4. User provides contact details (name, email, phone, company)
   → Form validation ensures data quality

5. System submits to /api/demo/submit
   → Calculates total score (0-100)
   → Determines category (high/mid/low)
   → Generates AI summary using Claude API
   → Saves to database

6. User sees results page with:
   → Score visualization
   → AI-generated personalized summary
   → Next step button (Calendly, Resources, or AI Chat)
   → Routing based on score

BACKEND PROCESS:

1. DemoController receives request
2. Validates all input data
3. Calculates score from answers
4. Makes API call to Anthropic Claude
5. Stores demo request in MySQL
6. Returns results to frontend
7. Frontend displays results with routing options

═══════════════════════════════════════════════════════════════════════════════
DATABASE SCHEMA
═══════════════════════════════════════════════════════════════════════════════

The demo_requests table includes:

CORE FIELDS:
- id (primary key)
- track_type (issuer, b2b, contact)
- first_name, last_name
- email, phone, company
- description (user's brief description)
- answers (JSON - stores all qualification answers)

SCORING:
- score (0-100)
- score_category (high/mid/low)
- ai_summary (Claude API generated text)
- routing_destination (calendly/resources/ai_chat)

TRACKING:
- demo_scheduled (boolean)
- demo_scheduled_at (timestamp)
- ip_address, user_agent, referrer
- utm_source, utm_medium, utm_campaign

MANAGEMENT:
- status (new/contacted/qualified/converted/closed)
- notes (admin notes)
- created_at, updated_at (timestamps)

INDEXES FOR PERFORMANCE:
- email, track_type, score_category, status, created_at

═══════════════════════════════════════════════════════════════════════════════
CUSTOMIZATION
═══════════════════════════════════════════════════════════════════════════════

TO CUSTOMIZE QUESTIONS:

Edit: app/Http/Controllers/DemoController.php

Find the $questions array (around line 20) and modify:
- Question text
- Answer options
- Score values
- Number of questions

TO CUSTOMIZE SCORING THRESHOLDS:

Edit: app/Http/Controllers/DemoController.php

Find getScoreCategory() function:
```php
if ($score >= 70) return 'high';     // Change 70 to your threshold
elseif ($score >= 40) return 'mid';  // Change 40 to your threshold
else return 'low';
```

TO CUSTOMIZE VIEWS:

Edit: resources/views/demo/*.blade.php
- landing.blade.php → Landing page design
- funnel.blade.php → Funnel wizard interface

TO CHANGE CALENDLY URL:

Option 1: .env file
```
CALENDLY_URL=https://calendly.com/your-new-link
```

Option 2: In controller (DemoController.php)
```php
'calendly_url' => env('CALENDLY_URL', 'https://calendly.com/default-link')
```

═══════════════════════════════════════════════════════════════════════════════
TESTING
═══════════════════════════════════════════════════════════════════════════════

LOCAL TESTING (before deploying):

1. Install XAMPP or MAMP (includes PHP + MySQL)
2. Extract ZIP to htdocs/
3. Create database and configure .env
4. Run: composer install
5. Run: php artisan migrate
6. Run: php artisan serve
7. Visit: http://localhost:8000

PRODUCTION TESTING (after deploying):

□ Test all 3 demo tracks
□ Submit test requests with different scores
□ Verify database entries created
□ Check AI summaries generate correctly
□ Test Calendly link opens
□ Test on mobile devices
□ Verify SSL (HTTPS) works
□ Check error logs for issues

═══════════════════════════════════════════════════════════════════════════════
MAINTENANCE
═══════════════════════════════════════════════════════════════════════════════

VIEW DEMO REQUESTS:

```bash
# Via database
mysql -u sprowtt_user -p sprowtt_demo
SELECT * FROM demo_requests ORDER BY created_at DESC LIMIT 20;

# Via artisan (create command)
php artisan tinker
>>> App\Models\DemoRequest::latest()->limit(10)->get();
```

CLEAR CACHE (after config changes):

```bash
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
```

BACKUP DATABASE:

```bash
mysqldump -u sprowtt_user -p sprowtt_demo > backup_$(date +%Y%m%d).sql
```

VIEW LOGS:

```bash
tail -f storage/logs/laravel.log
tail -f /var/log/apache2/error.log
```

═══════════════════════════════════════════════════════════════════════════════
DEPLOY TO MULTIPLE DOMAINS
═══════════════════════════════════════════════════════════════════════════════

To deploy the same app to:
- demo.sprowtt.com
- demo.sprowttcf.com
- demo.statecf.com

Use symlinks (recommended):

```bash
ln -s /var/www/demo.sprowtt.com /var/www/demo.sprowttcf.com
ln -s /var/www/demo.sprowtt.com /var/www/demo.statecf.com
```

Create virtual hosts for each domain pointing to the symlink.
Get SSL certificates for each domain.

See DEPLOYMENT_GUIDE.md Step 9 for complete instructions.

═══════════════════════════════════════════════════════════════════════════════
TROUBLESHOOTING
═══════════════════════════════════════════════════════════════════════════════

ISSUE: 500 Internal Server Error
→ Check storage permissions: chmod -R 775 storage
→ Check .env file exists and is configured
→ Check logs: storage/logs/laravel.log

ISSUE: Database connection failed
→ Verify .env database credentials
→ Test MySQL connection: mysql -u sprowtt_user -p
→ Ensure MySQL is running

ISSUE: Composer install fails
→ Ensure PHP 8.1+ is installed: php -v
→ Ensure Composer is installed: composer --version
→ Run with --verbose flag to see errors

ISSUE: AI summary not working
→ Verify ANTHROPIC_API_KEY in .env
→ Check API key is valid at console.anthropic.com
→ Check internet connectivity from server

For more troubleshooting, see DEPLOYMENT_GUIDE.md

═══════════════════════════════════════════════════════════════════════════════
SUPPORT
═══════════════════════════════════════════════════════════════════════════════

DOCUMENTATION:
- DEPLOYMENT_GUIDE.md (comprehensive guide)
- README.md (quick reference)
- Code comments throughout application

EXTERNAL RESOURCES:
- Laravel Documentation: https://laravel.com/docs
- InMotion Support: https://www.inmotionhosting.com/support
- Anthropic API Docs: https://docs.anthropic.com

═══════════════════════════════════════════════════════════════════════════════
SUMMARY
═══════════════════════════════════════════════════════════════════════════════

YOU HAVE:
✅ Complete Laravel PHP application (production-ready)
✅ MySQL database with migrations
✅ AI-powered lead qualification (Claude API)
✅ Three demo tracks with intelligent routing
✅ Professional responsive UI
✅ Complete deployment documentation
✅ Security best practices built-in

DEPLOYMENT TIME:
- Quick deployment: 30 minutes (experienced user)
- Full deployment: 1-2 hours (first time)
- Testing and verification: 30 minutes

NEXT STEPS:
1. Read DEPLOYMENT_GUIDE.md
2. Prepare your server (PHP 8.1+, MySQL, Composer)
3. Upload and extract ZIP
4. Run install.sh
5. Configure .env
6. Run migrations
7. Configure web server
8. Add SSL
9. Test!

READY TO DEPLOY!

═══════════════════════════════════════════════════════════════════════════════
