Ever wished you could just ask for the SQL query you need instead of writing it? In this project, I built a Java-based backend that lets you do exactly that.
🔗 Project Repo
Check out the full code on GitHub:
👉 github.com/amkumar072/AI-SQL-Generator
🧩 What Is It?
AI-SQL Generator is a backend application that transforms natural language prompts into SQL queries using OpenAI's GPT API. It’s perfect for:
- Developers building analytics dashboards
- Business users who aren’t fluent in SQL
- Teams needing AI-driven query interfaces
🚀 How It Works
You send a POST request with:
- A natural language prompt
- The table schema (as a SQL
CREATE TABLEstring)
And you get back a GPT-generated SQL query that's ready to use.
📦 Sample Request
POST /query
Content-Type: application/json
{
"question": "Which seller has delivered the most orders to customers in Rio de Janeiro"
}
✅ Sample Response
{
"sql": "SELECT * FROM Employee ORDER BY salary DESC LIMIT 5;"
}
🔧 Tech Stack
| Layer | Tech Used |
|---|---|
| Language | Java 17 |
| Framework | Spring Boot |
| API | OpenAI GPT (via HTTPS) |
| Config | dotenv-java for secrets |
| Build Tool | Maven |
| Testing | Postman / curl |
⚙️ Setup Instructions
- Clone the repo:
git clone https://github.com/amkumar072/AI-SQL-Generator.git
cd AI-SQL-Generator
- Add your OpenAI key to a
.envfile:
OPENAI_API_KEY=your_openai_api_key
- Run the Spring Boot app:
mvn spring-boot:run
📈 Example Use Cases
- 🔍 Internal tools for data analysts
- 🧠 Chatbot assistants that answer data questions
- 🖥️ AI dashboards for business users
- 🛠️ Dev platforms embedding auto-SQL features
📌 What’s Next?
Here are a few potential enhancements:
- UI frontend with React or Angular
- Support for SQL dialects (MySQL, PostgreSQL, etc.)
- Real-time database validation for generated SQL
🧠 Why I Built This
The idea came from a common pain point: not everyone can write SQL, but everyone needs data. Tools like ChatGPT already understand data requests well—why not bring that power into a dedicated backend app?
This project combines the reliability of Java/Spring Boot with the intelligence of OpenAI GPT to deliver something actually useful for devs and data teams alike.
📬 Let’s Connect
If you liked this or have ideas to improve it, feel free to:
#java #springboot #openai #sql #gpt #api #backend #ai #devtools #projectshowcase
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.