Skip to content

Infrastructure Overview

Architecture

Your Mac (local dev)

192.168.1.3 (big-buddy) - Hypervisor host
    ├── NPM (Nginx Proxy Manager) - Reverse proxy for all domains
    └── libvirt VMs (192.168.122.0/24 network)
        ├── backend-test (192.168.122.50) - TEST environment
        └── backend-alpha (192.168.122.154) - PRODUCTION environment

Environments

🧪 TEST (backend-test)

  • VM IP: 192.168.122.50
  • Domain: https://backend-dev.dmva.acebox.eu
  • Backend: PM2 process dm-voice-agent-alpha
  • Database: MariaDB 10.11.14 - voiceagent_alpha (shared with Alpha)
  • ENV Mode: NODE_ENV=development
  • Port: 3001
  • User: gabby
  • SSH: ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50"
  • Deployment: DEPLOY-DEV.md

🚀 PRODUCTION (backend-alpha)

  • VM IP: 192.168.122.154
  • Domain: https://backend-alpha.dmva.acebox.eu
  • Backend: PM2 process dm-voice-agent-alpha
  • Database: MariaDB 10.11.14 - voiceagent_alpha
  • ENV Mode: NODE_ENV=production
  • Port: 3001
  • User: gabby
  • SSH: ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154"
  • Deployment: DEPLOY-ALPHA.md

🖥️ HOST (big-buddy)

  • IP: 192.168.1.3
  • Services:
    • NPM (Nginx Proxy Manager) - Port 81
    • libvirt/KVM hypervisor
    • Port forwarding for VM access
  • SSH: ssh root@192.168.1.3

Quick SSH Access

Method 1: SSH Agent Forwarding (current)

bash
# TEST environment
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50"

# PRODUCTION environment
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154"

Add to ~/.ssh/config:

Host big-buddy
    HostName 192.168.1.3
    User root
    ForwardAgent yes

Host backend-test
    HostName 192.168.122.50
    User gabby
    ProxyJump big-buddy
    ForwardAgent yes

Host backend-alpha
    HostName 192.168.122.154
    User gabby
    ProxyJump big-buddy
    ForwardAgent yes

Then simply:

bash
ssh backend-test    # TEST
ssh backend-alpha   # PRODUCTION

Deployment Workflow

1. Local Development

bash
cd /Users/gabby/git/AI-assistant/dm-voice-agent
git checkout 001-billing-system
# Make changes to backend/src/...

2. Deploy to TEST

bash
# Sync file
cat backend/src/path/to/file.ts | ssh -A root@192.168.1.3 \
  "ssh gabby@192.168.122.50 'cat > /opt/dm-voice-agent-alpha/src/path/to/file.ts'"

# Build and restart
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 \
  'cd /opt/dm-voice-agent-alpha && npm run build && pm2 restart dm-voice-agent-alpha'"

# Check logs
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'pm2 logs --lines 50'"

3. Test on TEST environment

bash
curl https://backend-dev.dmva.acebox.eu/health

4. Deploy to PRODUCTION

bash
# Same process but for backend-alpha (192.168.122.154)
cat backend/src/path/to/file.ts | ssh -A root@192.168.1.3 \
  "ssh gabby@192.168.122.154 'cat > /opt/dm-voice-agent-alpha/src/path/to/file.ts'"

ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 \
  'cd /opt/dm-voice-agent-alpha && npm run build && pm2 restart dm-voice-agent-alpha'"

Key Directories

TEST (192.168.122.50)

/opt/dm-voice-agent-alpha/
├── src/              # TypeScript source
├── dist/             # Compiled JavaScript
├── public/           # Static files (admin.html)
├── uploads/          # User uploads
├── storage/          # Application storage
├── .env              # Environment config (NODE_ENV=development)
└── node_modules/     # Dependencies

PRODUCTION (192.168.122.154)

/opt/dm-voice-agent-alpha/
├── src/              # TypeScript source
├── dist/             # Compiled JavaScript
├── public/           # Static files (admin.html)
├── uploads/          # User uploads
├── storage/          # Application storage
│   └── invoices/     # Generated invoices
├── .env              # Environment config (NODE_ENV=production)
└── node_modules/     # Dependencies

Database

Shared Database:

  • Host: localhost (on each VM)
  • Type: MariaDB 10.11.14
  • Database: voiceagent_alpha
  • User: voiceagent
  • Password: AlphaSecurePass2024!

Note: Both TEST and PRODUCTION currently share the same database name. Consider creating voiceagent_test for TEST environment.

URLs & Endpoints

EnvironmentDomainAdmin PanelHealth Check
TESThttps://backend-dev.dmva.acebox.eu/admin.html/health
PRODUCTIONhttps://backend-alpha.dmva.acebox.eu/admin.html/health

Admin Panel Features (NEW - 2025-11-05)

Both environments have updated admin panel with:

  • 🔄 Load Current Values button to fetch ENV variables
  • Dynamic field generation from API
  • Grouping by prefix (TWILIO_, ELEVENLABS_, META_, N8N_)
  • 🔒 Sensitive field indicators
  • Masked values for passwords/secrets (••••••••)

Access: https://<domain>/admin.html → Settings tab

PM2 Process Management

Both VMs run the same PM2 process:

bash
pm2 list                    # List all processes
pm2 logs dm-voice-agent-alpha --lines 100
pm2 restart dm-voice-agent-alpha
pm2 monit                   # Real-time monitoring
pm2 info dm-voice-agent-alpha

Monitoring & Logs

Check Service Status

bash
# TEST
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'pm2 status'"

# PRODUCTION
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 'pm2 status'"

View Logs

bash
# TEST - last 100 lines
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'pm2 logs dm-voice-agent-alpha --lines 100 --nostream'"

# PRODUCTION - follow logs
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 'pm2 logs dm-voice-agent-alpha --lines 50'"

Database Access

bash
# TEST
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'mysql -u voiceagent -p\"AlphaSecurePass2024!\" voiceagent_alpha'"

# PRODUCTION
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 'mysql -u voiceagent -p\"AlphaSecurePass2024!\" voiceagent_alpha'"

Troubleshooting

Can't connect to VM

bash
# Check if VM is running
ssh root@192.168.1.3 "virsh list --all"

# Check IP addresses
ssh root@192.168.1.3 "virsh net-dhcp-leases default"

# Start VM if stopped
ssh root@192.168.1.3 "virsh start backend-test"

Backend not responding

bash
# Check PM2 process
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'pm2 status'"

# Check if port 3001 is listening
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'netstat -tlnp | grep 3001'"

# Restart backend
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 'pm2 restart dm-voice-agent-alpha'"

502 Bad Gateway

  • Check NPM configuration on host (192.168.1.3:81)
  • Verify backend is running on port 3001
  • Check NPM logs

VM Management

bash
# List all VMs
ssh root@192.168.1.3 "virsh list --all"

# Start VM
ssh root@192.168.1.3 "virsh start backend-test"

# Stop VM (graceful)
ssh root@192.168.1.3 "virsh shutdown backend-test"

# Force stop
ssh root@192.168.1.3 "virsh destroy backend-test"

# Reboot VM
ssh root@192.168.1.3 "virsh reboot backend-test"

# VM info
ssh root@192.168.1.3 "virsh dominfo backend-test"

Backup & Recovery

Database Backup

bash
# Backup TEST
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.50 \
  'mysqldump -u voiceagent -p\"AlphaSecurePass2024!\" voiceagent_alpha > /tmp/backup_test_\$(date +%Y%m%d).sql'"

# Backup PRODUCTION
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 \
  'mysqldump -u voiceagent -p\"AlphaSecurePass2024!\" voiceagent_alpha > /tmp/backup_prod_\$(date +%Y%m%d).sql'"

Code Rollback

bash
# Stop service
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 'pm2 stop dm-voice-agent-alpha'"

# Restore from git
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 \
  'cd /opt/dm-voice-agent-alpha && git checkout <commit-hash>'"

# Rebuild and restart
ssh -A root@192.168.1.3 "ssh gabby@192.168.122.154 \
  'cd /opt/dm-voice-agent-alpha && npm run build && pm2 restart dm-voice-agent-alpha'"

Security Notes

  • SSH key-based authentication only
  • SSH agent forwarding required for VM access
  • Sensitive ENV variables masked in admin UI
  • MariaDB bound to localhost only
  • HTTPS via NPM with Let's Encrypt certificates

Status (2025-11-05)

TEST (backend-test):

  • PM2 running
  • NODE_ENV=development
  • Admin panel with dynamic ENV loading deployed

PRODUCTION (backend-alpha):

  • PM2 running
  • NODE_ENV=production
  • Admin panel with dynamic ENV loading deployed

Docker (192.168.1.3):

  • Removed (was unhealthy, no longer needed)

Twinlix platform documentation.