Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

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

AppURL
Workspacehttps://sql-agent-omega-olive.vercel.app
Chathttps://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

LayerTech
BackendFastAPI, SQLAlchemy, PyMySQL, Motor
LLMsGroq (Llama 3.3 70B), NVIDIA (Llama 3.1 8B) via LangChain
Vector DBPinecone
File StorageCloudinary
Main FrontendReact 18, Vite, Tailwind CSS, Recharts, Framer Motion
Chat FrontendReact 18, Vite, Tailwind CSS, Recharts, Framer Motion
AuthJWT + Google OAuth 2.0
App DBMySQL

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/Linuxsource venv/bin/activate
pip install -r requirements.txt

Create backend/.env:

# MySQL (app database)DB_HOST=localhostDB_PORT=3306DB_USER=rootDB_PASSWORD=yourpasswordDB_NAME=sql_agent# LLMsGROQ_API_KEY=your_groq_keyGROQ_API_KEY_CHAT=your_groq_key_for_chat# optional separate keyGROQ_API_KEY_SUGGESTIONS=your_groq_key_for_suggestions# optional separate keyNVIDIA_API_KEY=your_nvidia_keyNVIDIA_API_KEY_CHAT=your_nvidia_key_for_chat# optional# Model names (optional — these are the defaults)CHAT_QUERY_MODEL=llama-3.3-70b-versatileCHAT_CONV_MODEL=meta/llama-3.1-8b-instruct# PineconePINECONE_API_KEY=your_pinecone_keyPINECONE_INDEX=querymind# CloudinaryCLOUDINARY_CLOUD_NAME=your_cloud_nameCLOUDINARY_API_KEY=your_cloudinary_keyCLOUDINARY_API_SECRET=your_cloudinary_secret# AuthJWT_SECRET=your_jwt_secret_keyJWT_ALGORITHM=HS256ACCESS_TOKEN_EXPIRE_MINUTES=60REFRESH_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:8000VITE_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:

CREATEDATABASEIF NOT EXISTS querymind_test;
USE querymind_test;
CREATETABLEemployees (
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');
CREATETABLEproducts (
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

MethodEndpointDescription
POST/auth/registerRegister with email/password
POST/auth/loginLogin
POST/auth/googleGoogle OAuth login
GET/auth/meGet current user
PATCH/auth/meUpdate 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/sessionsCreate chat session
POST/chat/sessions/{id}/messageSend a message
GET/chat/shared/{share_id}Get shared chat (public)

Environment Variables Reference

VariableRequiredDescription
GROQ_API_KEYMain Groq key for SQL generation
NVIDIA_API_KEYNVIDIA key for summaries and chat
PINECONE_API_KEYPinecone vector DB
PINECONE_INDEXPinecone index name
CLOUDINARY_CLOUD_NAMECloudinary for file storage
CLOUDINARY_API_KEYCloudinary API key
CLOUDINARY_API_SECRETCloudinary secret
JWT_SECRETSecret for JWT signing
GOOGLE_CLIENT_IDOnly needed for Google login
GROQ_API_KEY_CHATSeparate Groq key for chat (avoids rate limits)
GROQ_API_KEY_SUGGESTIONSSeparate Groq key for suggestions

Built With


Author

Venkatesh Paila GitHub: @venkateshpaila72-dev


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

Releases

Packages

Contributors

Languages