|
1 | 1 | # LLM Natural Language SQL Analytics - Specification |
2 | 2 |
|
3 | | -## 1. Project Overview |
| 3 | +## Overview |
4 | 4 |
|
5 | | -**Project Name:** LLM SQL Analytics |
6 | | -**Project Type:** Django Web Application |
7 | | -**Core Functionality:** A system that allows users to query structured databases using natural language. The system converts natural language questions into SQL queries, executes them against connected databases, and returns results. Includes semantic search over database schema documentation using pgvector. |
8 | 5 |
|
9 | | -**Target Users:** Business analysts, data scientists, and non-technical users who need to query databases without writing SQL. |
| 6 | +A system that allows users to query structured databases using natural language. The system converts natural language questions into SQL queries, executes them against connected databases, and returns results. Includes semantic search over database schema documentation using pgvector. |
10 | 7 |
|
11 | | ---- |
| 8 | +<img width="967" height="739" alt="Screenshot 2026-03-19 at 5 39 25 PM" src="https://github.com/user-attachments/assets/b94cbc77-eae0-42f6-89cf-6fd7b05f146f" /> |
12 | 9 |
|
13 | | -## 2. Technology Stack |
| 10 | + |
| 11 | +## Technology Stack |
14 | 12 |
|
15 | 13 | - **Framework:** Django >=4.2, <5.0 |
16 | 14 | - **Database Driver:** psycopg2-binary >=2.9.9 |
|
22 | 20 | - **Environment:** python-dotenv >=1.0.0 |
23 | 21 | - **PDF Parsing:** PyPDF2 >=3.0.0 |
24 | 22 |
|
25 | | ---- |
| 23 | + |
| 24 | +## Setup Instructions |
| 25 | + |
| 26 | +### 1. Prerequisites |
| 27 | + |
| 28 | +- Python 3.9+ |
| 29 | +- PostgreSQL 15+ with pgvector extension |
| 30 | +- Groq API key (free) |
| 31 | + |
| 32 | +### 2. Install Dependencies |
| 33 | + |
| 34 | +```bash |
| 35 | +pip install -r requirements.txt |
| 36 | +``` |
| 37 | + |
| 38 | +### 3. Database Setup |
| 39 | + |
| 40 | +**Option A: Using Docker** |
| 41 | +```bash |
| 42 | +docker run -d --name postgres-pgvector \ |
| 43 | + -e POSTGRES_PASSWORD=postgres \ |
| 44 | + -e POSTGRES_DB=llm_analytics \ |
| 45 | + -p 5432:5432 \ |
| 46 | + pgvector/pgvector:pg16 |
| 47 | +``` |
| 48 | + |
| 49 | +**Option B: Local PostgreSQL** |
| 50 | +1. Install PostgreSQL |
| 51 | +2. Create database: `CREATE DATABASE llm_analytics;` |
| 52 | +3. Enable pgvector: `CREATE EXTENSION vector;` |
| 53 | + |
| 54 | +### 4. Configure Environment |
| 55 | + |
| 56 | +Edit `.env` file: |
| 57 | +```env |
| 58 | +DB_NAME=llm_analytics |
| 59 | +DB_USER=postgres |
| 60 | +DB_PASSWORD=postgres |
| 61 | +DB_HOST=localhost |
| 62 | +DB_PORT=5432 |
| 63 | +GROQ_API_KEY=your_groq_api_key_here |
| 64 | +SECRET_KEY=your_django_secret_key |
| 65 | +``` |
| 66 | + |
| 67 | +**Get Groq API Key (free):** |
| 68 | +1. Go to https://console.groq.com/keys |
| 69 | +2. Create a new API key |
| 70 | +3. Copy it to your `.env` file |
| 71 | + |
| 72 | +### 5. Run Migrations |
| 73 | + |
| 74 | +```bash |
| 75 | +python manage.py migrate |
| 76 | +``` |
| 77 | + |
| 78 | +### 6. Run Development Server |
| 79 | + |
| 80 | +```bash |
| 81 | +python manage.py runserver |
| 82 | +``` |
| 83 | + |
| 84 | +### 7. Access the Application |
| 85 | + |
| 86 | +- Web UI: http://localhost:8000 |
| 87 | +- Admin: http://localhost:8000/admin |
| 88 | + |
| 89 | + |
0 commit comments