Skip to content

kusal-tharindu/SqlMaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’» Natural Language to SQL Query Converter

Download directly from github


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:

  1. Client: πŸ–₯️ A React-based frontend.
  2. Server: πŸš€ A Node.js backend powered by Express for handling requests.

✨ Features

  • πŸ” 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.

πŸš€ Getting Started

Follow these steps to clone the repository, install dependencies, and run the application on your local machine.

1️⃣ Clone the Repository

git clone https://github.com/your-username/natural-language-sql-converter.git
cd natural-language-sql-converter

2️⃣ Install Dependencies

  • Client Dependencies:
    Navigate to the client folder and run:

    cd client
    npm install
  • Server Dependencies:
    Navigate to the server folder and run:

    cd ../server
    npm install

πŸ› οΈ Running the Application

1️⃣ Run the Client (Frontend)

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

2️⃣ Run the Server (Backend)

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.


🐳 Docker Setup (Optional)

If you prefer to run the app using Docker, follow these steps to build and deploy the Docker images for the client and server.

1️⃣ Install Docker

Make sure Docker is installed and running on your machine.
πŸ”— Docker Installation Guide

Verify installation:

docker --version

2️⃣ Code Changes

Client (Frontend) Changes

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

Server (Backend) Changes

vi server/package.json

Remove the following line from package.json in the server directory:

"start": "node index.js",

3️⃣ Build and Run Docker Images

Client Image

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

Server Image

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

Verify Docker Images and Containers

docker images
docker ps

πŸ› οΈ Technologies Used

  • Frontend: React.js
  • Backend: Node.js with Express
  • Containerization: Docker
  • API Integration: OpenAI GPT-3.5 API

πŸ” How It Works

  1. User Input:
    The user enters a natural language query in the frontend interface (React).

  2. Backend Processing:
    The server sends the query to the GPT-3.5 model via OpenAI’s API to generate a SQL query.

  3. SQL Query Display:
    The generated SQL query is returned and displayed on the frontend.


πŸ‘₯ Authors and Contributors

πŸ‘¨β€πŸ’» Kusal Tharindu

🀝 Contributors


πŸ“„ License

This project is licensed under the MIT License.
Read the full details here: LICENSE.md


⚠️ Fair Use Act Disclaimer

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


🎁 Acknowledgments

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.


β˜• Support the Project

If you found this project useful, consider supporting it by buying me a coffee!

Buy Me A Coffee


πŸ“ž Contact Me

Feel free to reach out if you have any questions or feedback:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published