NLQuery is an AI-powered tool that translates natural language into SQL queries, making database interactions more intuitive and accessible.
- Natural language to SQL query conversion
- Support for multiple database types (PostgreSQL, MySQL)
- AI-powered query generation using Claude or OpenAI
- Interactive chat interface
- Real-time query results display
- Pagination for large result sets
- Configurable database and AI settings
- Docker and Docker Compose
- Database server (PostgreSQL or MySQL)
- AI API key (Claude or OpenAI)
- Clone the repository:
git clone https://github.com/yourusername/nlquery.git
cd nlquery- Create a
.envfile from the example:
cp .env.example .env-
Edit the
.envfile with your database and AI configuration. -
Build and start the containers:
docker-compose up --build- Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Provider: Choose between Claude or OpenAI
- API Key: Your AI provider API key
- Model: Specific model to use (e.g., claude-3-opus-20240229 or gpt-4)
- Temperature: AI response randomness (0-1)
- Max Tokens: Maximum response length
- Create a virtual environment:
cd backend
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the development server:
export $(cat ../.env | xargs)
uvicorn app.main:app --reload- Install dependencies:
cd frontend-old
npm install- Run the development server:
npm run devsql-chat/
├── backend/
│ ├── app/
│ │ ├── __init__.py
│ │ ├── main.py
│ │ ├── core/
│ │ │ ├── __init__.py
│ │ │ ├── config.py
│ │ │ └── security.py
│ │ ├── api/
│ │ │ ├── __init__.py
│ │ │ └── routes.py
│ │ └── models/
│ │ ├── __init__.py
│ │ └── schemas.py
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Chat.jsx
│ │ │ ├── ConfigForm.jsx
│ │ │ └── QueryResults.jsx
│ │ ├── App.jsx
│ │ └── main.jsx
│ ├── package.json
│ └── Dockerfile
├── docker-compose.yml
└── README.md
Send a natural language query to the system.
Request:
{
"message": "Show me all orders from last month",
"conversation_id": "optional-conversation-id"
}Response:
{
"message": "Query results...",
"sql": "SELECT * FROM...",
"results": [
{
"column1": "value1",
"column2": "value2"
}
]
}Create a new conversation.
Response:
{
"conversation_id": "uuid"
}Get conversation history.
Response:
{
"messages": [
{
"role": "user",
"content": "message"
},
{
"role": "assistant",
"content": "response"
}
]
}- All database credentials and API keys should be stored securely
- Use environment variables for sensitive information
- Enable SSL for database connections in production
- Implement proper authentication and authorization
- Regularly update dependencies for security patches
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details. Database Settings
- Type: PostgreSQL or MySQL
- Host: Database server hostname
- Port: Database server port
- Database: Database name
- Username: Database user
- Password: Database password
- SSL: Enable/disable SSL connection

