Skip to content

vaibhav17sharma/TextToSQL

Repository files navigation

Text to SQL Converter

AI/ML powered application that converts natural language text to SQL queries.

📸 Screenshots

Landing Page Welcome to Text to SQL Converter

Main Interface Convert natural language to SQL queries with ease

Database Schema Database schema visualization

Query Results Real-time SQL generation and execution

Session Management Manage your query sessions

🎥 Demo Video

Demo Video

Watch the Text to SQL converter in action

Tech Stack

  • Frontend: React
  • Backend: FastAPI
  • Database: MySQL, PostgreSQL & SQLite (user-provided)
  • AI/ML: Natural language processing for SQL generation
  • Model: mradermacher/natural-sql-7b-i1-GGUF

✨ Features

  • Convert plain English to SQL queries
  • Real-time query generation
  • Clean, intuitive interface
  • Multi-database support
  • One-click sample database loading

🚀 Deployment

Quick Start

Development

# Start development environment
docker-compose up --build

Production

# Run deployment script (recommended)
./deploy.sh

# Or use make commands
make prod  # Docker deployment
make pm2-start  # PM2 deployment

Access the application at http://localhost:3000

Deployment Options

🐳 Docker (Recommended)

Advantages: Isolated environment, easy scaling

# Production
make prod

# View logs
make logs

# Stop services
make stop

Access:

⚡ PM2 Process Manager

Advantages: Process management, auto-restart, load balancing

# Prerequisites
npm install -g pm2 serve pnpm

# Deploy
make pm2-start

# Manage
pm2 logs
pm2 status

🔧 Manual Setup

# Backend
cd backend
pip install -r requirements.txt
python install_llama.py

# Frontend
cd frontend
pnpm install
pnpm build

# Start services
cd backend && uvicorn app.main:app --host 0.0.0.0 --port 8000 &
cd frontend && serve -s dist -l 3000 &

Environment Configuration

Production Variables

# Backend
ENV=production
PYTHONPATH=/app

# Database (if external)
DATABASE_URL=postgresql://user:pass@host:5432/dbname

Database Setup

The application supports multiple database types:

  • Sample Database: Click "Load Sample Database" for instant demo with e-commerce data
  • PostgreSQL: Create a database and user with appropriate permissions
  • MySQL: Create a database and user with appropriate permissions
  • SQLite: Upload your own .db file through the interface

Example PostgreSQL setup:

CREATE DATABASE textosql;
CREATE USER texttosql WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE texttosql TO texttosql;

Monitoring & Logs

Docker

# View logs
docker-compose -f docker-compose.prod.yml logs -f

# Check status
docker-compose -f docker-compose.prod.yml ps

PM2

# View logs
pm2 logs

# Monitor
pm2 monit

Troubleshooting

Common Issues:

  1. Port conflicts: Change ports in docker-compose.prod.yml
  2. Memory issues: Increase Docker memory limits
  3. Model loading: Ensure sufficient disk space (4GB+ for AI model)

Health Checks:

# Frontend
curl http://localhost:3000

# Backend API
curl http://localhost:3000/api/health

Database Connection

The application supports multiple database types:

  • Connect via credentials (PostgreSQL/MySQL)
  • Upload SQLite files
  • Real-time schema detection and query generation

Architecture

  • Frontend: React app with Nginx (port 3000)
  • Backend: FastAPI on internal Docker network
  • Database: User-provided (PostgreSQL/MySQL/SQLite)
  • AI Model: 4GB cached in persistent volume
  • Security: Backend only accessible via proxy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published