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.
Railway (Recommended)
Render
Heroku
Google Cloud Run
AWS (Advanced)
Best for: Easy deployment with minimal configuration Pricing:
Free: $5 credit/month (limited)
Starter: $5/month + usage
Pro: $20/month + usage
Pros:
Git-based deployment
Automatic SSL certificates
Built-in database backups
Simple environment management
Cons:
Can get expensive at scale
Less control than VPS
Best for: Free tier and simplicity Pricing:
Free: Spins down after inactivity
Starter: $7/month
Standard: $25/month
Pros:
Generous free tier
Easy GitHub integration
Automatic deployments
Good documentation
Cons:
Free tier has cold starts
Limited customization
Best for: Established platform with add-ons Pricing:
Eco: $5/month (shared)
Basic: $7/month
Standard: $25-50/month
Pros:
Mature ecosystem
Many add-ons available
Strong documentation
Easy scaling
Cons:
More expensive than competitors
File system is ephemeral
Best for: YouTube API integration and pay-per-use Pricing:
Pay-per-use (can be free for low traffic)
~$10-30/month for typical usage
Pros:
Excellent YouTube API integration
Scales to zero
Pay only for what you use
Strong performance
Cons:
More complex setup
Requires containerization
Best for: Enterprise deployments Services:
EC2 for compute
RDS for database
S3 for file storage
CloudWatch for monitoring
Pricing:
Free tier available (12 months)
Production: $20-200+/month
Pros:
Maximum flexibility
Comprehensive services
Global infrastructure
Cons:
Steep learning curve
Can be expensive
Complex billing
Deployment Guide: Railway
Railway is the easiest cloud deployment option for the YouTube Automation Agent.
Create Railway Account
Go to railway.app
Sign up with GitHub
Verify your email
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
Create New Project
Click “New Project” in Railway dashboard
Select “Deploy from GitHub repo”
Choose your forked repository
Select the main branch
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
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
}
}
Configure Persistent Storage
Add a volume for data persistence:
Go to Settings → Volumes
Click “Add Volume”
Mount path: /app/data
This ensures your database persists across deployments
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
Deploy
Railway automatically deploys on git push: git add .
git commit -m "Configure for Railway deployment"
git push
Monitor deployment in Railway dashboard.
Access Your Application
Railway provides a public URL: https://your-app.railway.app
Access dashboard at that URL
Set up custom domain (optional) in Settings → Domains
Deployment Guide: Render
Render offers a generous free tier, perfect for testing.
Create New Web Service
Click “New” → “Web Service”
Connect your GitHub repository
Configure:
Name: youtube-automation-agent
Environment: Node
Build Command: npm install
Start Command: npm start
Plan: Free (or Starter for production)
Add Environment Variables
In Environment tab, add all variables from .env.example
Add Persistent Disk
Free tier doesn’t support disks, but Starter ($7/month) does:
Go to Disks tab
Add disk mounted to /opt/render/project/src/data
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.
Install Google Cloud SDK
# macOS
brew install google-cloud-sdk
# Linux
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Initialize
gcloud init
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" ]
Create .dockerignore
node_modules
npm-debug.log
.git
.gitignore
.env
data/
logs/
uploads/
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
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
Configure Environment Variables
gcloud run services update youtube-agent \
--update-env-vars OPENAI_API_KEY=your-key, \
CHANNEL_NAME= "Your Channel" , \
YOUTUBE_REGION=US
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
SQLite (Default)
PostgreSQL
MongoDB Atlas
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' );
Best for: Production deployments Most cloud platforms offer managed PostgreSQL:
Railway: Built-in PostgreSQL
Render: Managed PostgreSQL
AWS: RDS PostgreSQL
Install PostgreSQL driver: Update database configuration: const { Pool } = require ( 'pg' );
const pool = new Pool ({
connectionString: process . env . DATABASE_URL ,
ssl: { rejectUnauthorized: false }
});
Best for: Flexible schema Free tier available: const { MongoClient } = require ( 'mongodb' );
const client = new MongoClient ( process . env . MONGODB_URI );
File Storage for Cloud Deployment
Cloud Storage Google Cloud Storage npm install @google-cloud/storage
For thumbnails and video files
AWS S3 Amazon S3 Enterprise-grade object storage
Cloudinary Media Management Optimized for images and videos
DigitalOcean Spaces S3-Compatible
Cost-effective alternative to S3
Monitoring and Logging
Railway
Render
Google Cloud
Built-in metrics:
CPU usage
Memory usage
Network traffic
Application logs
Access via Railway dashboard → Metrics tab Free monitoring includes:
Deployment logs
Service metrics
Health checks
Paid plans add advanced metrics Use Cloud Logging and Monitoring: # View logs
gcloud run services logs read youtube-agent
# Stream logs
gcloud run services logs tail youtube-agent
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
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
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
Monitor Spending
Set up billing alerts:
Railway: Budget alerts in settings
Google Cloud: Budget & Alerts in Billing
AWS: CloudWatch billing alarms
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