This project is a full-stack application that converts natural language queries (in English) into SQL queries using OpenAI's GPT-3.5 architecture and its text completion API. It is designed to help users easily translate simple instructions into complex SQL queries, making database management more accessible.
The project consists of:
- Client: π₯οΈ A React-based frontend.
- Server: π A Node.js backend powered by Express for handling requests.
- π Converts natural language input into valid SQL queries.
- πΌοΈ User-friendly React frontend.
- π§ Scalable backend with Express and Node.js.
- π Supports containerization with Docker for easy deployment.
Follow these steps to clone the repository, install dependencies, and run the application on your local machine.
git clone https://github.com/your-username/natural-language-sql-converter.git
cd natural-language-sql-converter
-
Client Dependencies:
Navigate to theclient
folder and run:cd client npm install
-
Server Dependencies:
Navigate to theserver
folder and run:cd ../server npm install
Navigate to the client
folder and start the React development server:
cd client
npm run dev
After starting, the development URL will appear in your terminal. Example:
β Local: http://localhost:5173/
β Network: use --host to expose
In a new terminal, navigate to the server
folder and start the Node.js server:
cd server
npm start
Example:
Listening on port 3002...
π‘ Note: The above steps are for running the application locally. If you want to run it as Docker containers, follow the steps below.
If you prefer to run the app using Docker, follow these steps to build and deploy the Docker images for the client and server.
Make sure Docker is installed and running on your machine.
π Docker Installation Guide
Verify installation:
docker --version
cd client/src
vi App.jsx
Modify the fetch
URL in App.jsx
:
const generateQuery = async () => {
const response = await fetch("http://localhost:3002/generate"); // Change the URL as needed
vi server/package.json
Remove the following line from package.json in the server
directory:
"start": "node index.js",
cd client
docker build -t <YOUR_DOCKER_USERNAME>/nlsql-client:01 .
docker push <YOUR_DOCKER_USERNAME>/nlsql-client:01
docker run -d --restart unless-stopped -p 80:80 <YOUR_DOCKER_USERNAME>/nlsql-client:01
cd ../server
docker build -t <YOUR_DOCKER_USERNAME>/nlsql-server:01 .
docker push <YOUR_DOCKER_USERNAME>/nlsql-server:01
docker run -d --restart unless-stopped -p 3002:3002 <YOUR_DOCKER_USERNAME>/nlsql-server:01
docker images
docker ps
- Frontend: React.js
- Backend: Node.js with Express
- Containerization: Docker
- API Integration: OpenAI GPT-3.5 API
-
User Input:
The user enters a natural language query in the frontend interface (React). -
Backend Processing:
The server sends the query to the GPT-3.5 model via OpenAIβs API to generate a SQL query. -
SQL Query Display:
The generated SQL query is returned and displayed on the frontend.
- π₯οΈ Portfolio
- π Personal Blog
- π GitHub
- πΌ LinkedIn
- π¦ Twitter
- π§βπ» Sasindu K Karunarathna
- π§βπ» Malitha Abeysinghe
- π§βπ» IMKDilshan
This project is licensed under the MIT License.
Read the full details here: LICENSE.md
This project is for educational purposes only.
Under the Fair Use policy of the Copyright Act of 1976, this project can be used for teaching, scholarship, and research purposes.
Read the full disclaimer here: Disclaimer.md
I was inspired to create this project to contribute something useful to the developer community.
Many thanks to all contributors for making this project a reality.
If you found this project useful, consider supporting it by buying me a coffee!
Feel free to reach out if you have any questions or feedback:
- π§ Email: [email protected]