Skip to Content
User ManualsDeployment Guide

Infrastructure & Deployment

This manual details the production environment, server configurations, and deployment procedures for the PlugZero Intelligence platform.


🏗️ 1. Production Architecture Overview

PlugZero utilizes a distributed architecture to handle high-performance ML and NLP workloads.

  • Frontend: Next.js (React) - Optimized for Vercel or a dedicated Node.js server.
  • Backend API: Django REST Framework (WSGI) - Hosted on Linux/Ubuntu.
  • Task Queue: Redis (Broker) + Celery (Background Workers).
  • Web Entry: Nginx (Reverse Proxy) + SSL (Let’s Encrypt).

⚙️ 2. Server Configuration (Backend)

The backend is configured to run under the system user theplug within /home/theplug/plugzero-api.

A. WSGI: Gunicorn Configuration

Managed as a systemd service.

# Location: /etc/systemd/system/gunicorn.service [Service] User=theplug Group=www-data WorkingDirectory=/home/theplug/plugzero-api ExecStart=/home/theplug/env/bin/gunicorn \ --workers 3 \ --bind unix:/run/gunicorn.sock \ plugzero_api.wsgi:application

B. Reverse Proxy: Nginx

Nginx proxies traffic from Port 80/443 to the Gunicorn socket.

# Location: /etc/nginx/sites-available/plugzero location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; }

C. Background Processing (Celery)

Two critical processes must be running:

  1. Worker: Executes the math (celery -A plugzero_api worker -l info).
  2. Beat: Handles scheduled SEO audits and system cleaning.

🔐 3. Environment Secrets Checklist

Ensure the .env file in the plugzero_api/ root contains these keys:

VariablePurpose
SECRET_KEYDjango security salt.
GOOGLE_API_KEYPowering Gemini 2.0 Flash Analysis.
MAILJET_API_KEYTransactional emails.
REDIS_URLTask broker connection string.
DATABASE_URLProduction database connection string.

🚀 4. Deployment SOP

Frontend (Next.js)

The plugzero-analytics repository is optimized for Vercel.

  • Build Command: npm run build
  • Output Directory: .next
  • Endpoint: Ensure NEXT_PUBLIC_BACKEND_API_URL points to the live API.

Update Workflow

Pull Latest Code

git pull origin main

Sync Environment

pip install -r requirements.txt

Migrate Database

python manage.py migrate

Restart Services

sudo systemctl restart gunicorn && sudo systemctl restart celery


🛡️ 5. Security Maintenance

  • SSL: Use certbot for automated certificate management: sudo certbot --nginx -d api.plugzero.app.
  • Backups: Daily snapshots of the db.sqlite3 file and the media/ directory must be sent to off-site storage.

Important: Ensure Port 6379 (Redis) is NOT exposed to the public internet. It should only be accessible to local services.


Last updated on