Skip to main content

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.

Overview

Cloud deployment offers enterprise-grade scalability, reliability, and managed services. This option is ideal for:
  • Multiple YouTube channels
  • High-volume content production
  • Teams and agencies
  • Mission-critical operations
  • Automatic scaling based on demand
Cloud deployment can start free on some platforms or cost $10-100+/month depending on scale and features.

Cloud Platform Options

Deployment Guide: Railway

Railway is the easiest cloud deployment option for the YouTube Automation Agent.
1

Create Railway Account

  1. Go to railway.app
  2. Sign up with GitHub
  3. Verify your email
2

Fork the Repository

Fork the project to your GitHub account:
# Or clone and push to your own repo
git clone https://github.com/darkzOGx/youtube-automation-agent.git
cd youtube-automation-agent
git remote set-url origin https://github.com/YOUR-USERNAME/youtube-automation-agent.git
git push
3

Create New Project

  1. Click “New Project” in Railway dashboard
  2. Select “Deploy from GitHub repo”
  3. Choose your forked repository
  4. Select the main branch
4

Configure Environment Variables

In Railway dashboard, go to Variables tab and add:
NODE_ENV=production
PORT=3456
LOG_LEVEL=info

# AI Provider (choose one)
OPENAI_API_KEY=your-openai-key-here
GEMINI_API_KEY=your-gemini-key-here

# Channel Settings
CHANNEL_NAME=Your Channel Name
DEFAULT_AUTHOR=Your Name
TARGET_AUDIENCE=Your target audience

# YouTube Settings
YOUTUBE_REGION=US
DEFAULT_PRIVACY_STATUS=public

# Security
JWT_SECRET=generate-random-secure-string

# Rate Limiting
GLOBAL_RATE_LIMIT_PER_HOUR=50
DEFAULT_DELAY_BETWEEN_POSTS=60000
5

Add Build Configuration

Railway auto-detects Node.js, but you can customize by creating railway.json:
{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "NIXPACKS",
    "buildCommand": "npm install --production"
  },
  "deploy": {
    "startCommand": "npm start",
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10
  }
}
6

Configure Persistent Storage

Add a volume for data persistence:
  1. Go to Settings → Volumes
  2. Click “Add Volume”
  3. Mount path: /app/data
  4. This ensures your database persists across deployments
7

Upload YouTube Credentials

Since Railway doesn’t support file uploads in dashboard:Option 1: Base64 encode and use environment variable
# On your local machine
base64 config/credentials.json
Add to Railway variables:
YOUTUBE_CREDENTIALS_BASE64=<paste-base64-string>
Update your code to decode:
// In your authentication code
const credentials = process.env.YOUTUBE_CREDENTIALS_BASE64
  ? JSON.parse(Buffer.from(process.env.YOUTUBE_CREDENTIALS_BASE64, 'base64').toString())
  : require('./config/credentials.json');
Option 2: Use Railway CLI
npm install -g @railway/cli
railway login
railway link
railway run npm run credentials:setup
8

Deploy

Railway automatically deploys on git push:
git add .
git commit -m "Configure for Railway deployment"
git push
Monitor deployment in Railway dashboard.
9

Access Your Application

  1. Railway provides a public URL: https://your-app.railway.app
  2. Access dashboard at that URL
  3. Set up custom domain (optional) in Settings → Domains

Deployment Guide: Render

Render offers a generous free tier, perfect for testing.
1

Create Render Account

Sign up at render.com
2

Create New Web Service

  1. Click “New” → “Web Service”
  2. Connect your GitHub repository
  3. Configure:
    • Name: youtube-automation-agent
    • Environment: Node
    • Build Command: npm install
    • Start Command: npm start
    • Plan: Free (or Starter for production)
3

Add Environment Variables

In Environment tab, add all variables from .env.example
4

Add Persistent Disk

Free tier doesn’t support disks, but Starter ($7/month) does:
  1. Go to Disks tab
  2. Add disk mounted to /opt/render/project/src/data
5

Deploy

Click “Create Web Service” - Render will build and deploy automatically.
Free tier spins down after 15 minutes of inactivity. Use Starter plan for 24/7 operation.

Deployment Guide: Google Cloud Run

For advanced users who want serverless architecture.
1

Install Google Cloud SDK

# macOS
brew install google-cloud-sdk

# Linux
curl https://sdk.cloud.google.com | bash
exec -l $SHELL

# Initialize
gcloud init
2

Create Dockerfile

Create Dockerfile in project root:
FROM node:18-alpine

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm install --production

# Copy application files
COPY . .

# Create data directory
RUN mkdir -p /app/data

# Expose port
EXPOSE 3456

# Start application
CMD ["npm", "start"]
3

Create .dockerignore

node_modules
npm-debug.log
.git
.gitignore
.env
data/
logs/
uploads/
4

Build and Push Container

# Set project ID
export PROJECT_ID=your-gcp-project-id

# Enable required APIs
gcloud services enable run.googleapis.com
gcloud services enable containerregistry.googleapis.com

# Build container
gcloud builds submit --tag gcr.io/$PROJECT_ID/youtube-agent
5

Deploy to Cloud Run

gcloud run deploy youtube-agent \
  --image gcr.io/$PROJECT_ID/youtube-agent \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --memory 1Gi \
  --cpu 1 \
  --port 3456 \
  --set-env-vars NODE_ENV=production,PORT=3456
6

Configure Environment Variables

gcloud run services update youtube-agent \
  --update-env-vars OPENAI_API_KEY=your-key,\
CHANNEL_NAME="Your Channel",\
YOUTUBE_REGION=US
7

Set Up Cloud Storage for Persistence

# Create bucket
gsutil mb gs://$PROJECT_ID-youtube-data

# Update app to use Cloud Storage for data persistence
# This requires code modifications to use GCS instead of local filesystem

Database Options for Cloud Deployment

Best for: Simple deployments
  • Included by default
  • No additional cost
  • Requires persistent storage volume
  • Limited scalability
// Already configured in database/db.js
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./data/youtube-automation.db');

File Storage for Cloud Deployment

Cloud Storage

Google Cloud Storage
npm install @google-cloud/storage
For thumbnails and video files

AWS S3

Amazon S3
npm install aws-sdk
Enterprise-grade object storage

Cloudinary

Media Management
npm install cloudinary
Optimized for images and videos

DigitalOcean Spaces

S3-Compatible Cost-effective alternative to S3

Monitoring and Logging

Cloud Platform Monitoring

Built-in metrics:
  • CPU usage
  • Memory usage
  • Network traffic
  • Application logs
Access via Railway dashboard → Metrics tab

Third-Party Monitoring

# Install application monitoring
npm install newrelic
# Or
npm install @sentry/node
Sentry Configuration:
const Sentry = require('@sentry/node');

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.NODE_ENV,
  tracesSampleRate: 1.0,
});

Scaling Strategies

Vertical Scaling

Increase resources for single instance: Railway:
// railway.json
{
  "deploy": {
    "numReplicas": 1,
    "resources": {
      "memory": "2GB",
      "cpu": 2
    }
  }
}

Horizontal Scaling

Multiple instances for high availability: Google Cloud Run:
gcloud run services update youtube-agent \
  --min-instances 1 \
  --max-instances 10 \
  --concurrency 80

Task Queues

For handling background jobs:
npm install bull  # Redis-based queue
npm install ioredis
const Queue = require('bull');
const videoQueue = new Queue('video-generation', process.env.REDIS_URL);

// Add job
videoQueue.add({ topic: 'AI Tutorial', style: 'educational' });

// Process job
videoQueue.process(async (job) => {
  await generateVideo(job.data);
});

CI/CD Pipeline

GitHub Actions Example

Create .github/workflows/deploy.yml:
name: Deploy to Railway

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      - name: Use Node.js 18
        uses: actions/setup-node@v3
        with:
          node-version: 18
      
      - name: Install dependencies
        run: npm ci
      
      - name: Run tests
        run: npm test
      
      - name: Deploy to Railway
        uses: berviantoleo/railway-deploy@main
        with:
          railway_token: ${{ secrets.RAILWAY_TOKEN }}
          service: youtube-agent

Cost Optimization

1

Use Free Tiers

  • Railway: $5 free credit/month
  • Render: Free tier with limitations
  • Google Cloud Run: 2M requests/month free
  • Gemini API: 60 requests/minute free
2

Optimize Resource Usage

  • Right-size your instances
  • Use auto-scaling to scale down during off-hours
  • Implement caching to reduce API calls
  • Compress logs and rotate regularly
3

Monitor Spending

Set up billing alerts:
  • Railway: Budget alerts in settings
  • Google Cloud: Budget & Alerts in Billing
  • AWS: CloudWatch billing alarms
4

Use Scheduled Scaling

Scale down during low-activity hours:
// In your automation scheduler
const schedule = {
  peakHours: { instances: 2, memory: '2GB' },
  offHours: { instances: 1, memory: '1GB' }
};

Security Best Practices

Environment Variables

Never commit secrets to Git Use platform secret management

HTTPS Only

All cloud platforms provide free SSL Enforce HTTPS redirects

Rate Limiting

Protect against API abuse Use environment variables to configure

Regular Updates

Keep dependencies updated Monitor security advisories

Disaster Recovery

Automated Backups

// Add to your cron jobs
const schedule = require('node-cron');
const { backupToCloud } = require('./utils/backup');

// Daily backup at 3 AM
schedule.schedule('0 3 * * *', async () => {
  await backupToCloud();
});

Backup to Cloud Storage

const { Storage } = require('@google-cloud/storage');
const storage = new Storage();

async function backupToCloud() {
  const bucket = storage.bucket('youtube-agent-backups');
  const timestamp = new Date().toISOString();
  
  await bucket.upload('./data/youtube-automation.db', {
    destination: `backups/db-${timestamp}.db`,
    metadata: {
      contentType: 'application/x-sqlite3',
    },
  });
}

Troubleshooting Cloud Deployments

Build Failures

# Check build logs
railway logs --deployment

# Verify Node.js version
node --version

# Check package.json engines field
{
  "engines": {
    "node": ">=18.0.0"
  }
}

Memory Issues

// Add memory monitoring
const used = process.memoryUsage();
console.log(`Memory: ${Math.round(used.heapUsed / 1024 / 1024)} MB`);

// Increase memory limit if needed
// railway.json
{
  "deploy": {
    "resources": {
      "memory": "2GB"  // Increase from 1GB
    }
  }
}

Database Connection Issues

// Add connection retry logic
const connectWithRetry = async (retries = 5) => {
  for (let i = 0; i < retries; i++) {
    try {
      await db.connect();
      return;
    } catch (err) {
      if (i === retries - 1) throw err;
      await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
    }
  }
};

Next Steps

Configuration

Advanced configuration and optimization

Monitoring

Set up comprehensive monitoring

Scaling Guide

Handle growth and high traffic

API Reference

Build custom integrations

Build docs developers (and LLMs) love