# Remotion + Express + ElevenLabs Initialization

## Project Structure

```
/workspace/
├── src/
│   ├── index.js                 # Express server entry point
│   ├── services/
│   │   ├── ElevenLabsClient.js  # ElevenLabs API wrapper
│   │   ├── StorageClient.js     # S3 storage wrapper
│   │   └── VideoComposer.js     # Remotion video handling
│   └── components/
│       └── VideoElements.js     # Video component definitions
├── components/                  # Remotion composition files (placeholder)
├── generated/
│   ├── videos/                  # Output video files
│   ├── temp/                    # Temporary files
│   └── cache/                   # Cache directory
├── public/                      # Static assets
├── package.json                 # Dependencies
├── .env.example                 # Environment template
├── remotion.config.js           # Remotion configuration
└── README.md                    # This file
```

## Quick Start

1. **Install Dependencies**
   ```bash
   npm install
   ```

2. **Set Environment Variables**
   ```bash
   cp .env.example .env
   # Edit .env and add:
   # - ELEVENLABS_API_KEY
   # - STORAGE_BUCKET, S3_ACCESS_KEY, S3_SECRET_KEY
   ```

3. **Start Development Server**
   ```bash
   npm run dev
   # or npm start for production
   ```

4. **Server runs on**: `http://localhost:3000`

## Required System Dependencies

- **Node.js**: v20+
- **FFmpeg**: For video encoding
- **Playwright**: Browser automation (included in dependencies)
- **ElevenLabs SDK**: For text-to-speech

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/` | Server info & endpoints |
| GET | `/health` | Health check |
| POST | `/api/render` | Create render job |
| GET | `/api/render/:id` | Get render status |

## Environment Variables

Required in `.env`:
- `ELEVENLABS_API_KEY` - ElevenLabs API key
- `STORAGE_BUCKET` - AWS S3 bucket name
- `S3_ACCESS_KEY` - AWS access key
- `S3_SECRET_KEY` - AWS secret key
- `S3_REGION` - AWS region (default: us-east-1)

## Services

### ElevenLabsClient
Text-to-speech audio generation
```javascript
import ElevenLabsClient from './src/services/ElevenLabsClient.js';
const client = new ElevenLabsClient();
const audio = await client.textToSpeech('Hello World');
```

### StorageClient
S3 file uploads and management
```javascript
import StorageClient from './src/services/StorageClient.js';
const storage = new StorageClient();
await storage.uploadFile('video.mp4', fileBuffer);
```

### VideoComposer
Remotion video rendering
```javascript
import VideoComposer from './src/services/VideoComposer.js';
const composer = new VideoComposer();
const job = await composer.render('MyComposition', './output.mp4');
```

## Next Steps

1. Install dependencies: `npm install`
2. Configure environment variables in `.env`
3. Implement Remotion compositions in `components/`
4. Add render endpoints to `src/index.js`
5. Test with curl: `curl http://localhost:3000/health`
