Skip to content

AashishMehtoliya/QueryCatalyst-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueryCatalyst

A natural language to SQL query converter built with React and Tailwind CSS, powered by AI models to transform plain English questions into optimized SQL queries.

Features

  • Schema Upload: Upload database schemas in CSV, SQL, or JSON format
  • Natural Language Processing: Ask questions in plain English
  • SQL Generation: Automatically generate optimized SQL queries
  • Modern UI: Beautiful, responsive interface built with Tailwind CSS
  • Real-time Feedback: Instant query generation with explanations
  • Database Connection: Direct connection to PostgreSQL databases
  • Data Analysis: Interactive data visualization and analysis tools

Setup Steps

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • PostgreSQL database (for direct connections)
  • Python 3.8+ (for backend API)

Backend Setup

  1. Clone and setup the backend API:
# The backend should be running on http://localhost:8000
# Ensure the following endpoints are available:
# - POST /generate-sql
# - POST /connections
# - POST /generate-chart
# - GET /health
  1. Install Python dependencies:
cd backend  # Navigate to your backend directory
pip install -r requirements.txt
  1. Start the backend server:
python main.py  # or your backend startup command

Frontend Setup

  1. Clone the repository:
git clone <repository-url>
cd QueryCatalyst
  1. Install dependencies:
npm install
  1. Configure environment variables:
# Create .env file if needed
REACT_APP_API_BASE_URL=http://localhost:8000
  1. Start the development server:
npm start
  1. Open http://localhost:3000 in your browser

Architecture Overview

System Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   React Frontend│    │  Backend API    │    │  PostgreSQL    │
│                 │    │                 │    │   Database     │
│ - Schema Upload │◄──►│ - SQL Generation│◄──►│ - Data Storage │
│ - Query Input   │    │ - Chart Gen.    │    │ - Schema Info  │
│ - Data Analysis │    │ - DB Connection │    │ - Query Exec.  │
└─────────────────┘    └─────────────────┘    └─────────────────┘

Frontend Architecture

  • Component-Based Structure: Modular React components with clear separation of concerns
  • Context API: Global state management using React Context for data persistence
  • Routing: Single-page application with React Router for navigation
  • Responsive Design: Mobile-first approach using Tailwind CSS

Data Flow

  1. Schema Input: User uploads schema or connects to database
  2. Query Processing: Natural language query sent to backend API
  3. SQL Generation: AI model generates SQL from natural language
  4. Execution: SQL executed against database (if connected)
  5. Results Display: Data presented in interactive tables and charts

Models Used

AI Models

  • Natural Language to SQL: Large Language Model (LLM) for query understanding and SQL generation
  • Chart Generation: AI-powered chart type selection and visualization generation
  • Query Optimization: Model-based SQL query optimization and validation

Model Capabilities

  • Schema Understanding: Parses and understands database schemas
  • Query Intent Recognition: Converts natural language to SQL intent
  • SQL Generation: Produces syntactically correct SQL queries
  • Error Handling: Provides meaningful error messages and suggestions

Model Limitations

  • Language Support: Currently optimized for English queries
  • Complex Queries: May struggle with highly complex nested queries
  • Schema Complexity: Performance may degrade with very large schemas

Known Limitations and Risks

Technical Limitations

  • API Dependency: Frontend requires backend API to be running
  • Database Support: Currently optimized for PostgreSQL, limited support for other databases
  • Query Complexity: Very complex queries may not generate correctly
  • Schema Size: Large schemas (>100 tables) may impact performance

Security Risks

  • Database Credentials: Connection credentials stored in frontend state (consider encryption)
  • SQL Injection: Generated SQL should be validated before execution
  • Data Exposure: Sensitive data may be visible in query results
  • API Security: Backend API lacks authentication/authorization

Performance Considerations

  • Large Datasets: Querying very large datasets may cause timeouts
  • Memory Usage: Large result sets may impact browser performance
  • Network Latency: API calls may be slow on poor connections
  • Caching: No built-in caching for repeated queries

Data Privacy

  • Schema Information: Database schemas are sent to AI services for processing
  • Query Logs: User queries may be logged for model improvement
  • Data Transmission: Sensitive data transmitted over network

Usage

  1. Upload Schema: Use the schema upload component to provide your database structure
  2. Connect Database: Alternatively, establish direct database connection
  3. Ask Questions: Type natural language questions about your data
  4. Get SQL: Receive generated SQL queries with explanations
  5. Execute Queries: Run queries directly against connected database
  6. Analyze Data: Use built-in tools for data visualization and analysis

Technology Stack

  • Frontend: React 18, React Router, Tailwind CSS
  • Backend: Python FastAPI/Flask (assumed)
  • Database: PostgreSQL with connection pooling
  • AI/ML: Large Language Models for NLP and SQL generation
  • Icons: Lucide React
  • Build Tool: Create React App

Project Structure

src/
├── app/
│   ├── components/
│   │   ├── ui/           # Reusable UI components
│   │   ├── Header.js     # Navigation header
│   │   ├── SchemaUpload.js
│   │   ├── SchemaDisplay.js
│   │   ├── QueryInput.js
│   │   ├── QueryResponse.js
│   │   ├── DataAnalysis.js
│   │   └── DatabaseConnection.js
│   ├── context/          # React Context for state management
│   ├── hooks/            # Custom React hooks
│   ├── App.js            # Main application component
│   └── App.css
├── index.js              # Application entry point
├── index.css             # Global styles
└── mock.js               # Mock data for development

Development

  • Mock Mode: Currently uses mock data for demonstration
  • Production Ready: Designed to integrate with real AI services
  • Extensible: Easy to add new features and components
  • Testing: Unit tests and integration tests recommended

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

This project is built for Hackathon 2025.

Support

For issues and questions:

  • Check the known limitations above
  • Review the architecture overview
  • Ensure all setup steps are completed
  • Verify backend API is running and accessible

About

Web UI for QueryCatalyst

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors