Skip to content

About

The universal Text-to-Query interface. Connect to any database (SQL, NoSQL, Graph), use any LLM (OpenAI, Gemini, Claude, Llama), and generate queries from natural language

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueryFusion AI ✨

The universal Text-to-Query (Text2SQL) interface. Connect to any database (SQL, NoSQL, Graph), use any LLM (OpenAI, Gemini, Claude, Llama), and generate DB queries from natural language.

License: MIT GitHub stars PRs Welcome

QueryFusion AI bridges the gap between human language and machine queries. Stop wrestling with complex syntax and start talking to your data. This open-source project provides a sleek interface and a powerful backend to generate SQL, Cypher, MQL, and more, using your favorite local or cloud-based Large Language Models.

Screenshot

QueryFusion AI Screenshot

QueryFusion AI - Query Screenshot


Key Features

  • Universal Database Support: Built with a modular connector architecture.
    • SQL: PostgreSQL, MySQL, SQLite, DuckDB, ClickHouse, TimescaleDB.
    • NoSQL (WIP): MongoDB, Cassandra, HBase.
    • Graph (WIP): Neo4j.
  • Universal LLM Integration: Powered by LiteLLM, supporting 100+ models out-of-the-box.
    • Cloud APIs: OpenAI (ChatGPT), Google (Gemini), Anthropic (Claude), Grok, etc.
    • Open Source & Local: Llama 3, Mistral, CodeGemma via Ollama, vLLM, and other local inference servers.
  • Modern Tech Stack: Fast, scalable, and easy to contribute to.
    • Backend: FastAPI (Python)
    • Frontend: Vite + React + TypeScript + Tailwind CSS
  • Intelligent Schema Detection: Automatically introspects your database to provide the LLM with the necessary context for accurate query generation.
  • Developer Friendly: Easy setup, clean code, and designed for extension.

Architecture Overview

QueryFusion AI uses a decoupled frontend/backend architecture for maximum flexibility.

[User on Vite Frontend] --> [REST API call to FastAPI Backend] --> [LiteLLM Gateway] --> [Chosen LLM API (e.g., Ollama or OpenAI)]

The backend handles all the heavy lifting: database inspection, secure credential management, and prompt engineering.


🏁 Getting Started

Prerequisites

  • Python 3.9+ and Node.js 18+
  • Access to a database
  • API keys for desired LLMs (e.g., OPENAI_API_KEY) or a local Ollama server.

Installation

  1. Clone the repository:

    git clone [https://github.com/lokeshsk/queryfusion-ai.git](https://github.com/lokeshsk/queryfusion-ai.git)
    cd queryfusion-ai
  2. Setup the Backend:

    cd backend
    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    cp .env.example .env
    # Edit .env and add your API keys
  3. Setup the Frontend:

    cd ../frontend
    npm install

🚀 Part 2: Running & Testing the Full Application

Let's test it end-to-end. We'll set up a sample PostgreSQL database, run the backend and frontend, and generate a query.

1. Set Up a Sample Database

If you have PostgreSQL running, connect to it and run this SQL script to create some sample data.

-- Create a 'customers' table
CREATE TABLE customers (
    customer_id INT PRIMARY KEY,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    email VARCHAR(100) UNIQUE,
    registration_date DATE
);

-- Create an 'orders' table
CREATE TABLE orders (
    order_id INT PRIMARY KEY,
    customer_id INT REFERENCES customers(customer_id),
    order_date DATE,
    total_amount NUMERIC(10, 2)
);

-- Insert some sample data
INSERT INTO customers (customer_id, first_name, last_name, email, registration_date) VALUES
(1, 'Alice', 'Johnson', 'alice.j@email.com', '2023-01-15'),
(2, 'Bob', 'Smith', 'bob.s@email.com', '2023-02-20'),
(3, 'Charlie', 'Brown', 'charlie.b@email.com', '2023-03-10');

INSERT INTO orders (order_id, customer_id, order_date, total_amount) VALUES
(101, 1, '2024-05-10', 150.75),
(102, 2, '2024-05-12', 200.00),
(103, 1, '2024-05-15', 75.50),
(104, 3, '2024-05-18', 300.25),
(105, 1, '2024-05-20', 50.00);

2. Run the Backend

Navigate to the backend directory. Create and activate a virtual environment if you haven't already.

  • Install dependencies: pip install -r requirements.txt
  • Create your .env file and add your OpenAI API key.
  • Run the server: uvicorn app.main:app --reload

Your backend is now live at http://127.0.0.1:8000.

3. Run the Frontend

Open a new terminal and navigate to the frontend directory.

  • Install dependencies: npm install
  • Run the dev server: npm run dev

Your UI is now live at http://localhost:5173.

4. Test a Sample Query

  1. Open http://localhost:5173 in your browser.
  2. In the Database Connection section, fill in the details for your PostgreSQL database.
  3. In the Ask a Question section, type in a question like:

    What are the names and emails of customers who have spent more than $100?

  4. Select your desired LLM model from the dropdown (e.g., "OpenAI GPT-4o").
  5. Click the ✨ Generate Query button.

Contributing

Contributions are welcome! Whether it's adding a new database connector, improving the UI, or enhancing the prompt engineering, please feel free to open a Pull Request.


License

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

About

The universal Text-to-Query interface. Connect to any database (SQL, NoSQL, Graph), use any LLM (OpenAI, Gemini, Claude, Llama), and generate queries from natural language

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages