Skip to main content

Production Deployment

This comprehensive guide covers deploying Clipron AI to production servers using our automated deployment scripts and manual configuration options.
Production deployment requires system administration expertise. Ensure you understand server security, SSL certificates, and database management before proceeding.

Deployment Overview

Clipron AI production deployment includes:

Automated Scripts

One-command deployment with our start.sh script

Manual Configuration

Step-by-step manual setup for custom environments

Docker Deployment

Containerized deployment for scalability

Load Balancing

Multi-server setup with load balancing

Pre-Deployment Checklist

Before starting deployment, ensure you have:
1

Server Preparation

  • ✅ Ubuntu 20.04 LTS or newer server
  • ✅ Root or sudo access
  • ✅ Domain name pointing to server IP
  • ✅ Firewall configured (ports 80, 443, 22)
2

API Keys Ready

  • ✅ Google Gemini API key
  • ✅ DeepSeek API key (recommended)
  • ✅ Anthropic Claude API key (recommended)
  • ✅ OpenAI API key (fallback)
3

OAuth Applications

  • ✅ Google OAuth client ID and secret
  • ✅ GitHub OAuth client ID and secret
  • ✅ Redirect URLs configured for your domain
4

Payment Setup

  • ✅ Stripe account and API keys
  • ✅ Webhook endpoint configured
  • ✅ SSL certificate for webhook security

Automated Deployment

Quick Start with start.sh

Our automated deployment script handles most of the setup:
# 1. Clone repository
git clone https://github.com/clipron/clipron-ai.git
cd clipron-ai

# 2. Make scripts executable
chmod +x *.sh

# 3. Configure environment (see next section)
sudo nano backend/.env

# 4. Run automated deployment
sudo ./start.sh

What start.sh Does

  • Updates system packages
  • Installs Python 3.9+, Node.js 18+, Nginx
  • Installs build tools and development headers
  • Configures system users and permissions
  • Creates Python virtual environment
  • Installs Python dependencies
  • Builds React frontend for production
  • Initializes database with proper schema
  • Creates systemd service for backend
  • Configures Nginx as reverse proxy
  • Sets up SSL with Let’s Encrypt (if configured)
  • Enables automatic service startup
  • Configures firewall rules
  • Sets proper file permissions
  • Enables security headers
  • Configures log rotation

Environment Configuration

Production Environment File

Create backend/.env with production settings:
# Database Configuration
DATABASE_URL=postgresql://clipron:password@localhost/clipron_db
# or for SQLite: sqlite:///./clipron.db

# Security Settings
SECRET_KEY=your-super-secret-key-min-32-chars
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# Production Settings
ENVIRONMENT=production
DEBUG=false
FRONTEND_URL=https://yourdomain.com

# AI API Keys
GOOGLE_GEMINI_API_KEY=your_google_gemini_api_key
DEEPSEEK_API_KEY=your_deepseek_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
OPENAI_API_KEY=your_openai_api_key

# OAuth Configuration
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret

# Stripe Configuration
STRIPE_SECRET_KEY=sk_live_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret

# Email Configuration (optional)
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=[email protected]
SMTP_PASSWORD=your_app_password

Frontend Environment

Create frontend/.env.production:
# API Configuration
REACT_APP_API_URL=https://yourdomain.com/api
REACT_APP_ENVIRONMENT=production

# Analytics (optional)
REACT_APP_GOOGLE_ANALYTICS_ID=GA_MEASUREMENT_ID
REACT_APP_ENABLE_ANALYTICS=true

# Error Tracking (optional)
REACT_APP_SENTRY_DSN=your_sentry_dsn
REACT_APP_ENABLE_SENTRY=true

# Feature Flags
REACT_APP_ENABLE_GITHUB_INTEGRATION=true
REACT_APP_ENABLE_STRIPE_PAYMENTS=true

Manual Deployment Steps

If you prefer manual deployment or need custom configuration:

1. System Preparation

# Update system
sudo apt update && sudo apt upgrade -y

# Install required packages
sudo apt install -y git python3 python3-venv python3-pip nodejs npm nginx postgresql postgresql-contrib certbot python3-certbot-nginx

# Create application user
sudo useradd -m -s /bin/bash clipron
sudo usermod -aG sudo clipron

2. Database Setup

3. Application Installation

# Clone repository
cd /opt
sudo git clone https://github.com/clipron/clipron-ai.git clipron
sudo chown -R clipron:clipron /opt/clipron

# Switch to application user
sudo -u clipron -i
cd /opt/clipron

# Backend setup
cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Initialize database
python init_db.py

# Frontend setup
cd ../frontend
npm install
npm run build

4. Service Configuration

Create systemd service file:
sudo nano /etc/systemd/system/clipron.service
[Unit]
Description=Clipron AI Backend
After=network.target

[Service]
Type=simple
User=clipron
Group=clipron
WorkingDirectory=/opt/clipron/backend
Environment=PATH=/opt/clipron/backend/venv/bin
ExecStart=/opt/clipron/backend/venv/bin/python main.py
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable clipron
sudo systemctl start clipron

5. Nginx Configuration

Create Nginx configuration:
sudo nano /etc/nginx/sites-available/clipron
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    
    # Redirect HTTP to HTTPS
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name yourdomain.com www.yourdomain.com;
    
    # SSL Configuration (will be added by Certbot)
    
    # Frontend static files
    location / {
        root /opt/clipron/frontend/build;
        try_files $uri $uri/ /index.html;
        
        # Cache static assets
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
            expires 1y;
            add_header Cache-Control "public, immutable";
        }
    }
    
    # Backend API
    location /api/ {
        proxy_pass http://localhost:8000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    
    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" always;
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/clipron /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

6. SSL Certificate

# Install SSL certificate with Let's Encrypt
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

# Test automatic renewal
sudo certbot renew --dry-run

Post-Deployment Verification

Health Checks

# Check service status
sudo systemctl status clipron
sudo systemctl status nginx
sudo systemctl status postgresql

# Check logs
sudo journalctl -u clipron -f
sudo tail -f /var/log/nginx/access.log
# Test API endpoints
curl https://yourdomain.com/api/health
curl https://yourdomain.com/api/docs

# Test frontend
curl -I https://yourdomain.com/
# Test database connection
cd /opt/clipron/backend
source venv/bin/activate
python -c "from database import engine; print('Database OK')"

Monitoring and Maintenance

Log Management

Application Logs

  • Backend: journalctl -u clipron
  • Nginx: /var/log/nginx/
  • Database: /var/log/postgresql/

Log Rotation

  • Automatic rotation configured
  • 30-day retention policy
  • Compressed old logs

Backup Strategy

1

Database Backups

# PostgreSQL backup
sudo -u postgres pg_dump clipron_db > backup_$(date +%Y%m%d).sql

# SQLite backup
cp /opt/clipron/backend/clipron.db backup_$(date +%Y%m%d).db
2

Application Backups

# Backup configuration and uploads
tar -czf clipron_backup_$(date +%Y%m%d).tar.gz /opt/clipron/backend/.env /opt/clipron/uploads/
3

Automated Backups

# Add to crontab
0 2 * * * /opt/clipron/scripts/backup.sh
Production Tip: Always test your deployment on a staging server first. Use the same configuration and data to ensure everything works correctly before going live.