> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/darkzOGx/youtube-automation-agent/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Complete installation and configuration guide for the YouTube Automation Agent with prerequisites, setup steps, and deployment options.

# Installation Guide

This comprehensive guide covers everything you need to install, configure, and deploy the YouTube Automation Agent.

## Prerequisites

<CardGroup cols={2}>
  <Card title="Node.js 18+" icon="node-js">
    JavaScript runtime required for the application
  </Card>

  <Card title="Google Account" icon="google">
    For YouTube Data API access
  </Card>

  <Card title="AI Provider Account" icon="brain">
    OpenAI or Google AI Studio account
  </Card>

  <Card title="10 Minutes" icon="clock">
    Initial setup and configuration time
  </Card>
</CardGroup>

### System Requirements

<Tabs>
  <Tab title="Minimum">
    * **OS**: Windows 10+, macOS 10.15+, Ubuntu 20.04+
    * **CPU**: 2 cores
    * **RAM**: 2 GB available
    * **Storage**: 5 GB free space
    * **Network**: Stable internet connection
  </Tab>

  <Tab title="Recommended">
    * **OS**: Windows 11, macOS 12+, Ubuntu 22.04+
    * **CPU**: 4+ cores
    * **RAM**: 4 GB available
    * **Storage**: 20 GB free space (for media files)
    * **Network**: High-speed internet (10+ Mbps)
  </Tab>
</Tabs>

## Step 1: Install Node.js

<Steps>
  <Step title="Download Node.js">
    Visit [nodejs.org](https://nodejs.org/) and download the LTS version.

    <CodeGroup>
      ```bash macOS (Homebrew) theme={null}
      brew install node@18
      ```

      ```bash Ubuntu/Debian theme={null}
      curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
      sudo apt-get install -y nodejs
      ```

      ```bash Windows (Chocolatey) theme={null}
      choco install nodejs-lts
      ```
    </CodeGroup>
  </Step>

  <Step title="Verify Installation">
    ```bash theme={null}
    node --version  # Should show v18.x.x or higher
    npm --version   # Should show 9.x.x or higher
    ```
  </Step>
</Steps>

## Step 2: Clone Repository

<CodeGroup>
  ```bash HTTPS theme={null}
  git clone https://github.com/darkzOGx/youtube-automation-agent.git
  cd youtube-automation-agent
  ```

  ```bash SSH theme={null}
  git clone git@github.com:darkzOGx/youtube-automation-agent.git
  cd youtube-automation-agent
  ```

  ```bash GitHub CLI theme={null}
  gh repo clone darkzOGx/youtube-automation-agent
  cd youtube-automation-agent
  ```
</CodeGroup>

## Step 3: Install Dependencies

Install all required npm packages:

```bash theme={null}
npm install
```

This installs:

<AccordionGroup>
  <Accordion title="Core Dependencies" icon="box">
    ```json theme={null}
    {
      "googleapis": "^128.0.0",           // YouTube API integration
      "express": "^4.18.2",               // Web server
      "sqlite3": "^5.1.6",                // Database
      "dotenv": "^16.3.1",                // Environment variables
      "winston": "^3.11.0"                // Logging
    }
    ```
  </Accordion>

  <Accordion title="AI Providers" icon="brain">
    ```json theme={null}
    {
      "openai": "^4.20.0",                      // OpenAI GPT-4, DALL-E
      "@google/generative-ai": "^0.1.3",       // Google Gemini
      "replicate": "^1.0.1"                     // Alternative AI models
    }
    ```
  </Accordion>

  <Accordion title="Automation Tools" icon="robot">
    ```json theme={null}
    {
      "node-cron": "^3.0.2",              // Task scheduling
      "cron": "^3.1.6",                   // Advanced scheduling
      "axios": "^1.6.0",                  // HTTP requests
      "moment": "^2.29.4"                 // Date/time handling
    }
    ```
  </Accordion>

  <Accordion title="Media Processing" icon="photo-film">
    ```json theme={null}
    {
      "jimp": "^0.22.10",                           // Image manipulation
      "playwright": "^1.54.2",                      // Browser automation
      "microsoft-cognitiveservices-speech-sdk": "^1.45.0"  // TTS
    }
    ```
  </Accordion>
</AccordionGroup>

## Step 4: Configure API Credentials

### YouTube Data API Setup

<Steps>
  <Step title="Create Google Cloud Project">
    1. Navigate to [Google Cloud Console](https://console.cloud.google.com/)
    2. Click **"Select a project"** → **"New Project"**
    3. Enter project name: `YouTube Automation Agent`
    4. Click **"Create"**

    <Note>
      Project creation takes 10-30 seconds. Wait for the notification before proceeding.
    </Note>
  </Step>

  <Step title="Enable YouTube Data API v3">
    1. In the left sidebar: **"APIs & Services"** → **"Library"**
    2. Search for: `YouTube Data API v3`
    3. Click on the API in results
    4. Click **"Enable"** button

    ```javascript theme={null}
    // The API provides 10,000 quota units per day (FREE)
    // Typical usage:
    // - Search: 100 units
    // - Video details: 1 unit
    // - Upload: 1,600 units
    // Daily automation uses ~2,000-3,000 units
    ```
  </Step>

  <Step title="Create OAuth 2.0 Credentials">
    1. Navigate to: **"APIs & Services"** → **"Credentials"**
    2. Click **"Create Credentials"** → **"OAuth client ID"**
    3. If prompted, configure OAuth consent screen:
       * User Type: **External**
       * App name: `YouTube Automation Agent`
       * Support email: Your email
       * Scopes: Add `youtube.upload`, `youtube.readonly`
    4. Back to credentials, choose application type: **Desktop app**
    5. Name it: `YouTube Automation Desktop`
    6. Click **"Create"**
  </Step>

  <Step title="Download Credentials">
    1. Click the download icon (⬇️) next to your new OAuth client
    2. Save the JSON file
    3. Rename to `credentials.json`
    4. Move to `config/credentials.json` in your project:

    ```bash theme={null}
    mkdir -p config
    mv ~/Downloads/client_secret_*.json config/credentials.json
    ```
  </Step>
</Steps>

### AI Provider Setup

Choose **one** of the following AI providers:

<Tabs>
  <Tab title="OpenAI (Recommended)">
    ### OpenAI Setup

    <Steps>
      <Step title="Create Account">
        Visit [platform.openai.com/signup](https://platform.openai.com/signup) and create an account.
      </Step>

      <Step title="Generate API Key">
        1. Go to [API Keys](https://platform.openai.com/api-keys)
        2. Click **"Create new secret key"**
        3. Name it: `YouTube Automation`
        4. Copy the key (starts with `sk-proj-`)

        <Warning>
          Save your API key immediately! You won't be able to see it again.
        </Warning>
      </Step>

      <Step title="Add Credits">
        1. Go to [Billing](https://platform.openai.com/account/billing)
        2. Click **"Add payment method"**
        3. Add \$5-10 to start (lasts 20-50 videos)
      </Step>

      <Step title="Configure in .env">
        ```bash theme={null}
        OPENAI_API_KEY=sk-proj-your-key-here
        ```
      </Step>
    </Steps>

    **Pricing Overview**:

    * GPT-4: \$0.01 per 1K tokens (\~750 words)
    * DALL-E 3: \$0.040 per image (1024x1024)
    * **Total per video**: \~\$0.10-0.30
  </Tab>

  <Tab title="Google Gemini (FREE)">
    ### Google Gemini Setup

    <Steps>
      <Step title="Access AI Studio">
        Visit [makersuite.google.com](https://makersuite.google.com/)
      </Step>

      <Step title="Get API Key">
        1. Click **"Get API Key"** in the top right
        2. Choose **"Create API key in new project"** or select existing project
        3. Click **"Create API key"**
        4. Copy the key (starts with `AIza`)
      </Step>

      <Step title="Configure in .env">
        ```bash theme={null}
        GEMINI_API_KEY=AIza-your-key-here
        ```
      </Step>
    </Steps>

    **Free Tier**:

    * 60 requests per minute
    * 1,500 requests per day
    * Perfect for 3-5 videos daily at **\$0 cost**
  </Tab>

  <Tab title="Custom (Advanced)">
    ### Custom AI Integration

    You can integrate any OpenAI-compatible API:

    ```javascript theme={null}
    // Example: Anthropic Claude
    const Anthropic = require('@anthropic-ai/sdk');

    const anthropic = new Anthropic({
      apiKey: process.env.ANTHROPIC_API_KEY
    });

    async generateContent(prompt) {
      const response = await anthropic.messages.create({
        model: 'claude-3-sonnet-20240229',
        max_tokens: 1024,
        messages: [{ role: 'user', content: prompt }]
      });
      return response.content[0].text;
    }
    ```

    Or use local models:

    ```bash theme={null}
    # Install Ollama
    curl https://ollama.ai/install.sh | sh

    # Run local model
    ollama run llama2

    # Configure endpoint
    OLLAMA_API_URL=http://localhost:11434
    ```
  </Tab>
</Tabs>

## Step 5: Run Setup Wizard

The interactive setup wizard configures everything:

```bash theme={null}
npm run setup
```

### Setup Wizard Flow

<Steps>
  <Step title="Create Directories">
    ```javascript theme={null}
    async createDirectories() {
      const directories = [
        'config',      // Configuration files
        'logs',        // Application logs
        'data',        // Generated content
        'data/production',        // Production assets
        'data/assets',           // Media assets
        'data/videos',           // Video files
        'data/audio',            // Audio files
        'data/scripts',          // Generated scripts
        'data/captions',         // Caption files
        'data/thumbnail-templates',  // Thumbnail templates
        'temp/processing',       // Temporary processing
        'uploads/thumbnails'     // Upload queue
      ];
      
      for (const dir of directories) {
        await fs.mkdir(path.join(__dirname, dir), { recursive: true });
      }
    }
    ```
  </Step>

  <Step title="Initialize Database">
    ```javascript theme={null}
    async initializeDatabase() {
      this.db = new Database();
      await this.db.initialize();
      
      // Creates tables:
      // - content_strategies
      // - scripts
      // - thumbnails
      // - seo_data
      // - productions
      // - publish_schedule
      // - analytics_reports
      // - keyword_performance
      // - content_history
      // - settings
    }
    ```
  </Step>

  <Step title="Configure Credentials">
    Interactive prompts for:

    * YouTube channel selection
    * AI provider preference
    * API keys validation
    * Content preferences
    * Posting schedule
  </Step>

  <Step title="Generate Environment File">
    ```javascript theme={null}
    async createEnvironmentFile() {
      const envContent = `
      # Application Settings
      NODE_ENV=production
      PORT=3456
      LOG_LEVEL=info
      
      # YouTube Settings
      YOUTUBE_REGION=US
      DEFAULT_PRIVACY_STATUS=public
      
      # Content Settings
      AUTO_SHORTEN_CONTENT=true
      AUTO_ADD_BACKLINKS=true
      PRESERVE_FORMATTING=true
      
      # Rate Limiting
      GLOBAL_RATE_LIMIT_PER_HOUR=50
      DEFAULT_DELAY_BETWEEN_POSTS=60000
      
      # Security
      JWT_SECRET=${this.generateJWTSecret()}
      
      # Automation
      DAILY_CONTENT_ENABLED=true
      AUTO_PUBLISH_ENABLED=true
      OPTIMIZATION_ENABLED=true
      CONTENT_BUFFER_DAYS=3
      MAX_DAILY_POSTS=1
      `;
      
      await fs.writeFile('.env', envContent);
    }
    ```
  </Step>

  <Step title="Validate Setup">
    ```javascript theme={null}
    async validateSetup() {
      // Check directories exist
      await fs.access('data');
      await fs.access('logs');
      await fs.access('config');
      
      // Check database
      const stats = await this.database.getStats();
      
      // Validate credentials
      const valid = await this.credentialManager.validateAll();
      
      // Check environment
      await fs.access('.env');
    }
    ```
  </Step>
</Steps>

## Step 6: Start the Application

Launch the automation agent:

```bash theme={null}
npm start
```

Successful startup shows:

```
🎬 YouTube Automation Agent v1.0
──────────────────────────────────────────────────
ℹ Initializing database...
✓ Database initialized successfully
ℹ Loading credentials...
ℹ Initializing agents...
ℹ ✓ strategy agent initialized
ℹ ✓ scriptWriter agent initialized
ℹ ✓ thumbnailDesigner agent initialized
ℹ ✓ seoOptimizer agent initialized
ℹ ✓ production agent initialized
ℹ ✓ publishing agent initialized
ℹ ✓ analytics agent initialized
ℹ Setting up automation scheduler...
ℹ Started scheduled task: daily-content-generation
ℹ Started scheduled task: publish-queue-processing
ℹ Started scheduled task: daily-analytics
ℹ Started scheduled task: weekly-strategy-review
ℹ Started scheduled task: daily-optimization
ℹ Started scheduled task: database-maintenance
✓ YouTube Automation Agent initialized successfully!

✅ YouTube Automation Agent running on port 3456
──────────────────────────────────────────────────
📊 Dashboard: http://localhost:3456
🔧 API Health: http://localhost:3456/health
📅 Schedule: http://localhost:3456/schedule
📈 Analytics: http://localhost:3456/analytics
──────────────────────────────────────────────────

🤖 Automation is active. Content will be generated and posted daily.
```

## Deployment Options

### Local Development

Run on your computer during development:

```bash theme={null}
# Development mode with auto-restart
npm install -g nodemon
nodemon index.js
```

### Production Deployment

<Tabs>
  <Tab title="PM2 (Recommended)">
    ### Process Manager for Node.js

    ```bash theme={null}
    # Install PM2
    npm install -g pm2

    # Start application
    pm2 start index.js --name youtube-automation

    # Enable startup script
    pm2 startup
    pm2 save

    # Monitor
    pm2 monit

    # View logs
    pm2 logs youtube-automation

    # Restart
    pm2 restart youtube-automation
    ```

    The setup wizard creates `ecosystem.config.js`:

    ```javascript theme={null}
    module.exports = {
      apps: [{
        name: 'youtube-automation-agent',
        script: 'index.js',
        instances: 1,
        autorestart: true,
        watch: false,
        max_memory_restart: '1G',
        env: {
          NODE_ENV: 'production',
          PORT: 3456
        }
      }]
    };
    ```
  </Tab>

  <Tab title="Docker">
    ### Docker Deployment

    Create `Dockerfile`:

    ```dockerfile theme={null}
    FROM node:18-alpine

    WORKDIR /app

    COPY package*.json ./
    RUN npm ci --only=production

    COPY . .

    EXPOSE 3456

    CMD ["node", "index.js"]
    ```

    Create `docker-compose.yml`:

    ```yaml theme={null}
    version: '3.8'
    services:
      youtube-automation:
        build: .
        ports:
          - "3456:3456"
        volumes:
          - ./data:/app/data
          - ./logs:/app/logs
          - ./config:/app/config
        env_file:
          - .env
        restart: unless-stopped
    ```

    Deploy:

    ```bash theme={null}
    docker-compose up -d
    ```
  </Tab>

  <Tab title="VPS (DigitalOcean/Linode)">
    ### Cloud VPS Deployment

    <Steps>
      <Step title="Create VPS">
        * Provider: DigitalOcean, Linode, Vultr
        * Plan: \$5-10/month (1-2 GB RAM)
        * OS: Ubuntu 22.04 LTS
      </Step>

      <Step title="SSH and Setup">
        ```bash theme={null}
        # Connect to VPS
        ssh root@your-vps-ip

        # Update system
        apt update && apt upgrade -y

        # Install Node.js
        curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
        apt install -y nodejs

        # Install Git
        apt install -y git
        ```
      </Step>

      <Step title="Clone and Configure">
        ```bash theme={null}
        # Clone repository
        git clone https://github.com/darkzOGx/youtube-automation-agent.git
        cd youtube-automation-agent

        # Install dependencies
        npm install

        # Configure environment
        nano .env
        # (Add your API keys)

        # Setup credentials
        mkdir config
        nano config/credentials.json
        # (Paste YouTube API credentials)
        ```
      </Step>

      <Step title="Start with PM2">
        ```bash theme={null}
        # Install PM2
        npm install -g pm2

        # Start application
        pm2 start index.js --name youtube-automation

        # Configure startup
        pm2 startup systemd
        pm2 save

        # Setup nginx reverse proxy (optional)
        apt install -y nginx
        # Configure nginx for domain access
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Configuration Reference

### Environment Variables

<AccordionGroup>
  <Accordion title="Application Settings">
    ```bash theme={null}
    NODE_ENV=production          # Environment (development/production)
    PORT=3456                    # Server port
    LOG_LEVEL=info              # Logging level (debug/info/warn/error)
    ```
  </Accordion>

  <Accordion title="YouTube Settings">
    ```bash theme={null}
    YOUTUBE_REGION=US                    # YouTube region code
    DEFAULT_PRIVACY_STATUS=public        # Video privacy (public/private/unlisted)
    ```
  </Accordion>

  <Accordion title="Content Settings">
    ```bash theme={null}
    CHANNEL_NAME=Your Channel Name
    TARGET_AUDIENCE=Your target audience
    POSTING_FREQUENCY=daily              # daily/every-2-days/3-per-week/weekly
    CONTENT_BUFFER_DAYS=3               # Days of content to keep ready
    MAX_DAILY_POSTS=1                   # Maximum posts per day
    ```
  </Accordion>

  <Accordion title="Automation Settings">
    ```bash theme={null}
    DAILY_CONTENT_ENABLED=true
    AUTO_PUBLISH_ENABLED=true
    OPTIMIZATION_ENABLED=true
    ANALYTICS_ENABLED=true
    ```
  </Accordion>
</AccordionGroup>

## Verification

Confirm everything is working:

<Steps>
  <Step title="Health Check">
    ```bash theme={null}
    curl http://localhost:3456/health
    ```

    Should return:

    ```json theme={null}
    {
      "status": "healthy",
      "initialized": true,
      "agents": ["strategy", "scriptWriter", "thumbnailDesigner", "seoOptimizer", "production", "publishing", "analytics"],
      "timestamp": "2026-03-05T12:00:00.000Z"
    }
    ```
  </Step>

  <Step title="Test Content Generation">
    ```bash theme={null}
    curl -X POST http://localhost:3456/generate \
      -H "Content-Type: application/json" \
      -d '{"topic": "Test Video"}'
    ```
  </Step>

  <Step title="Check Logs">
    ```bash theme={null}
    # View application logs
    tail -f logs/application.log

    # Or with PM2
    pm2 logs youtube-automation
    ```
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/api-reference">
    Explore available API endpoints
  </Card>

  <Card title="Configuration" icon="gear" href="/configuration">
    Advanced configuration options
  </Card>

  <Card title="Agents" icon="robot" href="/features/ai-agents">
    Learn about each AI agent
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/advanced/troubleshooting">
    Common issues and solutions
  </Card>
</CardGroup>

<Note>
  **Installation Complete!** Your YouTube Automation Agent is now running and will automatically generate and publish content according to your schedule.
</Note>
