# LiveKit Frontend Status Report
**Date**: March 20, 2026

## Current Status

### ✅ Backend Status: RUNNING
- **Python Agent**: Running on multiple processes (PIDs: 1018315, 1026005, 1030030)
- **Backend Port**: 8002 (listening and active)
- **Location**: `/var/www/html/livekit_frontend/BackEnd/agent-starter-python`
- **Status**: Backend is healthy and operational

### ✅ Frontend Status: RUNNING (but not accessible via Apache)
- **Next.js Server**: Running on port 3000 (PID: 2207682)
- **Base Path**: `/voicebot`
- **Direct Access**: Works at `http://localhost:3000/voicebot`
- **Production Build**: Exists in `.next` directory
- **Status**: Frontend is running but Apache is not proxying correctly

### ❌ Apache Configuration: NEEDS FIX
- **Current Issue**: Apache is serving `/var/www/html/livekit_frontend` as a static directory (showing file listing)
- **Expected**: Apache should proxy `/livekit_frontend/` to `http://localhost:3000/voicebot`
- **URL**: `https://app2.syntheon.in/livekit_frontend/` shows directory listing instead of UI

## Problem Summary

When you access `https://app2.syntheon.in/livekit_frontend/`, you see:
- ❌ Directory listing (files and folders)
- ❌ No UI displayed

This is because Apache is configured with:
```apache
DocumentRoot /var/www/html/livekit_frontend
<Directory /var/www/html/livekit_frontend>
    Options -Indexes +FollowSymLinks
    ...
</Directory>
```

This serves the directory as static files instead of proxying to Next.js.

## Solution

The Apache configuration needs to be updated to proxy `/livekit_frontend/` to the Next.js app.

### Updated Configuration
I've created the correct configuration in:
- `/var/www/html/livekit_frontend/app2-updated.conf`

This configuration:
1. Changes DocumentRoot to `/var/www/html` (parent directory)
2. Adds a `<Location /livekit_frontend>` block to proxy to `http://localhost:3000/voicebot`
3. Adds WebSocket support for LiveKit connections
4. Keeps other paths working normally

### How to Apply the Fix

Run this script (requires sudo):
```bash
bash /var/www/html/livekit_frontend/fix-apache.sh
```

Or run these commands manually:
```bash
# Backup current config
sudo cp /etc/apache2/sites-enabled/app2.syntheon.in.conf /var/www/html/livekit_frontend/app2.syntheon.in.conf.backup

# Apply new config
sudo cp /var/www/html/livekit_frontend/app2-updated.conf /etc/apache2/sites-enabled/app2.syntheon.in.conf

# Test configuration
sudo apache2ctl configtest

# Reload Apache
sudo systemctl reload apache2
```

## After Applying the Fix

Once Apache is reloaded, accessing `https://app2.syntheon.in/livekit_frontend/` will:
1. Proxy the request to `http://localhost:3000/voicebot`
2. Display the LiveKit Voice Agent UI
3. Support WebSocket connections for real-time audio

## Verification Steps

After applying the fix:
1. Check Next.js is running: `ss -tlnp | grep :3000`
2. Test the URL: `curl -I https://app2.syntheon.in/livekit_frontend/`
3. Open in browser: `https://app2.syntheon.in/livekit_frontend/`

## Additional Notes

### Next.js Configuration
The Next.js app is configured with `basePath: '/voicebot'` in `next.config.ts`. This means:
- All routes are prefixed with `/voicebot`
- Static assets are served from `/voicebot/_next/...`
- The app expects to be accessed at `/voicebot` path

### Port Mapping
- Frontend (Next.js): Port 3000 → `/voicebot` basePath
- Backend (Python): Port 8002 (not used by frontend directly)
- Apache: Port 443 (HTTPS) → Proxies to port 3000

### PM2 Configuration
The `ecosystem.config.js` is configured to run `npm start` on port 3000, but PM2 is not currently managing the process. The Next.js server was started manually with `nohup npm start`.

To use PM2 instead:
```bash
cd /var/www/html/livekit_frontend/FrontEnd/agent-starter-react/agent-starter-react
sudo pm2 start ecosystem.config.js
sudo pm2 save
```
