Skip to content

Adarsh-codesOP/askDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Query (askDB) - AI-Powered Database Querying Tool

AI Query Logo

Transform natural language into powerful database queries with AI-driven insights and beautiful visualizations.

Docker React Flask License

🌟 Overview

AI Query (askDB) is a revolutionary full-stack web application that democratizes database interaction by allowing users to query databases using natural language. Powered by Google's Gemini AI, it automatically generates SQL queries, provides intelligent suggestions, and delivers stunning data visualizations - all without requiring deep technical knowledge.

Whether you're a business analyst, data scientist, or developer, AI Query bridges the gap between complex databases and actionable insights.

✨ Features

πŸ” Natural Language Querying

  • AI-Powered SQL Generation: Ask questions in plain English and get accurate SQL queries instantly
  • Multi-Database Support: Connect to PostgreSQL, MySQL, MongoDB, and SQLite databases
  • Intelligent Suggestions: Receive contextual query recommendations based on your database schema and conversation history

πŸ“Š Interactive Data Visualization

  • Multiple Chart Types: View data as tables, bar charts, pie charts, or line graphs
  • Auto-Detection: Automatically suggests the best visualization type for your data
  • Export Capabilities: Download results as CSV or PNG images
  • Responsive Design: Beautiful, mobile-friendly visualizations

πŸ—οΈ Schema Exploration

  • Interactive Schema Browser: Explore tables, columns, and relationships visually
  • Entity-Relationship Diagrams: Generate and interact with ER diagrams of your database
  • Real-time Schema Analysis: Understand your data structure at a glance

🐳 Containerized Deployment

  • Docker Support: Easy deployment with Docker and Docker Compose
  • Development Ready: Hot-reload development environment
  • Production Optimized: Lightweight containers for efficient deployment

🎨 Modern User Interface

  • Dark/Light Themes: Choose your preferred visual experience
  • Intuitive Design: Clean, modern interface inspired by modern data tools
  • Real-time Feedback: Live status updates and progress indicators

πŸš€ Unique Selling Points

πŸ€– AI-First Approach

Unlike traditional query builders, AI Query leverages cutting-edge AI to understand context, handle complex relationships, and generate optimized queries that traditional tools might miss.

🌐 Universal Database Compatibility

Connect to any major database system without changing your workflow. Whether you're working with relational databases or NoSQL, AI Query adapts seamlessly.

πŸ“ˆ Visual Intelligence

Go beyond raw data - get automatic insights through intelligent visualizations that highlight trends, patterns, and anomalies in your data.

πŸ’¬ Conversational Analytics

Maintain context across queries with conversation history, allowing for follow-up questions and iterative data exploration.

πŸ”’ Privacy-Focused

All processing happens locally or in your controlled environment. Your data stays secure while benefiting from AI capabilities.

πŸ› οΈ Installation

Prerequisites

  • Docker and Docker Compose
  • Git

Quick Start

  1. Clone the repository

    git clone https://github.com/yourusername/ai-query.git
    cd ai-query
  2. Set up environment variables

    # Create .env file in Backend directory
    cd Backend
    cp .env.example .env
    # Edit .env with your Google Gemini API key
  3. Launch with Docker

    cd ..
    docker-compose up --build
  4. Access the application

Manual Installation (Alternative)

Backend Setup

cd Backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Set up your .env file with GEMINI_API_KEY
python app.py

Frontend Setup

cd frontend
npm install
npm run dev

πŸ“– Usage

Connecting to a Database

  1. Launch the application
  2. Choose your database type (PostgreSQL, MySQL, MongoDB, or SQLite)
  3. Enter connection details:
    • For local databases: host, port, database name, credentials
    • For cloud databases: connection string or detailed credentials
  4. Click "Connect Database"

Querying Your Data

  1. Once connected, you'll see suggested queries based on your schema
  2. Type natural language questions like:
    • "Show me the top 10 customers by revenue"
    • "What are the sales trends over the last month?"
    • "Find all orders from customers in California"
  3. AI Query generates the SQL and executes it automatically
  4. View results in table format or switch to visualizations

Exploring Schema

  • Use the Schema Explorer sidebar to browse tables and columns
  • Click "View ER Diagram" for a visual representation of relationships
  • Expand/collapse tables to see column details and data types

Working with Visualizations

  • Results automatically suggest the best visualization type
  • Switch between Table, Bar, Pie, and Line chart views
  • Export data as CSV or save charts as PNG

πŸ”§ API Documentation

Core Endpoints

Health Check

GET /api/health

Database Connection

POST /api/db/connect
Content-Type: application/json

{
  "dbType": "postgresql",
  "host": "localhost",
  "port": "5432",
  "database": "mydb",
  "username": "user",
  "password": "pass"
}

Natural Language Query

POST /api/sql/query
Content-Type: application/json

{
  "nl_query": "Show me all customers from New York",
  "session_id": "your-session-id"
}

Get Schema

POST /api/db/schema
Content-Type: application/json

{
  "session_id": "your-session-id"
}

For complete API documentation, see the API Reference.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Frontendβ”‚    β”‚   Flask Backend β”‚    β”‚   AI Service    β”‚
β”‚   (Vite)        │◄──►│   (REST API)    │◄──►│   (Gemini AI)   β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ - Query UI      β”‚    β”‚ - API Routes    β”‚    β”‚ - Query Gen     β”‚
β”‚ - Visualizations β”‚    β”‚ - DB Connection β”‚    β”‚ - Suggestions   β”‚
β”‚ - Schema Explorerβ”‚    β”‚ - Session Mgmt  β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   Databases     β”‚
                       β”‚                 β”‚
                       β”‚ PostgreSQL      β”‚
                       β”‚ MySQL          β”‚
                       β”‚ MongoDB        β”‚
                       β”‚ SQLite         β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

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

Areas for Contribution

  • Additional database connectors
  • New visualization types
  • Enhanced AI prompts
  • Performance optimizations
  • UI/UX improvements

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Google Gemini AI for powering intelligent query generation
  • React & Vite for the modern frontend framework
  • Flask for the robust backend API
  • Recharts for beautiful data visualizations
  • Tailwind CSS for the stunning UI design

πŸ“ž Support


Made with ❀️ for data enthusiasts everywhere

Transforming the way the world interacts with databases, one query at a time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors