Skip to main content

Launch an EC2 instance

  1. Go to AWS EC2 → Launch Instance
  2. Choose Ubuntu 22.04 LTS (free tier eligible: t2.micro / t3.micro)
  3. Add security group rules: allow inbound on port 22 (SSH) and 443 (HTTPS)
  4. Download your key pair

Initial server setup

ssh -i your-key.pem ubuntu@your-ec2-ip

# Update and install dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install python3.11 python3.11-venv nginx certbot python3-certbot-nginx -y

Deploy the backend

git clone https://github.com/rmurarishetti/vantage.git
cd vantage/backend

python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Create .env with your credentials
cp .env.example .env
nano .env

Configure systemd

Create /etc/systemd/system/vantage.service:
[Unit]
Description=Vantage Wealth FastAPI Backend
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/vantage/backend
Environment="PATH=/home/ubuntu/vantage/backend/venv/bin"
ExecStart=/home/ubuntu/vantage/backend/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --workers 2
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
sudo systemctl enable vantage
sudo systemctl start vantage
sudo systemctl status vantage

Configure nginx + HTTPS

# /etc/nginx/sites-available/vantage
server {
    server_name api.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        # Required for SSE streaming
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 300s;
    }
}
sudo ln -s /etc/nginx/sites-available/vantage /etc/nginx/sites-enabled/
sudo certbot --nginx -d api.yourdomain.com
sudo systemctl reload nginx
Update your API_BASE_URL in .env.json to https://api.yourdomain.com.