Top

Pixel AI documentation

Generate high-quality content, images, and code effortlessly with Pixel AI

Live Server Deployment

Introduction

This guide explains how to deploy the Pixel AI backend on a VPS (Virtual Private Server). You'll set up the server, install all required tools, configure the database, and run Pixel AI securely in production. VPS deployment is the recommended method because it gives full control over performance, scaling, security, and custom configurations.

1. System Setup

After connecting to your VPS via SSH, start by updating your server and installing required packages.

sudo apt update && sudo apt upgrade -y 
sudo apt install curl wget git unzip -y

This installs essential utilities needed later to fetch and manage Pixel AI backend files and dependencies.

2. Install Node.js Runtime

The Pixel AI backend is built on Node.js. Install the latest LTS version:

curl -fsSL https://deb.nodesource.com/setup_22.x |sudo -E bash -
sudo apt-get install -y nodejs
node --version
npm --version

Confirming the version ensures Node.js and npm installed successfully.

3. MongoDB Setup

Install MongoDB Community Edition (recommended version: 8.0 or latest stable)

1. Import the MongoDB public GPG Key (for version 8.0):

curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc

sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

2. Create the list file (for Ubuntu 22.04 = jammy | 24.04 = noble):

Use 'jammy' for Ubuntu 22.04, 'noble' for Ubuntu 24.04

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ]
https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" |
sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

3. Update and install MongoDB

sudo apt update
sudo apt install -y mongodb-org

4. Start and enable MongoDB service

sudo systemctl start mongodb
sudo systemctl enable mongodb

5. Verify the installation

sudo systemctl status mongod
mongod --version
mongosh --version

6. Create MongoDB Admin User

Open MongoDB shell:

mongosh

Switch to admin database

use admin

Create admin user:

db.createUser({ 
user: "admin", 
pwd: "strongpassword", 
roles: [ { role: "root", db: "admin" } ] 
})

Enable authentication (security best practice):

sudo nano /etc/mongod.conf
security:
  authorization: enabled

Restart MongoDB:

sudo systemctl restart mongodb

Connect using authentication:

mongosh -u admin -p --authenticationDatabase admin
4. Deploy the Application Code

Upload the Pixel AI backend folder or clone it directly from your repository:

git clone  
cd pixel-ai-backend
npm install --production

After installation, create a .env file and add all required backend configuration values.

How to Run Seeding

To seed all data to the database, navigate to your backend directory and run the following command:

npm run seed
Note: Ensure your .env file is correctly configured with your MongoDB connection string before running the seed command.
5. Process Management

To keep Pixel AI running continuously and auto-restart on errors, use PM2:

sudo npm install -g pm2
pm2 start server.js --name pixelai-backend
pm2 save
pm2 startup

PM2 ensures uptime, handles crashes, and provides clean logging tools.

6. Reverse Proxy Setup (Nginx)

Pixel AI runs on an internal port (e.g., 3001), so you need Nginx to route traffic from your domain.

Create an Nginx config file:

sudo nano /etc/nginx/sites-available/pixel-ai

Add the following configuration:

server {
    listen 80;   
    server_name your-domain.com;   
    location / { 
        proxy_pass http://localhost:3001;     
        proxy_http_version 1.1;     
        proxy_set_header Upgrade $http_upgrade;     
        proxy_set_header Connection 'upgrade';     
        proxy_set_header Host $host;     
        proxy_cache_bypass $http_upgrade;   
    } 
}

Enable and restart Nginx:

sudo ln -s /etc/nginx/sites-available/pixel-ai /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Your Pixel AI backend will now be available through your domain.

7. Enable SSL (HTTPS)

Secure your API with a free Let’s Encrypt SSL certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your-domain.com

Set up auto-renewal:

0 12 * * * /usr/bin/certbot renew --quiet
8. Setup Cron Job

Cron jobs are used to schedule automatic tasks on your server such as database maintenance, SSL renewal, queue processing, and more.

Type : 1 Internal Cron Jobs (node-cron)

Pixel AI includes internal cron jobs managed via the node-cron library. These tasks are handled directly within the Node.js process and include:

  • Automatic message status updates
  • System logs cleanup
  • Periodic database synchronization
  • Subscription status updates (Status Cron)
  • Trial expiry and user cleanup (Trial Cron)

Requirement: These run automatically as long as the PM2 process is active. No manual crontab entry is needed for these internal tasks.

Customization: If you want to change the schedule of internal cron jobs:

Go to your project cron job folder (e.g., /cron or /services/cron)

Locate the relevant file:

Status Cron (subscription expiry handling)

Trial Period Cron (trial cleanup and deletion)

Update the schedule inside the cron.schedule() method

Cron Schedule Format:

* * * * *  
| | | | |  
| | | | └───── Day of week (0 - 7) (Sunday is both 0 and 7)  
| | | └─────── Month (1 - 12)  
| | └───────── Day of month (1 - 31)  
| └─────────── Hour (0 - 23)  
└───────────── Minute (0 - 59)
Example:
0 0 * * * → Runs daily at 12:00 AM
0 1 * * * → Runs daily at 1:00 AM
Important: After modifying the cron schedule, you must restart your application for changes to take effect:
pm2 restart all
9. Testing and Verification

Visit your domain (e.g., https://your-domain.com/api) to confirm Pixel AI is running correctly.

Check logs with:

pm2 logs pixel-ai-backend

Verify API responses, media upload paths, authentication, and real-time events.

10. Maintenance & Updates

To update your Pixel AI backend in the future:

git pull origin main
npm install
pm2 restart pixel-ai-backend

It is recommended to monitor CPU, RAM, disk usage, database health, and system logs regularly.

Summary

By following this guide, your Pixel AI backend will be fully deployed on a VPS with a secure, scalable, and production-ready environment. This deployment method ensures reliable performance, smooth real-time services.

What's Next?

Let's get started — your journey with Pixel AI begins here!