ProspectIQ Deployment & Operations Guide
ProspectIQ Deployment & Operations Guide
Section titled “ProspectIQ Deployment & Operations Guide”Product: ProspectIQ - Automated Prospect Intelligence Platform Version: 2.0 Last Updated: 2026-01-21 Audience: Developers, DevOps, Technical Staff, Operations Team Owner: iSu Technologies
Overview
Section titled “Overview”ProspectIQ is an automated prospect intelligence platform that discovers, enriches, and scores business leads using AI-powered analysis. This guide covers server architecture, deployment procedures, and operational best practices for the production environment.
Production URL: https://prospectiq.isutech.co.za
GitHub Repository: https://github.com/gedeza/isutech-prospect-iq
Table of Contents
Section titled “Table of Contents”- Server Infrastructure
- Directory Architecture
- Service Configuration
- Deployment Procedures
- Database Operations
- Monitoring & Maintenance
- Troubleshooting Guide
- Emergency Procedures
Server Infrastructure
Section titled “Server Infrastructure”Production Server
Section titled “Production Server”| Component | Details |
|---|---|
| Provider | Hetzner Cloud |
| IP Address | 46.224.40.5 |
| Domain | prospectiq.isutech.co.za |
| Operating System | Ubuntu/Debian Linux |
| Database | PostgreSQL 15+ (prospect_iq) |
| Cache/Queue | Redis |
| Web Server | Nginx (reverse proxy + SSL) |
| SSL Provider | Let’s Encrypt (auto-renewal via Certbot) |
Tech Stack
Section titled “Tech Stack”Backend:
- Python 3.11+ with FastAPI
- PostgreSQL with SQLAlchemy ORM
- Celery + Redis for async tasks
- Anthropic Claude AI for pain point detection
Frontend:
- Next.js 14 with TypeScript
- Tailwind CSS for styling
- Recharts for data visualization
Access
Section titled “Access”# SSH Access (requires proper SSH key)ssh root@46.224.40.5
# Or via hostnamessh root@prospectiq.isutech.co.zaDirectory Architecture
Section titled “Directory Architecture”ProspectIQ uses a dual-directory system that separates development and production environments.
Development/Staging Directory
Section titled “Development/Staging Directory”Location: /root/projects/active/isutech-prospect-iq/
Purpose:
- Development and testing
- Version control (Git repository)
- Staging area before production deployment
Characteristics:
- ✅ Connected to GitHub:
git@github.com:gedeza/isutech-prospect-iq.git - ✅ Clean codebase without production artifacts
- ✅ All commits and version control happen here
- ✅ Branch:
main
Structure:
/root/projects/active/isutech-prospect-iq/├── backend/│ ├── app/ # FastAPI application│ │ ├── main.py # Application entry point│ │ ├── config/ # Configuration files│ │ ├── models/ # Database models│ │ ├── routers/ # API endpoints│ │ ├── enrichers/ # AI enrichment logic│ │ └── scrapers/ # Data collection│ ├── alembic/ # Database migrations│ └── requirements.txt # Python dependencies├── frontend/│ ├── app/ # Next.js pages│ ├── components/ # React components│ ├── lib/ # Utilities & API clients│ └── package.json # Node.js dependencies├── DOCS/ # Project documentation├── CLAUDE.md # Development context└── README.md # Project overviewProduction Directory
Section titled “Production Directory”Location: /home/prospectiq/prospectiq/
Purpose:
- Running the live production site
- Serving https://prospectiq.isutech.co.za
Characteristics:
- ⚠️ Not a git repository (file-based deployment)
- 🚀 Active production services
- 📦 Contains production artifacts, backups, logs
- 🔧 Systemd services run from here
Structure:
/home/prospectiq/prospectiq/├── backend/│ ├── app/ # Same structure as dev│ ├── alembic/ # Database migrations│ ├── venv/ # Python virtual environment (if used)│ └── .env # Production environment variables├── frontend/│ ├── .next/ # Next.js production build│ ├── app/ # Next.js pages│ ├── node_modules/ # Node dependencies│ └── .env.local # Frontend environment variables└── [production artifacts] # Backups, logs, experimental featuresWhy Two Directories?
Section titled “Why Two Directories?”| Aspect | Development | Production |
|---|---|---|
| Version Control | Yes (Git) | No (file-based) |
| Purpose | Testing, staging | Live site |
| Artifacts | Clean code only | Build artifacts, logs |
| Changes | Frequent commits | Controlled deployments |
| Services | Manual testing | Systemd services |
Service Configuration
Section titled “Service Configuration”Both services run as systemd services under the prospectiq user.
Backend Service (API)
Section titled “Backend Service (API)”Service Name: prospectiq-api.service
Service File: /etc/systemd/system/prospectiq-api.service
[Unit]Description=ProspectIQ FastAPI BackendAfter=network.target postgresql.service
[Service]Type=simpleUser=prospectiqWorkingDirectory=/home/prospectiq/prospectiq/backendEnvironment="PYTHONPATH=/home/prospectiq/prospectiq/backend"EnvironmentFile=/home/prospectiq/prospectiq/backend/.envExecStart=/usr/bin/python3 -m uvicorn app.main:app --host 0.0.0.0 --port 8002Restart=alwaysRestartSec=10
[Install]WantedBy=multi-user.targetDetails:
- Port: 8002 (internal)
- User: prospectiq
- Working Directory:
/home/prospectiq/prospectiq/backend - Process: Uvicorn ASGI server
Frontend Service
Section titled “Frontend Service”Service Name: prospectiq-frontend.service
Service File: /etc/systemd/system/prospectiq-frontend.service
[Unit]Description=ProspectIQ Next.js FrontendAfter=network.target
[Service]Type=simpleUser=prospectiqWorkingDirectory=/home/prospectiq/prospectiq/frontendEnvironment="NODE_ENV=production"ExecStart=/usr/bin/npm start -- -p 3002Restart=alwaysRestartSec=10
[Install]WantedBy=multi-user.targetDetails:
- Port: 3002 (internal)
- User: prospectiq
- Working Directory:
/home/prospectiq/prospectiq/frontend - Process: Next.js production server
Nginx Proxy Configuration
Section titled “Nginx Proxy Configuration”Domain: prospectiq.isutech.co.za SSL: Let’s Encrypt certificates
Routing:
https://prospectiq.isutech.co.za/api/*→ Backend (port 8002)https://prospectiq.isutech.co.za/*→ Frontend (port 3002)
Service Management Commands
Section titled “Service Management Commands”# Check status of both servicessystemctl status prospectiq-api prospectiq-frontend
# Start servicessystemctl start prospectiq-apisystemctl start prospectiq-frontend
# Stop servicessystemctl stop prospectiq-apisystemctl stop prospectiq-frontend
# Restart services (after deployment)systemctl restart prospectiq-api prospectiq-frontend
# Enable services on bootsystemctl enable prospectiq-api prospectiq-frontend
# View real-time logsjournalctl -u prospectiq-api -fjournalctl -u prospectiq-frontend -f
# View last 50 log linesjournalctl -u prospectiq-api -n 50 --no-pagerjournalctl -u prospectiq-frontend -n 50 --no-pagerDeployment Procedures
Section titled “Deployment Procedures”Standard Deployment Workflow
Section titled “Standard Deployment Workflow”Phase 1: Development
Section titled “Phase 1: Development”-
Navigate to development directory:
Terminal window cd /root/projects/active/isutech-prospect-iq/ -
Make your changes:
- Edit files as needed
- Test locally if possible
-
Commit to Git:
Terminal window git add .git commit -m "feat: description of changes"git push origin main
Phase 2: Deploy to Production
Section titled “Phase 2: Deploy to Production”-
Copy backend changes:
Terminal window cp -r /root/projects/active/isutech-prospect-iq/backend/app/* \/home/prospectiq/prospectiq/backend/app/ -
Update Python dependencies (if requirements.txt changed):
Terminal window cd /home/prospectiq/prospectiq/backendpip install -r requirements.txt -
Run database migrations (if schema changed):
Terminal window cd /home/prospectiq/prospectiq/backendalembic upgrade head -
Copy frontend changes:
Terminal window # First, rebuild in dev directorycd /root/projects/active/isutech-prospect-iq/frontendnpm run build# Then copy build to productioncp -r .next/* /home/prospectiq/prospectiq/frontend/.next/ -
Fix file ownership:
Terminal window chown -R prospectiq:prospectiq /home/prospectiq/prospectiq/ -
Restart services:
Terminal window systemctl restart prospectiq-apisystemctl restart prospectiq-frontend
Phase 3: Verification
Section titled “Phase 3: Verification”-
Check service status:
Terminal window systemctl status prospectiq-apisystemctl status prospectiq-frontend -
Check logs for errors:
Terminal window journalctl -u prospectiq-api -n 50 --no-pagerjournalctl -u prospectiq-frontend -n 50 --no-pager -
Test API health:
Terminal window curl https://prospectiq.isutech.co.za/api/health -
Verify website:
Terminal window curl -I https://prospectiq.isutech.co.za
Quick Deployment Script
Section titled “Quick Deployment Script”Save this as /root/deploy-prospectiq.sh:
#!/bin/bash# ProspectIQ Quick Deployment Script
set -e # Exit on error
echo "🚀 Starting ProspectIQ Deployment..."
# Backup (optional)BACKUP_DIR="/root/backups/prospectiq-$(date +%Y%m%d_%H%M%S)"echo "📦 Creating backup at $BACKUP_DIR"mkdir -p $BACKUP_DIRcp -r /home/prospectiq/prospectiq/backend/app $BACKUP_DIR/cp -r /home/prospectiq/prospectiq/frontend/.next $BACKUP_DIR/ 2>/dev/null || true
# Copy backendecho "📂 Deploying backend..."cp -r /root/projects/active/isutech-prospect-iq/backend/app/* \ /home/prospectiq/prospectiq/backend/app/
# Copy frontendecho "📂 Deploying frontend..."cp -r /root/projects/active/isutech-prospect-iq/frontend/.next/* \ /home/prospectiq/prospectiq/frontend/.next/ 2>/dev/null || true
# Fix permissionsecho "🔒 Fixing permissions..."chown -R prospectiq:prospectiq /home/prospectiq/prospectiq/
# Restart servicesecho "🔄 Restarting services..."systemctl restart prospectiq-apisystemctl restart prospectiq-frontend
# Wait for servicessleep 5
# Verifyecho "✅ Verifying deployment..."if systemctl is-active --quiet prospectiq-api && systemctl is-active --quiet prospectiq-frontend; then echo "✅ Deployment successful!" echo "🌐 Site: https://prospectiq.isutech.co.za" echo "📊 API Health: https://prospectiq.isutech.co.za/api/health"else echo "❌ Service verification failed! Check logs:" echo " journalctl -u prospectiq-api -n 20" echo " journalctl -u prospectiq-frontend -n 20" exit 1fiUsage:
chmod +x /root/deploy-prospectiq.sh/root/deploy-prospectiq.shDatabase Operations
Section titled “Database Operations”Database Information
Section titled “Database Information”Database Name: prospect_iq
DBMS: PostgreSQL 15+
Connection: Configured in /home/prospectiq/prospectiq/backend/.env
Running Migrations
Section titled “Running Migrations”IMPORTANT: Always run migrations from the production directory.
# Navigate to production backendcd /home/prospectiq/prospectiq/backend
# Check current migration versionalembic current
# View migration historyalembic history --verbose
# Upgrade to latest versionalembic upgrade head
# Downgrade one step (if needed)alembic downgrade -1
# Show pending migrationsalembic historyCreating New Migrations
Section titled “Creating New Migrations”If you modify database models:
# 1. Make changes to models in developmentcd /root/projects/active/isutech-prospect-iq/backend
# 2. Generate migrationalembic revision --autogenerate -m "description of changes"
# 3. Review generated migration file in alembic/versions/
# 4. Test in developmentalembic upgrade head
# 5. Deploy to production (copy migration file)cp alembic/versions/NEW_MIGRATION_FILE.py \ /home/prospectiq/prospectiq/backend/alembic/versions/
# 6. Run in productioncd /home/prospectiq/prospectiq/backendalembic upgrade headDatabase Backup & Restore
Section titled “Database Backup & Restore”Create Backup:
# Full database backupsudo -u postgres pg_dump prospect_iq > \ /root/backups/prospect_iq_$(date +%Y%m%d_%H%M%S).sql
# Compressed backupsudo -u postgres pg_dump prospect_iq | gzip > \ /root/backups/prospect_iq_$(date +%Y%m%d_%H%M%S).sql.gzRestore Backup:
# Stop services firstsystemctl stop prospectiq-api
# Restore databasesudo -u postgres psql prospect_iq < /root/backups/prospect_iq_20260121.sql
# Or restore compressedgunzip -c /root/backups/prospect_iq_20260121.sql.gz | \ sudo -u postgres psql prospect_iq
# Restart servicessystemctl start prospectiq-apiDatabase Access
Section titled “Database Access”# Connect as postgres usersudo -u postgres psql prospect_iq
# Or with specific userpsql -U prospect_user -d prospect_iq
# Common queriesprospect_iq=# SELECT COUNT(*) FROM companies;prospect_iq=# SELECT COUNT(*) FROM contacts;prospect_iq=# SELECT COUNT(*) FROM email_logs;prospect_iq=# \dt -- List all tablesprospect_iq=# \q -- ExitMonitoring & Maintenance
Section titled “Monitoring & Maintenance”Application Logs
Section titled “Application Logs”Backend Logs:
# Real-time logs (follow)journalctl -u prospectiq-api -f
# Last 100 linesjournalctl -u prospectiq-api -n 100
# Logs since 1 hour agojournalctl -u prospectiq-api --since "1 hour ago"
# Logs for todayjournalctl -u prospectiq-api --since today
# Error logs onlyjournalctl -u prospectiq-api -p errFrontend Logs:
# Real-time logsjournalctl -u prospectiq-frontend -f
# Last 100 linesjournalctl -u prospectiq-frontend -n 100Nginx Logs:
# Access logtail -f /var/log/nginx/access.log
# Error logtail -f /var/log/nginx/error.log
# Search for errorsgrep "error" /var/log/nginx/error.log | tail -20System Health Checks
Section titled “System Health Checks”# Check all ProspectIQ servicessystemctl status prospectiq-api prospectiq-frontend
# Check if services are runningsystemctl is-active prospectiq-api prospectiq-frontend
# Check disk spacedf -h
# Check memory usagefree -h
# Check CPU and processestophtop # If installed
# Check PostgreSQLsystemctl status postgresqlsudo -u postgres psql -c "SELECT version();"
# Check Redisredis-cli ping # Should return PONGSSL Certificate Status
Section titled “SSL Certificate Status”# Check certificate expirationcertbot certificates
# Test certificate renewalcertbot renew --dry-run
# Force renewal (if needed)certbot renew --force-renewalsystemctl reload nginxScheduled Maintenance Tasks
Section titled “Scheduled Maintenance Tasks”Weekly:
- Review application logs for errors
- Check disk space usage
- Verify backup integrity
Monthly:
- Update system packages:
apt update && apt upgrade - Review and archive old logs
- Database performance analysis
- SSL certificate expiration check
Quarterly:
- Security audit
- Performance optimization review
- Capacity planning assessment
Troubleshooting Guide
Section titled “Troubleshooting Guide”Issue: Services Won’t Start
Section titled “Issue: Services Won’t Start”Symptoms:
- Services fail immediately after starting
systemctl statusshows “failed” or “inactive”
Diagnosis:
# Check service statussystemctl status prospectiq-apisystemctl status prospectiq-frontend
# Check recent logsjournalctl -u prospectiq-api -n 50 --no-pager
# Check if ports are in usenetstat -tulpn | grep 8002netstat -tulpn | grep 3002Solutions:
- Check
.envfile configuration - Verify database connection
- Kill processes using the port:
kill -9 $(lsof -t -i:8002) - Check file permissions:
ls -la /home/prospectiq/prospectiq/ - Review Python/Node dependencies
Issue: 502 Bad Gateway
Section titled “Issue: 502 Bad Gateway”Symptoms:
- Website shows Nginx 502 error
- API calls fail
Diagnosis:
# Check if backend is runningsystemctl status prospectiq-apicurl http://127.0.0.1:8002/api/health
# Check if frontend is runningsystemctl status prospectiq-frontendcurl http://127.0.0.1:3002
# Check nginxnginx -tsystemctl status nginxSolutions:
- Restart backend/frontend services
- Check nginx configuration:
nginx -t - Restart nginx:
systemctl restart nginx - Verify internal ports (8002, 3002) are accessible
Issue: Database Connection Errors
Section titled “Issue: Database Connection Errors”Symptoms:
- Backend logs show “could not connect to database”
- API returns 500 errors
Diagnosis:
# Check PostgreSQL statussystemctl status postgresql
# Test database connectionpsql -U prospect_user -d prospect_iq -c "SELECT 1;"
# Check database existssudo -u postgres psql -l | grep prospect_iqSolutions:
- Verify
DATABASE_URLin.envfile - Ensure PostgreSQL is running:
systemctl start postgresql - Check database user credentials
- Review pg_hba.conf for authentication settings
Issue: High Memory/CPU Usage
Section titled “Issue: High Memory/CPU Usage”Symptoms:
- Server becomes slow or unresponsive
- Services crash due to resource exhaustion
Diagnosis:
# Check memory usagefree -htop
# Check CPU usagetophtop
# Find memory-hungry processesps aux --sort=-%mem | head -10
# Find CPU-hungry processesps aux --sort=-%cpu | head -10Solutions:
- Restart services to free memory
- Investigate application code for memory leaks
- Optimize database queries
- Consider server upgrade
- Implement caching strategies
Issue: SSL Certificate Expired
Section titled “Issue: SSL Certificate Expired”Symptoms:
- Browser shows “Certificate expired” warning
- HTTPS connection fails
Solutions:
# Check certificate statuscertbot certificates
# Renew certificatecertbot renew
# Reload nginxsystemctl reload nginx
# If auto-renewal is broken, force renewalcertbot renew --force-renewalEmergency Procedures
Section titled “Emergency Procedures”Emergency Rollback
Section titled “Emergency Rollback”If a deployment causes critical issues:
# 1. Stop servicessystemctl stop prospectiq-api prospectiq-frontend
# 2. Restore from backupBACKUP_DIR="/root/backups/prospectiq-TIMESTAMP"cp -r $BACKUP_DIR/app/* /home/prospectiq/prospectiq/backend/app/cp -r $BACKUP_DIR/.next/* /home/prospectiq/prospectiq/frontend/.next/
# 3. Fix permissionschown -R prospectiq:prospectiq /home/prospectiq/prospectiq/
# 4. Restart servicessystemctl start prospectiq-api prospectiq-frontend
# 5. Verifysystemctl status prospectiq-api prospectiq-frontendcurl https://prospectiq.isutech.co.za/api/healthDatabase Recovery
Section titled “Database Recovery”If database is corrupted or needs restoration:
# 1. Stop backendsystemctl stop prospectiq-api
# 2. Create backup of current state (just in case)sudo -u postgres pg_dump prospect_iq > \ /root/backups/prospect_iq_before_recovery_$(date +%Y%m%d_%H%M%S).sql
# 3. Drop and recreate databasesudo -u postgres dropdb prospect_iqsudo -u postgres createdb prospect_iq
# 4. Restore from backupsudo -u postgres psql prospect_iq < /root/backups/prospect_iq_LATEST.sql
# 5. Run migrations to ensure schema is currentcd /home/prospectiq/prospectiq/backendalembic upgrade head
# 6. Restart backendsystemctl start prospectiq-apiComplete Service Reset
Section titled “Complete Service Reset”If all else fails:
# 1. Stop all servicessystemctl stop prospectiq-api prospectiq-frontend nginx
# 2. Check for zombie processesps aux | grep -E "uvicorn|next" | grep -v grep# Kill any found processes
# 3. Clear any port conflictsfuser -k 8002/tcpfuser -k 3002/tcp
# 4. Restart PostgreSQLsystemctl restart postgresql
# 5. Start services in ordersystemctl start nginxsystemctl start prospectiq-apisleep 5systemctl start prospectiq-frontend
# 6. Verify all servicessystemctl status nginx prospectiq-api prospectiq-frontendcurl https://prospectiq.isutech.co.za/api/healthContact Information
Section titled “Contact Information”In case of emergencies:
- Technical Lead: Sibonga - support@isutech.co.za
- Product Owner: Nhlanhla Mnyandu - nhlanhla@isutech.co.za
- Server Provider: Hetzner Cloud Support
Additional Resources
Section titled “Additional Resources”- Project Repository: https://github.com/gedeza/isutech-prospect-iq
- Production Dashboard: https://prospectiq.isutech.co.za/dashboard
- API Documentation: https://prospectiq.isutech.co.za/api/docs
- Central Knowledge Hub: https://docs.isutech.co.za
- Technical Architecture: See project DOCS/technical/ARCHITECTURE.md
Document History
Section titled “Document History”| Date | Version | Changes | Author |
|---|---|---|---|
| 2026-01-21 | 1.0 | Initial deployment guide for central knowledge hub | System |
ProspectIQ Deployment & Operations Guide v1.0 iSu Technologies © 2026 For internal use only - Confidential