Skip to content

Commit be31e25

Browse files
Revert README to match main to avoid merge conflicts
1 parent e3d6d6c commit be31e25

File tree

1 file changed

+68
-78
lines changed

1 file changed

+68
-78
lines changed

README.md

Lines changed: 68 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,77 @@
1-
# Text-to-SQL Platform (FastAPI + Groq)
1+
# SQL Query Generator with Google Gemini
22

3-
This repository provides a modular backend that converts natural language into SQL and executes it on an SQLite database (`student.db`).
4-
5-
The backend is built with FastAPI and uses Groq’s OpenAI-compatible API to generate SQL from English questions. A separate modern UI will be added by the frontend team.
3+
This project is a Streamlit application that converts English questions into SQL queries using Google Gemini's generative AI capabilities. It allows users to retrieve data from an SQLite database named **student.db**, which contains information about students, their classes, sections, and marks.
64

75
## Table of Contents
86

97
- [Features](#features)
108
- [Technologies Used](#technologies-used)
11-
- [Getting Started](#getting-started)
9+
- [Installation](#installation)
10+
- [Usage](#usage)
1211
- [Example Queries](#example-queries)
1312
- [Database Schema](#database-schema)
14-
- [API Endpoints (v1)](#api-endpoints-v1)
15-
- [Testing & Coverage](#testing--coverage)
16-
- [Roadmap](#roadmap)
1713
- [Contributing](#contributing)
1814
- [License](#license)
19-
- [License](#license)
2015

2116
## Features
2217

23-
- Convert natural language questions into SQL queries (Groq).
18+
- Convert natural language questions into SQL queries.
2419
- Execute generated SQL queries against the SQLite database.
25-
- Clean SQL responses (strip markdown, enforce semicolon).
26-
- Modern FastAPI backend with auto docs at `/docs`.
27-
- Full test suite with coverage and temporary DB isolation.
20+
- User-friendly interface built with Streamlit.
21+
- Response cleaning to ensure valid SQL execution.
2822

2923
## Technologies Used
3024

31-
- [FastAPI](https://fastapi.tiangolo.com/) for the backend API
32-
- [Groq](https://groq.com/) for NL→SQL (OpenAI-compatible API)
33-
- [SQLite](https://www.sqlite.org/) for the demo database
34-
- [Pydantic](https://docs.pydantic.dev/) for validation
35-
- [Pytest](https://docs.pytest.org/) for testing and coverage
25+
- [Streamlit](https://streamlit.io/) - For building the web application.
26+
- [SQLite](https://www.sqlite.org/index.html) - Lightweight database to store student records.
27+
- [Google Generative AI](https://developers.google.com/generative-ai) - To generate SQL queries from text input.
28+
- [Python](https://www.python.org/) - Programming language used to build the application.
29+
- [Regex](https://docs.python.org/3/library/re.html) - For cleaning generated SQL queries.
30+
31+
## Installation
32+
33+
To get started, clone the repository and install the required dependencies.
34+
35+
### Prerequisites
3636

37-
## Getting Started
37+
- Python 3.7 or higher
38+
- pip (Python package installer)
3839

39-
Backend is located in `backend/`. You can use Conda for a reproducible setup.
40+
### Steps to Install
4041

41-
1) Create environment (Option A: from file)
42-
```bash
43-
conda env create -f backend/environment.yml
44-
conda activate text2sql-backend
45-
```
42+
1. **Clone the repository:**
43+
```bash
44+
git clone https://github.com/yourusername/sql-query-generator.git
45+
cd sql-query-generator
46+
```
4647

47-
Or Option B (manual):
48-
```bash
49-
conda create -n text2sql-backend python=3.11 -y
50-
conda activate text2sql-backend
51-
pip install -e backend[dev]
52-
```
48+
2. **Create a virtual environment (optional but recommended):**
49+
```bash
50+
python -m venv venv
51+
source venv/bin/activate # On Windows use `venv\Scripts\activate`
52+
```
5353

54-
2) Configure environment variables
55-
```bash
56-
cp backend/.env.example backend/.env
57-
# edit backend/.env and set GROQ_API_KEY and (optionally) GROQ_MODEL
58-
```
54+
3. **Install required packages:**
55+
```bash
56+
pip install -r requirements.txt
57+
```
5958

60-
3) Run the API (from repo root)
61-
```bash
62-
uvicorn app.main:app --reload --port 8000 --app-dir backend
63-
```
59+
4. **Set up your environment variables:**
60+
- Create a `.env` file in the project root and add your Google API key:
61+
```
62+
GOOGLE_API_KEY=your_api_key_here
63+
```
6464
65-
Open API docs at: http://127.0.0.1:8000/docs
65+
## Usage
66+
67+
1. Run the Streamlit application:
68+
```bash
69+
streamlit run app.py
70+
```
71+
72+
2. Open your browser and go to `http://localhost:8501`.
73+
74+
3. Input your question in the text box and click the "Ask the question" button. The app will generate an SQL query based on your input and execute it against the database, displaying the results.
6675

6776
## Example Queries
6877

@@ -83,41 +92,6 @@ The database **student.db** has the following schema:
8392
| SECTION | VARCHAR(25) | Section of the student |
8493
| MARKS | INT | Marks obtained by the student |
8594

86-
## API Endpoints (v1)
87-
88-
- GET `/api/v1/health` → health check
89-
- GET `/api/v1/students` → list all students
90-
- POST `/api/v1/sql` → execute provided SQL
91-
- POST `/api/v1/nl2sql` → convert NL to SQL using Groq
92-
93-
Example curl (after starting the server):
94-
```bash
95-
curl http://127.0.0.1:8000/api/v1/health
96-
curl http://127.0.0.1:8000/api/v1/students
97-
curl -X POST http://127.0.0.1:8000/api/v1/sql \
98-
-H 'Content-Type: application/json' \
99-
-d '{"sql":"SELECT COUNT(*) FROM STUDENT;"}'
100-
curl -X POST http://127.0.0.1:8000/api/v1/nl2sql \
101-
-H 'Content-Type: application/json' \
102-
-d '{"question":"How many entries of records are present?"}'
103-
```
104-
105-
## Testing & Coverage
106-
107-
```bash
108-
cd backend
109-
pytest -q --cov=app --cov-report=term-missing
110-
```
111-
112-
Tests use a temporary SQLite DB and do not touch your real `student.db`.
113-
114-
## Roadmap
115-
116-
- Frontend UI integration (modern SPA)
117-
- AuthN/Z and rate limiting
118-
- Schema introspection and multi-table support
119-
- Safer SQL generation and validation guardrails
120-
12195
## Contributing
12296

12397
Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute.
@@ -128,8 +102,24 @@ Contributions are welcome! Please open an issue or submit a pull request if you'
128102
4. Push to the branch (`git push origin feature/AmazingFeature`).
129103
5. Open a pull request.
130104

131-
## License
132105

133-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
134106

135107

108+
### Key Sections Explained
109+
110+
1. **Title & Introduction:** Brief overview of the project and its purpose.
111+
2. **Table of Contents:** Provides easy navigation throughout the README.
112+
3. **Features:** Highlights the main capabilities of the application.
113+
4. **Technologies Used:** Lists the frameworks, libraries, and languages used in the project.
114+
5. **Installation:** Step-by-step guide for setting up the project, including environment variable setup.
115+
6. **Usage:** Instructions on how to run the application and interact with it.
116+
7. **Example Queries:** Offers sample questions to demonstrate the app’s functionality.
117+
8. **Database Schema:** Details the structure of the SQLite database for better understanding.
118+
9. **Contributing:** Encourages community contributions with a guide on how to do so.
119+
10. **License:** Information regarding the licensing of the project.
120+
121+
### Tips for Customization
122+
123+
- Replace placeholders like `yourusername` and `your_api_key_here` with actual values relevant to your project.
124+
- Adjust the content based on any additional features or changes you have made.
125+
- Make sure to include any additional documentation or instructions relevant to your specific project needs.

0 commit comments

Comments
 (0)