🔥FLASH SALE: 30% OFF everything!
LogoTemplateFame
icon of Natural Language Postgres

Natural Language Postgres

An Next.js application that allows you to query a PostgreSQL database with natural language and visualize results.

Introduction

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:
  1. Users input natural language queries about unicorn companies.
  2. GPT-4o generates an appropriate SQL query.
  3. The SQL query is executed against the PostgreSQL database.
  4. Results are presented in a table.
  5. An AI-generated chart configuration visualizes the data.
  6. 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.

Information

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates