This project is a Next.js application designed to enable users to interact with a PostgreSQL database using natural language queries, and then visualize the results effectively. It leverages the Vercel AI SDK and OpenAI's GPT-4o model to seamlessly translate plain English questions into executable SQL commands.
Key Features:
- Natural Language to SQL: Transform user-friendly queries into precise SQL statements using advanced AI.
- Data Visualization: Automatically display query results in both tabular and dynamic chart formats, with intelligent chart type selection based on the data structure.
- Query Explanation: Gain insights into the generated SQL queries through AI-powered explanations, detailing each component of the query.
Technology Stack:
The application is built on a robust stack including Next.js for both frontend and API routes, the Vercel AI SDK for AI integration, and OpenAI's GPT-4o for natural language processing. Data is stored in PostgreSQL, hosted via Vercel Postgres. UI/UX is enhanced with Framer Motion for animations, ShadcnUI for components, and Tailwind CSS for styling. Data visualization is handled by Recharts.
How It Works:
- Users input natural language queries about unicorn companies.
- GPT-4o generates an appropriate SQL query.
- The SQL query is executed against the PostgreSQL database.
- Results are presented in a table.
- An AI-generated chart configuration visualizes the data.
- Users can switch between table and chart views and request AI explanations for SQL queries.
Data:
The database contains comprehensive information on unicorn companies, including name, valuation, date joined, country, city, industry, and select investors, sourced from CB Insights. This template offers a powerful solution for data exploration and analysis without requiring SQL expertise.





