You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
6
4
7
5
## Table of Contents
8
6
9
7
-[Features](#features)
10
8
-[Technologies Used](#technologies-used)
11
-
-[Getting Started](#getting-started)
9
+
-[Installation](#installation)
10
+
-[Usage](#usage)
12
11
-[Example Queries](#example-queries)
13
12
-[Database Schema](#database-schema)
14
-
-[API Endpoints (v1)](#api-endpoints-v1)
15
-
-[Testing & Coverage](#testing--coverage)
16
-
-[Roadmap](#roadmap)
17
13
-[Contributing](#contributing)
18
14
-[License](#license)
19
-
-[License](#license)
20
15
21
16
## Features
22
17
23
-
- Convert natural language questions into SQL queries (Groq).
18
+
- Convert natural language questions into SQL queries.
24
19
- Execute generated SQL queries against the SQLite database.
- Create a `.env` file in the project root and add your Google API key:
61
+
```
62
+
GOOGLE_API_KEY=your_api_key_here
63
+
```
64
64
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.
66
75
67
76
## Example Queries
68
77
@@ -83,41 +92,6 @@ The database **student.db** has the following schema:
83
92
| SECTION | VARCHAR(25) | Section of the student |
84
93
| MARKS | INT | Marks obtained by the student |
85
94
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
-
121
95
## Contributing
122
96
123
97
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'
128
102
4. Push to the branch (`git push origin feature/AmazingFeature`).
129
103
5. Open a pull request.
130
104
131
-
## License
132
105
133
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
134
106
135
107
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