Self-Hosted Deployment
Deploy CognitiveX on your own infrastructure for maximum control and data privacy.
Requirements
- Ubuntu 20.04+ or similar Linux distribution
- 4GB+ RAM (8GB+ recommended)
- PostgreSQL 14+ with pgvector
- Redis 6+
- Node.js 18+
- Domain with SSL certificate
Installation
1. Install Dependencies
bash
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
# Install PostgreSQL with pgvector
sudo apt install -y postgresql-14
sudo apt install -y postgresql-14-pgvector
# Install Redis
sudo apt install -y redis-server2. Clone Repository
bash
git clone https://github.com/cognitivex/platform.git
cd platform3. Configure Environment
.envbash
NODE_ENV=production
PORT=3000
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/cognitivex
# Redis
REDIS_URL=redis://localhost:6379
# API Keys
OPENAI_API_KEY=your_key
ANTHROPIC_API_KEY=your_key
# Security
JWT_SECRET=your_secure_random_string
ENCRYPTION_KEY=your_encryption_key4. Run Migrations
bash
npm install
npm run migration:run5. Start Application
bash
npm run build
npm run start:prodProcess Management with PM2
bash
# Install PM2
npm install -g pm2
# Start application
pm2 start npm --name "cognitivex" -- run start:prod
# Save process list
pm2 save
# Setup startup script
pm2 startupNginx Reverse Proxy
/etc/nginx/sites-available/cognitivexnginx
server {
listen 80;
server_name api.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}SSL with Let's Encrypt
bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d api.yourdomain.comBest Practices
- • Use PM2 or systemd for process management
- • Set up automated backups for PostgreSQL
- • Configure log rotation
- • Enable firewall (ufw)
- • Use strong passwords and keys
- • Regular security updates
- • Monitor system resources
- • Set up SSL/TLS certificates