Transform natural language queries into SQL with AI-powered intelligence and real-time database insights.
See the GIFs above for quick feature highlights, or watch the full demo video for a complete walkthrough!
- AI-Powered Query Generation: Convert natural language to SQL using advanced language models
- Semantic Search: Intelligent table and column matching using embeddings
- Real-time Visualization: Interactive charts and data insights
- SQL Security: Built-in protection against dangerous SQL operations
- Banking Domain Focus: Specialized for financial data analysis
- Modern UI: Clean, responsive interface with real-time feedback
- Multi-Architecture: Streamlit backend + Next.js frontend
text-2-sql/
├── backend/ # Streamlit API & Core Logic
│ ├── main.py # Main Streamlit application
│ ├── flask_api.py # REST API endpoints
│ ├── core/ # Core utilities & config
│ ├── nodes/ # Processing nodes
│ ├── prompts/ # AI prompt templates
│ └── qdrant/ # Vector database for embeddings
├── frontend/ # Next.js React Application
│ ├── app/ # App router pages
│ ├── components/ # Reusable UI components
│ └── utils/ # API utilities
└── samlple_queries/ # Example queries
Entity Relationship Diagram showing the banking database structure
- Python 3.8+
- Node.js 18+
- PostgreSQL database
- OpenAI API key
-
Clone the repository
git clone https://github.com/yourusername/text-2-sql.git cd text-2-sql -
Install Python dependencies
cd backend pip install streamlit flask psycopg2-binary openai qdrant-client sentence-transformers pyyaml -
Configure the database
- Set up PostgreSQL with a
banking_datadatabase - Update
backend/core/config.yamlwith your database credentials
- Set up PostgreSQL with a
-
Set up environment variables
export OPENAI_API_KEY="your-openai-api-key"
-
Start the backend
streamlit run main.py
-
Install Node.js dependencies
cd frontend npm install -
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:3000
Try these natural language queries:
- "Which branches have the highest total account balances?"
- "How has the total account balance at each branch changed month over month?"
- "Show me customers with loans above $50,000"
- "What's the average transaction amount by account type?"
- Natural Language Input: Type your question in plain English
- AI Processing: The system analyzes your query and generates SQL
- Results Display: View formatted results with charts and insights
- SQL Transparency: See the generated SQL for verification
openai:
api_key: "your-openai-api-key"
org_id: "your-org-id"
postgres:
host: "localhost"
database: "banking_data"
user: "postgres"
password: "your-password"
port: 5432
settings:
page_title: "Text-to-SQL Agent"
max_query_timeout: 30
max_result_rows: 1000The system includes built-in protection against:
- INSERT operations
- UPDATE operations
- DELETE operations
- DROP operations
- ALTER operations
- TRUNCATE operations
- CREATE operations
- Streamlit: Web application framework
- OpenAI GPT: Natural language processing
- PostgreSQL: Database management
- Qdrant: Vector database for embeddings
- Sentence Transformers: Text embedding models
- Next.js 15: React framework
- Tailwind CSS: Styling
- Chart.js: Data visualization
- Clerk: Authentication
- React Table: Data tables
The system is designed for banking data analysis with tables including:
- Customer information
- Account balances
- Transaction history
- Branch data
- Loan information
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request




