# Demo Experience UI

Customer-facing video interface for BuzzTrail's automated demo system with Tavus AI avatar and Slidev presentations.

## 🎯 Overview

React app using Tavus CVI (Conversational Video Interface) components extended for multi-participant Daily.co rooms:
- **Customer** (local participant)
- **Tavus Avatar** (AI presenter via Pipecat)
- **Slidev Presentation** (screenshare)

## 🚀 Quick Start

### Local Development

```bash
# Install dependencies (from monorepo root)
pnpm install

# Start dev server
pnpm nx dev demo-experience-ui

# Open browser
open http://localhost:4500
```

### Environment Variables

Copy `.env.example` to `.env.local` and configure:

```bash
VITE_SUPABASE_URL=https://dwdytxxqcvlrmyemonxz.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key_here
VITE_DAILY_DOMAIN=buzztrail.daily.co
VITE_MOTIA_API_URL=https://slide-system-production-5813.up.railway.app
```

## 📦 Architecture

### Tech Stack
- **Framework**: React 19 + Vite
- **Video**: Daily.co (@daily-co/daily-react)
- **UI Components**: Tavus CVI (@tavus/cvi-ui)
- **State**: Jotai
- **Styling**: CSS Modules

### Component Structure

```
src/
├── components/
│   ├── cvi/                    # Generated Tavus CVI components
│   │   ├── components/
│   │   │   ├── hair-check/     # ✅ Pre-demo device testing
│   │   │   ├── device-select/  # ✅ Mic/camera controls
│   │   │   └── cvi-provider/   # ✅ Daily.co provider
│   │   └── hooks/
│   │       ├── use-local-camera.tsx
│   │       ├── use-local-microphone.tsx
│   │       └── use-start-haircheck.tsx
│   └── extended/               # 🆕 Multi-participant extensions (to be built)
│       ├── ExtendedConversationBlock.tsx
│       ├── useParticipants.tsx
│       └── useViewMode.tsx
└── App.tsx                     # Main app (HairCheck ↔ Conversation routing)
```

## 🎨 Features

### Current (MVP)
- [x] Tavus CVI base components generated
- [ ] HairCheck (pre-demo device testing)
- [ ] Multi-participant detection (customer, avatar, slideshow)
- [ ] Automatic view switching (Discovery ↔ Presentation)
- [ ] Media controls (mic, camera)

### View Modes
- **Discovery Mode**: Tavus avatar large, customer PiP
- **Presentation Mode**: Slidev screenshare large, avatar + customer PiPs

## 🚢 Deployment

### Live URLs

- **Production**: https://demo-experience-ui-buzztrail.vercel.app
- **Preview**: https://demo-experience-boengh1nc-buzztrail.vercel.app
- **Staging** (planned): demo-staging.buzztrail.ai
- **Production** (planned): demo.buzztrail.ai (after migration from legacy demos)

### Vercel Deployment

**✅ Deployed and Live**

```bash
# Deploy to preview (staging)
cd /Users/lars/mycode/buzztrail/extension
vercel --yes

# Deploy to production
vercel --prod --yes
```

Environment variables are configured in Vercel for all environments (production, preview, development):
- ✅ `VITE_SUPABASE_URL`
- ✅ `VITE_SUPABASE_ANON_KEY`
- ✅ `VITE_DAILY_DOMAIN`
- ✅ `VITE_MOTIA_API_URL`

**See**: `DEPLOYMENT.md` for detailed deployment guide

### Build Commands

```bash
# Build for production
pnpm nx vite:build demo-experience-ui

# Preview production build
pnpm nx vite:preview demo-experience-ui

# Type checking
pnpm nx typecheck demo-experience-ui
```

## 📝 Development Notes

### Adding More Tavus CVI Components

From monorepo root:
```bash
pnpx @tavus/cvi-ui add conversation-01
pnpx @tavus/cvi-ui add audio-wave

# Move generated components to app
mv src/components/cvi/* apps/demo-experience-ui/src/components/cvi/
```

### Testing with Railway API
```bash
# Create demo session
curl -X POST https://slide-system-production-5813.up.railway.app/demo-sessions \
  -H "Content-Type: application/json" \
  -d '{"session_type":"test","environment":"dev"}'

# Returns:
# {
#   "session_id": "...",
#   "daily_room_url": "https://buzztrail.daily.co/demo-...",
#   "status": "waiting_for_customer"
# }
```

## 🔗 Related

- **PRD**: `.claude/prds/core-presentation-engine/demo-experience-ui.md`
- **Epic**: `.claude/epics/demo-experience-ui/epic.md`
- **Railway API**: `apps/slide-system/`
- **Legacy Demos**: `apps/demos/` (to be replaced)

## 🎯 Next Steps

1. [ ] Implement `useParticipants` hook
2. [ ] Build `ExtendedConversationBlock` component
3. [ ] Add automatic view mode detection
4. [ ] Integration testing with Railway API
5. [ ] Deploy to Vercel staging
