A simple web application that lets you ask natural-language questions about your PostgreSQL database and have them converted into SQL queries by an LLM. It includes schema browsing, query confirmation for destructive statements, and result display with pagination and hover-tooltips.
- Natural Language → SQL: Describe what you want in plain English, and the app generates a SQL statement.
- Schema Browser: View tables, columns, data types, primary/foreign key badges, and search/filter tables.
- Confirmation Flow: Destructive operations (INSERT, UPDATE, DELETE, etc.) require confirmation.
- Result Rendering: Paginated, responsive table with hover popovers for long content.
- Database Connection: Connect to or create databases directly from the UI.
Place a .env file at the project root with the following:
# For Together AI (default)
LLM_API_KEY=your-together-api-key
LLM_API_URL=https://api.together.xyz/v1/chat/completions
LLM_API_MODEL_NAME=meta-llama/Llama-3-70B-Instruct
# OR for Gemini (optional alternative)
GEMINI_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=your-gemini-api-keygit clone https://github.com/ah-naf/nlsql.git
cd nlsqlcd backend
go mod tidycd ../frontend
npm install
npm run buildcd ../backend
go run cmd/main.goOpen http://localhost:8080 in your browser.
This project supports multi-stage Docker builds (frontend + backend). Here's how to build and run:
docker build -t nlsql-app .docker run -p 8080:8080 nlsql-appMake sure your PostgreSQL instance is accessible from the container.
Visit: http://localhost:8080
Show all orders placed in the last 24 hoursAdd a new user named Alice with email alice@example.comDelete all rows from temp_sessions table
This project is open-source and available under the MIT License.