Last Updated: February 4, 2026
Version: 2.0 (Comprehensive)
Purpose: Production deployment validation with infrastructure and monitoring focus
This checklist ensures safe, reliable deployment of NIJA to production with comprehensive infrastructure setup and monitoring.
Use this checklist for:
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:
VAULT_ENCRYPTION_KEY - Vault encryption (generated above)JWT_SECRET_KEY - JWT signing (generated above)DATABASE_URL - Database connection stringPORT - Application port (default: 8000)ENVIRONMENT - Set to βproductionβLOG_LEVEL - Set to βINFOβ (or βWARNINGβ for quieter logs)Exchange API credentials (per user, stored encrypted):
β οΈ CRITICAL WARNINGS:
.gitignore excludes: .env, *.db, *.pem, __pycache__/, vault.db, users.dbSecurity 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
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"
vault, users, audit_log, login_historyInitialization commands:
# Initialize database
python3 init_database.py
# Verify tables exist
sqlite3 nija.db ".tables" # For SQLite
# OR
psql $DATABASE_URL -c "\dt" # For PostgreSQL
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
Run comprehensive test suite:
# MVP components test
python3 test_mvp_components.py
# Expected output:
# β
Tests Passed: 4/4 (100.0%)
# β Tests Failed: 0
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 testing:
# Run security-specific tests
python3 test_security_fixes.py
# CodeQL scan (if available)
codeql database analyze
Choose deployment platform and configure:
railway.json configuration validatedbash start.shPORT=5000 (or Railway-assigned)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
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
nija-productionKubernetes 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
requirements.txtTraditional 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
Health check endpoint:
/health endpoint returns 200 OKTest health endpoint:
curl https://your-domain.com/health
# Expected: {"status": "healthy", "timestamp": "...", "service": "NIJA FastAPI Backend", "version": "2.0.0"}
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
}
Key metrics to track:
Monitoring tools (choose one or more):
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!")
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"
External uptime monitoring:
Configure UptimeRobot (or similar):
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')"
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
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
Run basic smoke tests:
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
Monitor closely:
Metrics to watch:
Weekly review:
Monthly tasks:
Quarterly tasks:
Deployment is successful when:
If deployment fails:
git checkout
railway rollback
kubectl rollout undo deployment/nija -n nija-production
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
curl http://localhost:8000/health
python3 test_mvp_components.py
Deployment team:
External vendors:
Escalation:
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