Complete guide to deploying the QueryMind-SQL system on AWS EC2 (Ubuntu 22.04).
- AWS account with EC2 access
- An OpenAI API key with GPT-4o access
- Olist dataset CSVs (from Kaggle)
- SSH key pair for EC2
- Open the EC2 console → Launch Instance
- AMI: Ubuntu Server 22.04 LTS (64-bit x86)
- Instance type:
t3.mediumminimum (2 vCPU, 4 GB RAM) — LangChain + ChromaDB need memory - Storage: 20 GB gp3
- Security Group rules:
Type Port Source SSH 22 Your IP HTTP 80 0.0.0.0/0 - Select your SSH key pair → Launch
- Note the Public IPv4 address
ssh -i ~/.ssh/your-key.pem ubuntu@<PUBLIC_IP>
sudo apt-get install -y git
git clone https://github.com/ridash2005/QueryMind-SQL.git /opt/querymind-sql
cd /opt/querymind-sqlsudo bash infra/setup.shThis installs Python 3.11, Node.js 20, nginx, and system dependencies.
export OPENAI_API_KEY="sk-your-actual-key-here"
export APP_DIR=/opt/querymind-sql
sudo bash infra/configure_env.shVerify the .env was created with correct permissions:
ls -la /opt/querymind-sql/.env # Should show -rw------- (600)Upload the CSV files from your local machine to the EC2 instance:
# From your LOCAL machine:
scp -i ~/.ssh/your-key.pem \
olist_orders_dataset.csv \
olist_order_items_dataset.csv \
olist_customers_dataset.csv \
olist_products_dataset.csv \
olist_sellers_dataset.csv \
olist_geolocation_dataset.csv \
olist_order_reviews_dataset.csv \
product_category_name_translation.csv \
ubuntu@<PUBLIC_IP>:/opt/querymind-sql/data/raw/Or set KAGGLE_AUTO_DOWNLOAD=1 in .env and install the Kaggle CLI:
pip install kaggle
# Place ~/.kaggle/kaggle.json (from kaggle.com → Account → API)cd /opt/querymind-sql
bash infra/install_app.shThis will:
- Create Python venv and install packages
- Create DB schema
- Seed the Olist data (takes ~5 min)
- Build the ChromaDB vector index
- Compile the React frontend
sudo cp infra/texttosql.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable texttosql # Start on boot
sudo systemctl start texttosqlCheck it's running:
sudo systemctl status texttosql
sudo journalctl -u texttosql -f # Follow logssudo cp infra/nginx.conf /etc/nginx/sites-available/texttosql
sudo ln -sf /etc/nginx/sites-available/texttosql /etc/nginx/sites-enabled/texttosql
sudo rm -f /etc/nginx/sites-enabled/default # Remove default placeholder
sudo nginx -t # Test config
sudo systemctl reload nginxbash infra/verify.shExpected output:
✅ texttosql.service is ACTIVE
✅ /api/health returned HTTP 200
✅ nginx is ACTIVE
✅ nginx config syntax OK
✅ Public endpoint http://X.X.X.X/api/health returned HTTP 200
✅ All checks passed. Stack is healthy.
Open your browser at http://<PUBLIC_IP>/
- Frontend: React app with schema explorer and chat interface
- API docs:
http://<PUBLIC_IP>/api/docs(FastAPI Swagger UI) - Health check:
http://<PUBLIC_IP>/api/health
cd /opt/querymind-sql
git pull origin main
source venv/bin/activate && pip install -r requirements.txt
cd frontend && npm ci && npm run build && cd ..
sudo systemctl restart texttosql# Live application logs
sudo journalctl -u texttosql -f
# nginx access logs
sudo tail -f /var/log/nginx/access.log
# Query history (in SQLite)
source venv/bin/activate && source .env
python -c "
from model.database import get_engine
from sqlalchemy import text
with get_engine().connect() as c:
rows = c.execute(text('SELECT question, latency_ms, created_at FROM query_log ORDER BY created_at DESC LIMIT 20')).fetchall()
for r in rows: print(r)
"If you encounter any issues during or after deployment (such as a 502 Bad Gateway, blank page, timeouts, or permission errors), please refer to our comprehensive Troubleshooting Guide for diagnostics and step-by-step resolution.