A natural-language to SQL query tool. Ask questions about your data in plain English and get instant results with visualizations.
Built with Next.js, Gemini AI, and Supabase.

- Natural Language Queries — Type questions in plain English and get accurate SQL generated by Gemini 2.5 Flash.
- Live Query Execution — Generated SQL runs against a live Supabase PostgreSQL database with results displayed instantly.
- Smart Visualizations — Results are rendered as bar charts, line charts, or tables based on query intent (powered by Recharts).
- Multiple Schemas — Choose from pre-loaded database schemas: E-Commerce, SaaS Analytics, and HR & Operations.
- Dark / Light Mode — Toggle between themes with
next-themes. - Chat Interface — Conversational UI with message history and a "New Chat" reset.
| Layer | Technology |
|---|---|
| Framework | Next.js 14 (App Router) |
| AI | Gemini 2.5 Flash via Vercel AI SDK |
| Database | Supabase (PostgreSQL) |
| Charts | Recharts |
| UI | shadcn/ui, Radix, Tailwind CSS |
| Validation | Zod |
- Node.js 18+
- A Google AI Studio API key
- A Supabase project with seed data
-
Clone the repo
git clone https://github.com/upendrapant/query-craft.git cd query-craft -
Install dependencies
npm install
-
Configure environment variables
Create a
.env.localfile in the project root:GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
-
Run the dev server
npm run dev
Open http://localhost:3000.
- Select a database schema from the dropdown in the header.
- Type a question or click a suggested query.
- View the generated SQL, explanation, and results as a chart or table.
MIT