# BuzzTrail Demo Applications

**Customer demo platform** - Interactive demo applications showcasing BuzzTrail AI video integration with multiple deployment targets including Wix custom code.

## 🎯 Overview

The BuzzTrail demos app provides **customer-ready demonstrations** of AI video integration built with **Vite** and optimized for multiple deployment platforms. It features specialized Wix integration with character limit optimization and environment-based builds.

### Key Features

- ✅ **Multi-Platform Deployment** - Regular web demos and Wix custom code
- ✅ **Character Limit Optimization** - Wix builds under 15,000 character limit
- ✅ **Environment-Based Builds** - Separate local/production configurations
- ✅ **Customer Branding** - BuzzTrail and Sendcloud themed demos
- ✅ **Real-Time Development** - Live reload and instant preview
- ✅ **NX Integration** - Full monorepo build system integration
- ✅ **Production Ready** - Optimized for customer deployment

## 🚀 Quick Start

### Prerequisites

- Node.js 18+
- pnpm package manager

### Development Setup

1. **Install Dependencies**:
   ```bash
   # From project root
   pnpm install
   ```

2. **Start Development Servers**:
   ```bash
   # BuzzTrail demo
   pnpm run serve:demos:buzztrail

   # Sendcloud demo
   pnpm run serve:demos:sendcloud

   # General development server
   pnpm run dev:demos
   ```

3. **Open in Browser**:
   ```bash
   # Automatically open BuzzTrail demo
   pnpm run open:demos:buzztrail

   # Automatically open Sendcloud demo
   pnpm run open:demos:sendcloud
   ```

### Wix Integration Development

1. **Full Wix Development Workflow**:
   ```bash
   # Complete Wix workflow: builds both + opens test
   pnpm run dev demos
   ```

2. **Production Wix Build**:
   ```bash
   # Build optimized for Wix deployment
   pnpm run build:wix

   # Quick alias
   pnpm wix
   ```

3. **Local Wix Build**:
   ```bash
   # Build with local development settings
   pnpm nx build:wix:local demos
   ```

## 🏗️ Architecture

### Build System

- **Framework**: Vite with TypeScript
- **Package Manager**: pnpm
- **Workspace**: Nx monorepo integration
- **Output**: Multiple deployment formats

### Project Structure

```
apps/demos/
├── buzztrail-video-demo/          # Main demo application
│   ├── .env.local                 # Local development config
│   ├── .env.production           # Production config
│   ├── src/
│   │   ├── wix-combined.js        # Wix-optimized entry point
│   │   ├── shared-demo.js         # Shared utilities
│   │   └── [demo-files]
│   ├── wix-custom-code-production.html   # Production output (14,993 chars)
│   └── wix-custom-code-local.html        # Local development output
├── project.json                   # NX build configuration
├── vite.config.ts                 # Standard web build
└── vite.wix.config.ts             # Wix-specific build
```

### Key Technologies

- **React 19** - UI framework with modern features
- **TypeScript** - Type safety and development experience
- **Vite** - Fast build tool with HMR
- **Custom Minification** - Wix character limit optimization
- **Environment Variables** - Configuration management

### Wix Integration System

The demos app includes a sophisticated **Wix integration system** that:

- **Character Optimization**: Builds within Wix's 15,000 character limit
- **Environment Handling**: Separate local/production configurations
- **Minification**: Custom JavaScript and CSS minification
- **Error Handling**: Simplified logging-only approach for debugging
- **Dual Output**: Both development and production versions

## 📋 Available Commands

### Development Commands

```bash
# Start development servers
pnpm run dev:demos               # General development
pnpm run serve:demos:buzztrail   # BuzzTrail-specific demo
pnpm run serve:demos:sendcloud   # Sendcloud-specific demo

# Open demos in browser
pnpm run open:demos:buzztrail    # Auto-open BuzzTrail demo
pnpm run open:demos:sendcloud    # Auto-open Sendcloud demo

# Full Wix development workflow
pnpm run dev demos               # Complete workflow with test
```

### Build Commands

```bash
# Standard web builds
pnpm run build:demos             # Regular web demo build

# Wix-optimized builds
pnpm run build:wix               # Production Wix build
pnpm wix                         # Quick alias for build:wix
pnpm nx build:wix:local demos    # Local development Wix build
```

### Quality Commands

```bash
# Code quality
pnpm run lint:demos              # ESLint checking
pnpm run type-check              # TypeScript validation

# Testing
pnpm run test:demos              # Unit tests
```

## 🎨 Demo Configurations

### BuzzTrail Demo

**Features**:
- BuzzTrail branding and styling
- AI video conversation interface
- Real-time chat capabilities
- Mobile-responsive design

**Configuration**:
```typescript
const buzztrailConfig = {
  theme: 'buzztrail',
  primaryColor: '#6366F1',
  logo: 'buzztrail-logo.svg',
  apiEndpoint: 'https://buzztrail-proxy.vercel.app'
};
```

### Sendcloud Demo

**Features**:
- Sendcloud branding and colors
- E-commerce integration patterns
- Customer service scenarios
- Multi-language support

**Configuration**:
```typescript
const sendcloudConfig = {
  theme: 'sendcloud',
  primaryColor: '#00A3E0',
  logo: 'sendcloud-logo.svg',
  apiEndpoint: 'https://sendcloud-proxy.vercel.app'
};
```

## 🔧 Wix Integration

### Wix Custom Code Optimization

The Wix integration system includes sophisticated optimization:

**Character Limit Management**:
- **Limit**: 15,000 characters maximum
- **Current Usage**: 14,993/15,000 (99.95% efficiency)
- **Optimization**: Automated minification and compression

**Build Process**:
1. **Environment Selection**: Choose local or production config
2. **Code Combination**: Merge all source files
3. **Minification**: JavaScript and CSS optimization
4. **Template Processing**: Inline styles and remove comments
5. **Validation**: Character count verification
6. **Output Generation**: HTML file ready for Wix

### Environment Configuration

#### Production Environment (`.env.production`)
```bash
# Optimized for customer deployment
VITE_API_ENDPOINT=https://production-api.vercel.app
VITE_ENABLE_LOGGING=false
VITE_DEBUG_MODE=false
VITE_MINIFY_OUTPUT=true
```

#### Local Environment (`.env.local`)
```bash
# Development-friendly settings
VITE_API_ENDPOINT=http://localhost:3001
VITE_ENABLE_LOGGING=true
VITE_DEBUG_MODE=true
VITE_MINIFY_OUTPUT=false
```

### Wix Deployment Process

1. **Build Production Code**:
   ```bash
   pnpm run build:wix
   ```

2. **Copy Generated Code**:
   ```bash
   # Copy contents of wix-custom-code-production.html
   cat apps/demos/buzztrail-video-demo/wix-custom-code-production.html
   ```

3. **Add to Wix Site**:
   - Go to Wix Editor
   - Add Custom Code element
   - Paste generated HTML
   - Save and publish

## 🚀 Deployment

### Standard Web Deployment

```bash
# Build for standard deployment
pnpm run build:demos

# Deploy to Vercel
vercel deploy dist/apps/demos/

# Deploy to Netlify
netlify deploy --prod --dir=dist/apps/demos/
```

### Wix Deployment

```bash
# Build optimized for Wix
pnpm run build:wix

# Output file ready for Wix custom code
# File: apps/demos/buzztrail-video-demo/wix-custom-code-production.html
```

### CDN Deployment

```bash
# Build and upload to CDN
pnpm run build:demos
aws s3 sync dist/apps/demos/ s3://your-demo-bucket/
```

## 📊 Performance

### Build Characteristics

**Standard Web Build**:
- **Bundle Size**: ~200KB minified
- **Load Time**: <1s on 3G
- **Interactive**: <300ms

**Wix Optimized Build**:
- **Character Count**: 14,993/15,000 (99.95% efficiency)
- **Inline Assets**: All CSS and JS inlined
- **Load Time**: <500ms (no external requests)

### Optimization Features

- **Tree Shaking**: Removes unused code
- **Asset Inlining**: Base64 embedded assets for Wix
- **CSS Minification**: Optimized styling
- **JavaScript Compression**: Minified and optimized
- **Template Optimization**: Removed whitespace and comments

## 🧪 Testing

### Manual Testing

1. **Development Testing**: Test on development server
2. **Build Testing**: Test built versions locally
3. **Wix Testing**: Test in Wix preview environment
4. **Cross-Browser**: Chrome, Firefox, Safari testing
5. **Mobile Testing**: Responsive design verification

### Automated Testing

```bash
# Unit tests
pnpm nx test demos

# Integration tests
pnpm nx e2e demos

# Build validation
pnpm run test:builds
```

### Character Limit Testing

```bash
# Verify Wix character limits
pnpm run build:wix
# Check output for character count validation
```

## 🔍 Troubleshooting

### Common Issues

**Wix Character Limit Exceeded**:
- Review minification settings
- Remove unnecessary comments
- Optimize inline assets
- Check for repeated code

**Demo Not Loading**:
- Check browser console for errors
- Verify API endpoint configuration
- Test with simplified configuration

**Styling Issues**:
- Check CSS conflicts with host site
- Verify theme configuration
- Test with default theme

**Build Failures**:
- Clear build cache: `rm -rf dist/`
- Check TypeScript errors
- Verify environment variables

### Debug Commands

```bash
# Development with full logging
VITE_DEBUG_MODE=true pnpm run dev:demos

# Build with verbose output
pnpm run build:demos --verbose

# Wix build with debugging
DEBUG_WIX_BUILD=true pnpm run build:wix
```

## 📚 Related Documentation

### Core Documentation
- [Build System Guide](../../documentation/documentation/build-system-guide.md) - Build system architecture
- [Package Scripts Reference](../../docs/package-scripts-reference.md) - All available commands
- [Development Guide](../../documentation/documentation/development-guide.md) - General development setup

### Demo-Specific
- [Demos Development Guide](../../documentation/documentation/demos-development-guide.md) - Complete development workflow
- [Wix Integration Guide](../../documentation/documentation/wix-integration-guide.md) - Technical Wix setup
- [Wix Environment Build System](../../documentation/documentation/wix-environment-build-system.md) - Environment configuration

### Integration
- [Tavus Integration Guide](../../documentation/documentation/tavus-integration-guide.md) - AI video API integration
- [UI/UX Guide](../../documentation/documentation/ui-ux-guide.md) - Component architecture

### Planning
- See `.claude/prds/` for all product requirements and future planning
- Planning documents migrated from `documentation/planning/` (now archived in `.claude/migration/planning-archive/`)

---

**Build System**: Vite + Custom Wix Optimization
**Package Manager**: pnpm
**Wix Character Limit**: 14,993/15,000 (99.95% efficiency)
**Deployment**: Web + Wix Custom Code
**Last Updated**: September 26, 2025