# 🚀 Quick Start - Proxmox Deployment

## Prerequisites Checklist

- [ ] Proxmox server with Ubuntu VM/Container
- [ ] Domain name pointing to server IP
- [ ] SSH access to server
- [ ] Application files (cloned or uploaded)

## Quick Deployment Steps

### 1. Access Your Server

```bash
# SSH into your Proxmox VM/Container
ssh root@your-server-ip
```

### 2. Run Automated Setup

```bash
# Clone or upload your repository
cd /opt
git clone <your-repo-url> institutional_trader
# OR upload files manually

# Run deployment script
cd institutional_trader
chmod +x deploy.sh
sudo bash deploy.sh
```

### 3. Configure Environment Variables

**Backend** (`/opt/institutional_trader/backend/.env`):
```env
NODE_ENV=production
PORT=3000
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_KEY=your_service_key
DATABASE_URL=your_database_url
CORS_ORIGIN=https://yourdomain.com
JWT_SECRET=your_secret_key_32_chars_min
```

**Frontend** (`/opt/institutional_trader/frontend/.env.production`):
```env
VITE_API_URL=https://api.yourdomain.com
VITE_WS_URL=wss://api.yourdomain.com
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_anon_key
```

### 4. Create Systemd Services

```bash
# Copy service files from PROXMOX_DEPLOYMENT.md section 6
# Or create manually:

# Backend service
sudo nano /etc/systemd/system/institutional-trader-backend.service
# (Paste configuration from deployment guide)

# Python service (if using)
sudo nano /etc/systemd/system/institutional-trader-python.service
# (Paste configuration from deployment guide)

# Enable and start
sudo systemctl daemon-reload
sudo systemctl enable institutional-trader-backend
sudo systemctl start institutional-trader-backend
```

### 5. Configure Nginx

```bash
# Copy nginx config from PROXMOX_DEPLOYMENT.md section 7
sudo nano /etc/nginx/sites-available/institutional-trader
# (Paste and customize configuration)

# Enable site
sudo ln -s /etc/nginx/sites-available/institutional-trader /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```

### 6. Set Up SSL

```bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com -d api.yourdomain.com
```

### 7. Set Up Database Access for Friend

**Option A: Supabase (Easiest)**
- Go to Supabase Dashboard > Settings > Team
- Invite your friend via email
- Share connection details

**Option B: PostgreSQL User**
```bash
# Run the SQL script
cd /opt/institutional_trader/backend/database
sudo -u postgres psql institutional_trader < setup_friend_access.sql
# Edit the script first to set username/password!
```

## Verify Deployment

```bash
# Check services
sudo systemctl status institutional-trader-backend
sudo systemctl status nginx

# Test health endpoint
curl https://api.yourdomain.com/health

# Check logs
sudo journalctl -u institutional-trader-backend -f
```

## Common Commands

```bash
# Restart services
sudo systemctl restart institutional-trader-backend
sudo systemctl restart institutional-trader-python
sudo systemctl reload nginx

# View logs
sudo journalctl -u institutional-trader-* -f

# Update application
cd /opt/institutional_trader
git pull
cd backend && npm install --production
cd ../frontend && npm run build
sudo systemctl restart institutional-trader-backend
```

## Need Help?

See the full guide: **PROXMOX_DEPLOYMENT.md**

