Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueryMind AI

Ask your data anything. Get charts, tables, and insights — in plain English.

QueryMind AI is a full-stack natural language data platform that lets you query MySQL databases, MongoDB collections, and files (CSV, Excel, PDF) without writing a single line of SQL or code.


Live Demo

App URL
Workspace https://sql-agent-omega-olive.vercel.app
Chat https://sql-agent-chat-frontend.vercel.app

Features

Workspace (frontend/)

  • Natural language → SQL / MongoDB pipeline / Pandas code generation
  • Auto chart selection — bar, donut, area, grouped bar, metric cards
  • Schema explorer with table/collection relationships
  • Saved queries with history
  • Dashboard with query analytics
  • File uploads — CSV, Excel, PDF querying
  • Settings — accent theme, layout density, profile management

Chat (chat-frontend/)

  • Conversational interface over all data sources
  • Session management with clusters and folders
  • Voice input (Web Speech API)
  • Follow-up questions with conversation memory (Pinecone RAG)
  • Shareable chat links (public read-only)
  • Intent classification — answers greetings conversationally, queries the DB for data questions
  • Download chat as JSON

Backend (backend/)

  • Multi-source query routing — MySQL, MongoDB, CSV, Excel, PDF
  • LLM-powered SQL generation, auto-fix on failure, query decomposition
  • RAG pipeline — schema embeddings + conversation history in Pinecone
  • JWT + Google OAuth authentication
  • File storage on Cloudinary
  • Privacy-first — db_url never stored in backend DB, passed per-request

Tech Stack

Layer Tech
Backend FastAPI, SQLAlchemy, PyMySQL, Motor
LLMs Groq (Llama 3.3 70B), NVIDIA (Llama 3.1 8B) via LangChain
Vector DB Pinecone
File Storage Cloudinary
Main Frontend React 18, Vite, Tailwind CSS, Recharts, Framer Motion
Chat Frontend React 18, Vite, Tailwind CSS, Recharts, Framer Motion
Auth JWT + Google OAuth 2.0
App DB MySQL

Project Structure

querymind/
├── backend/                  FastAPI backend (port 8000)
│   ├── agents/               LLM agents — SQL gen, chart selector, decomposer, suggestions
│   ├── auth/                 JWT handler, Google OAuth, dependencies
│   ├── connectors/           MySQL, MongoDB, CSV, Excel, PDF connectors
│   ├── rag/                  Pinecone client, schema RAG, history RAG, memory
│   ├── routes/               API routes — auth, chat, query, uploads, schema, dashboard
│   ├── db.py                 SQLAlchemy engine, schema loader, query runner
│   └── main.py               FastAPI app, startup (MySQL + Pinecone init)
│
├── frontend/                 Main workspace (port 5173)
│   └── src/
│       ├── api/              axios clients — authApi, schemaApi, queryApi, uploadsApi
│       ├── context/          AuthContext, SourceContext, QueryContext
│       ├── pages/            Workspace, Dashboard, Schema, Saved, Uploads, Settings
│       └── components/       AppShell, charts, query UI, source management
│
└── chat-frontend/            Chat app (port 5174)
    └── src/
        ├── api/              chatApi, uploadsApi, schemaApi
        ├── context/          AuthContext, ChatContext, SourceContext
        ├── hooks/            useChat, useSource, useAuth, useVoice, useToast
        ├── pages/            ChatPage, ConnectionsPage, LoginRedirectPage
        └── components/       Chat bubbles, SmartChart, ResultTabs, Sidebar, Source dropdown

Getting Started

Prerequisites

1. Clone the repo

git clone https://github.com/venkateshpaila72-dev/querymind.git
cd querymind

2. Backend setup

cd backend
python -m venv venv

# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate

pip install -r requirements.txt

Create backend/.env:

# MySQL (app database)
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=sql_agent

# LLMs
GROQ_API_KEY=your_groq_key
GROQ_API_KEY_CHAT=your_groq_key_for_chat        # optional separate key
GROQ_API_KEY_SUGGESTIONS=your_groq_key_for_suggestions  # optional separate key
NVIDIA_API_KEY=your_nvidia_key
NVIDIA_API_KEY_CHAT=your_nvidia_key_for_chat    # optional

# Model names (optional — these are the defaults)
CHAT_QUERY_MODEL=llama-3.3-70b-versatile
CHAT_CONV_MODEL=meta/llama-3.1-8b-instruct

# Pinecone
PINECONE_API_KEY=your_pinecone_key
PINECONE_INDEX=querymind

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_key
CLOUDINARY_API_SECRET=your_cloudinary_secret

# Auth
JWT_SECRET=your_jwt_secret_key
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
REFRESH_TOKEN_EXPIRE_DAYS=30

# Google OAuth (optional)
GOOGLE_CLIENT_ID=your_google_client_id

Run database migrations (create tables):

mysql -u root -p sql_agent < schema.sql

Start the backend:

uvicorn main:app --reload

3. Main frontend setup

cd frontend
npm install

Create frontend/.env:

VITE_API_URL=http://localhost:8000
VITE_GOOGLE_CLIENT_ID=your_google_client_id
npm run dev
# Runs on http://localhost:5173

4. Chat frontend setup

cd chat-frontend
npm install

Create chat-frontend/.env:

VITE_API_URL=http://localhost:8000
npm run dev
# Runs on http://localhost:5174

How It Works

Query Flow

User types question
       ↓
Intent classifier (chat vs data query)
       ↓
RAG — retrieve relevant schema tables + similar past queries
       ↓
LLM generates SQL / MongoDB pipeline / Pandas code
       ↓
Query executed on user's database
       ↓
Chart auto-selected based on columns + data shape
       ↓
LLM generates plain-English summary
       ↓
Result shown as chart + table + SQL + summary

Auth Flow

User logs in on main frontend (port 5173)
       ↓
JWT stored in localStorage as qm_access_token
       ↓
Chat button → opens http://localhost:5174/?token=JWT
       ↓
Chat frontend reads token from URL → saves → redirects to /chat

Privacy Model

Database credentials (db_url) are never stored in the backend database. They live only in the browser's localStorage and are passed with every query request. This means:

  • Credentials are never logged server-side
  • Deleting your browser data removes all credentials
  • The backend only stores session metadata and message history

Sample Test Database

Run this in MySQL to create a test database:

CREATE DATABASE IF NOT EXISTS querymind_test;
USE querymind_test;

CREATE TABLE employees (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100), department VARCHAR(50),
  salary DECIMAL(10,2), hired_date DATE, status VARCHAR(20)
);

INSERT INTO employees (name, department, salary, hired_date, status) VALUES
('Alice Johnson', 'Engineering', 95000, '2021-03-15', 'active'),
('Bob Smith',     'Marketing',   72000, '2020-07-01', 'active'),
('Carol White',   'Engineering', 88000, '2022-01-10', 'active'),
('Grace Kim',     'Finance',     78000, '2020-09-05', 'active'),
('Iris Chen',     'Finance',     84000, '2021-12-01', 'active');

CREATE TABLE products (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100), category VARCHAR(50),
  price DECIMAL(10,2), stock INT
);

INSERT INTO products (name, category, price, stock) VALUES
('Laptop Pro',    'Electronics', 1299.99, 45),
('Wireless Mouse','Electronics',   29.99, 200),
('Office Chair',  'Furniture',    349.00,  30),
('Monitor 27"',   'Electronics',  399.99,  60),
('Desk Lamp',     'Furniture',     49.99,  90);

Try asking: "What is the average salary by department?" or "Which products have stock less than 50?"


API Reference

Full interactive docs at http://localhost:8000/docs

Method Endpoint Description
POST /auth/register Register with email/password
POST /auth/login Login
POST /auth/google Google OAuth login
GET /auth/me Get current user
PATCH /auth/me Update profile name
POST /query/ Run a natural language query
GET /schema/ Get database schema
GET /uploads/ List uploaded files
POST /uploads/ Upload a file
POST /chat/sessions Create chat session
POST /chat/sessions/{id}/message Send a message
GET /chat/shared/{share_id} Get shared chat (public)

Environment Variables Reference

Variable Required Description
GROQ_API_KEY Main Groq key for SQL generation
NVIDIA_API_KEY NVIDIA key for summaries and chat
PINECONE_API_KEY Pinecone vector DB
PINECONE_INDEX Pinecone index name
CLOUDINARY_CLOUD_NAME Cloudinary for file storage
CLOUDINARY_API_KEY Cloudinary API key
CLOUDINARY_API_SECRET Cloudinary secret
JWT_SECRET Secret for JWT signing
GOOGLE_CLIENT_ID Only needed for Google login
GROQ_API_KEY_CHAT Separate Groq key for chat (avoids rate limits)
GROQ_API_KEY_SUGGESTIONS Separate Groq key for suggestions

Built With


Author

Venkatesh Paila GitHub: @venkateshpaila72-dev


QueryMind AI — your data, your questions, instant answers.