Nija

πŸš€ NIJA Deploy Checklist - Infrastructure & Monitoring

Last Updated: February 4, 2026
Version: 2.0 (Comprehensive)
Purpose: Production deployment validation with infrastructure and monitoring focus


πŸ“‹ Overview

This checklist ensures safe, reliable deployment of NIJA to production with comprehensive infrastructure setup and monitoring.

Use this checklist for:


πŸ” Pre-Deployment: Security & Credentials

βœ… Environment Variables & Secrets

Critical secrets that MUST be set:

# Generate encryption keys (run these commands)
python3 -c "from cryptography.fernet import Fernet; print(f'VAULT_ENCRYPTION_KEY={Fernet.generate_key().decode()}')"
python3 -c "import secrets; print(f'JWT_SECRET_KEY={secrets.token_hex(32)}')"

Required environment variables:

Exchange API credentials (per user, stored encrypted):

⚠️ CRITICAL WARNINGS:

βœ… Security Validation

Security scan commands:

# Run security scanner
python3 -m bandit -r bot/ -ll

# Check for secrets in code
detect-secrets scan --baseline .secrets.baseline

# Validate .gitignore effectiveness
git status --ignored

πŸ—„οΈ Database Setup & Validation

βœ… Database Configuration

For Production (PostgreSQL recommended):

export DATABASE_URL="postgresql://user:password@host:5432/nija_production"

For Development/Testing (SQLite acceptable):

export DATABASE_URL="sqlite:///nija.db"

βœ… Database Initialization

Initialization commands:

# Initialize database
python3 init_database.py

# Verify tables exist
sqlite3 nija.db ".tables"  # For SQLite
# OR
psql $DATABASE_URL -c "\dt"  # For PostgreSQL

βœ… Database Backups

Backup commands:

# SQLite backup
cp vault.db vault.db.backup.$(date +%Y%m%d-%H%M%S)
cp users.db users.db.backup.$(date +%Y%m%d-%H%M%S)

# PostgreSQL backup
pg_dump $DATABASE_URL > nija_backup_$(date +%Y%m%d-%H%M%S).sql

πŸ§ͺ Pre-Deployment Testing

βœ… Component Tests

Run comprehensive test suite:

# MVP components test
python3 test_mvp_components.py

# Expected output:
# βœ… Tests Passed: 4/4 (100.0%)
# ❌ Tests Failed: 0

βœ… Integration Tests

Integration test commands:

# Test vault functionality
python3 -c "from vault.secure_api_vault import SecureAPIVault; v = SecureAPIVault(); print('βœ… Vault OK')"

# Test authentication
python3 test_authentication.py  # If test file exists

# Test API health
curl http://localhost:8000/health
# Expected: {"status": "healthy", ...}

βœ… Security Tests

Security testing:

# Run security-specific tests
python3 test_security_fixes.py

# CodeQL scan (if available)
codeql database analyze

πŸ—οΈ Infrastructure Setup

βœ… Platform Configuration

Choose deployment platform and configure:

Option 1: Railway

Railway deployment:

# Install Railway CLI
npm install -g @railway/cli

# Login
railway login

# Link to project
railway link

# Set environment variables
railway variables set VAULT_ENCRYPTION_KEY=<key>
railway variables set JWT_SECRET_KEY=<key>

# Deploy
railway up

Option 2: Docker

Docker deployment:

# Build image
docker build -t nija-production:latest .

# Run with environment variables
docker run -d \
  --name nija-app \
  -p 8000:8000 \
  -e VAULT_ENCRYPTION_KEY=$VAULT_ENCRYPTION_KEY \
  -e JWT_SECRET_KEY=$JWT_SECRET_KEY \
  -e DATABASE_URL=$DATABASE_URL \
  -v $(pwd)/data:/app/data \
  --restart unless-stopped \
  nija-production:latest

# Verify container running
docker ps | grep nija-app

Option 3: Kubernetes

Kubernetes deployment:

# Create namespace
kubectl create namespace nija-production

# Create secrets
kubectl create secret generic nija-secrets \
  --from-literal=VAULT_ENCRYPTION_KEY=$VAULT_ENCRYPTION_KEY \
  --from-literal=JWT_SECRET_KEY=$JWT_SECRET_KEY \
  -n nija-production

# Apply manifests
kubectl apply -f k8s/deployment.yaml -n nija-production
kubectl apply -f k8s/service.yaml -n nija-production

# Verify deployment
kubectl get pods -n nija-production

Option 4: Traditional Server (VPS/Cloud VM)

Traditional server setup:

# Install dependencies
sudo apt update
sudo apt install -y python3.11 python3-pip nginx certbot

# Install Python packages
pip3 install -r requirements.txt

# Create systemd service
sudo nano /etc/systemd/system/nija.service

Systemd service file example:

[Unit]
Description=NIJA Trading Platform
After=network.target

[Service]
User=nija
WorkingDirectory=/opt/nija
Environment="VAULT_ENCRYPTION_KEY=<your-key>"
Environment="JWT_SECRET_KEY=<your-key>"
Environment="DATABASE_URL=postgresql://..."
ExecStart=/usr/bin/gunicorn fastapi_backend:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
# Enable and start service
sudo systemctl enable nija
sudo systemctl start nija
sudo systemctl status nija

βœ… Network & DNS


πŸ“Š Monitoring & Observability

βœ… Application Monitoring

Health check endpoint:

Test health endpoint:

curl https://your-domain.com/health
# Expected: {"status": "healthy", "timestamp": "...", "service": "NIJA FastAPI Backend", "version": "2.0.0"}

βœ… Logging Configuration

Log levels and destinations:

Log locations:

# Application logs
/var/log/nija/application.log

# Error logs
/var/log/nija/error.log

# Audit logs (vault operations)
SELECT * FROM audit_log ORDER BY timestamp DESC LIMIT 100;

# Login history
SELECT * FROM login_history WHERE timestamp > datetime('now', '-1 day');

Configure log rotation (logrotate):

sudo nano /etc/logrotate.d/nija

Logrotate config:

/var/log/nija/*.log {
    daily
    rotate 30
    compress
    delaycompress
    notifempty
    create 0640 nija nija
    sharedscripts
    postrotate
        systemctl reload nija
    endscript
}

βœ… Performance Monitoring

Key metrics to track:

Monitoring tools (choose one or more):

βœ… Trading-Specific Monitoring

Critical trading metrics:

Custom monitoring script:

# Example: Monitor vault operations
from vault.secure_api_vault import SecureAPIVault

vault = SecureAPIVault()
recent_operations = vault.get_audit_log(limit=100)
failed_ops = [op for op in recent_operations if op['status'] == 'failed']

if len(failed_ops) > 10:
    alert("High vault failure rate detected!")

βœ… Alerting Configuration

Set up alerts for:

Critical (immediate response required):

Warning (investigate within hours):

Info (review daily):

Alert channels:

Example alert configuration (Prometheus Alertmanager):

groups:
  - name: nija_alerts
    rules:
      - alert: ServiceDown
        expr: up{job="nija"} == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "NIJA service is down"
          
      - alert: HighErrorRate
        expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High error rate detected"

βœ… Uptime Monitoring

External uptime monitoring:

Configure UptimeRobot (or similar):


🧯 Disaster Recovery & Backup

βœ… Backup Strategy

What to backup:

Backup frequency:

Backup retention:

Backup locations:

Backup verification:

# Test database restore
# 1. Create test backup
cp vault.db vault.db.test.backup

# 2. Restore to test environment
cp vault.db.test.backup vault_test.db

# 3. Verify data integrity
python3 -c "from vault.secure_api_vault import SecureAPIVault; v = SecureAPIVault('vault_test.db'); print('βœ… Restore successful' if v.get_audit_log() else '❌ Restore failed')"

βœ… Recovery Procedures

Document recovery steps:

Recovery procedure example:

# 1. Stop service
systemctl stop nija

# 2. Restore database
cp /backups/vault.db.backup.20260204 vault.db
cp /backups/users.db.backup.20260204 users.db

# 3. Verify encryption key
export VAULT_ENCRYPTION_KEY=<from-secure-storage>

# 4. Test database
python3 test_mvp_components.py

# 5. Restart service
systemctl start nija

# 6. Verify health
curl http://localhost:8000/health

πŸš€ Deployment Execution

βœ… Deployment Steps

1. Final pre-deployment checks:

2. Deploy application:

# Pull latest code
git pull origin main

# Install/update dependencies
pip install -r requirements.txt

# Run database migrations (if any)
# alembic upgrade head

# Restart service
systemctl restart nija  # Systemd
# OR
railway up  # Railway
# OR
kubectl rollout restart deployment/nija -n nija-production  # Kubernetes
# OR
docker restart nija-app  # Docker

3. Post-deployment verification:

Post-deployment test commands:

# 1. Health check
curl https://your-domain.com/health

# 2. Test registration
curl -X POST https://your-domain.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"TestPass123!","subscription_tier":"basic"}'

# 3. Test login
curl -X POST https://your-domain.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"TestPass123!"}'

# 4. Check logs for errors
tail -f /var/log/nija/error.log
# OR
railway logs  # Railway
# OR
kubectl logs -f deployment/nija -n nija-production  # Kubernetes

βœ… Smoke Testing

Run basic smoke tests:

βœ… Production Traffic Cutover

If migrating from existing deployment:

Canary deployment (recommended):

# Kubernetes example
kubectl set image deployment/nija nija=nija:v2.0.0 -n nija-production
kubectl rollout pause deployment/nija -n nija-production  # Pause at 10%
# Monitor metrics for 15 minutes
kubectl rollout resume deployment/nija -n nija-production  # Continue rollout

πŸ“‹ Post-Deployment Monitoring

βœ… First 24 Hours

Monitor closely:

Metrics to watch:

βœ… First Week

Weekly review:

βœ… Ongoing Maintenance

Monthly tasks:

Quarterly tasks:


🎯 Success Criteria

Deployment is successful when:


🚨 Rollback Procedure

If deployment fails:

  1. Immediate rollback: ```bash

    Systemd

    git checkout systemctl restart nija

Railway

railway rollback

Kubernetes

kubectl rollout undo deployment/nija -n nija-production

Docker

docker stop nija-app docker run -d –name nija-app nija-production:previous-version


2. **Restore database (if needed):**
```bash
systemctl stop nija
cp /backups/vault.db.backup.<timestamp> vault.db
cp /backups/users.db.backup.<timestamp> users.db
systemctl start nija
  1. Verify rollback:
    curl http://localhost:8000/health
    python3 test_mvp_components.py
    
  2. Post-rollback:
    • Incident report created
    • Root cause analysis performed
    • Fix implemented
    • Re-test in staging
    • Schedule new deployment

πŸ“ž Emergency Contacts

Deployment team:

External vendors:

Escalation:


βœ… Final Checklist Summary

Before going live, verify:

Production is ready when ALL checkboxes are checked.



Document Version: 2.0
Last Updated: February 4, 2026
Maintainer: NIJA DevOps Team


Questions or Issues?
πŸ“§ Email: devops@nija.app
πŸ“– Docs: See related documentation above
πŸ› Issues: Report to development team