Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


πŸš€ LucidSQL AI β€” Local Natural Language to SQL Intelligence

Enterprise-grade AI database assistant that converts natural language into SQL queries and executes them instantly β€” powered by a fully local LLM.

LucidSQL AI enables users to interact with databases using plain English. It uses LangChain + Ollama + Llama 3 + Streamlit to automatically generate SQL queries and return structured results through a professional dashboard.

⚑ Runs locally πŸ”’ Privacy-first 🌐 Offline capable πŸ€– AI-powered database querying


✨ Features

🧠 AI-Powered SQL Generation

  • Converts natural language β†’ SQL automatically
  • Schema-aware query generation
  • Uses Llama 3 via Ollama

⚑ Fully Local AI (No Cloud APIs)

  • Runs completely on your machine
  • No OpenAI or external API calls
  • Privacy-safe architecture
  • Offline support after setup

πŸ“Š Automatic Query Execution

  • Executes generated SQL instantly
  • Displays results in structured tables

🎨 Professional Dashboard UI

  • Clean enterprise-grade interface
  • Dark theme adaptive styling
  • Responsive layout
  • Session state management

πŸ” Secure Query Pipeline

  • Uses only database schema
  • Prevents invalid queries
  • Safe SQL execution

πŸ—„οΈ SQLite Database Integration

  • Lightweight local database
  • Easy setup
  • Fast performance

πŸ–ΌοΈ Application Preview

πŸ”Ή Overview Dashboard

πŸ‘‰image


πŸ”Ή Generated SQL + Results

πŸ‘‰ image


🧠 How It Works

Pipeline Flow

User Question
      ↓
Prompt Engineering
      ↓
LangChain SQL Generator
      ↓
Local Llama 3 (Ollama)
      ↓
SQL Query Execution
      ↓
Results Displayed in UI

Step-by-Step Process

  1. User enters a natural language question.
  2. Database schema + question sent to LLM.
  3. Llama 3 generates SQL query.
  4. SQL executes on SQLite database.
  5. Results displayed in Streamlit UI.

πŸ—οΈ Architecture

Fully Local AI Stack

Frontend        β†’ Streamlit
AI Engine       β†’ Ollama + Llama 3 (Local)
LLM Framework   β†’ LangChain
Database        β†’ SQLite
Data Handling   β†’ Pandas

Why this architecture is powerful:

βœ… No cloud dependency βœ… Data never leaves your machine βœ… Works offline βœ… Privacy-first design βœ… Low latency inference


🌐 Offline Capability

LucidSQL AI runs fully offline after initial setup.

Internet required only for:

  • Installing dependencies
  • Installing Ollama
  • First-time model download

After setup:

βœ… No internet required βœ… Local AI inference βœ… Local database execution


πŸ—οΈ Tech Stack

Technology Purpose
Python Core development
Streamlit UI framework
LangChain LLM orchestration
Ollama Local LLM runtime
Llama 3 SQL generation model
SQLite Database
Pandas Data processing

πŸ“‚ Project Structure

LucidSQL-AI/
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ project.db
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md

⚑ Installation & Setup

1️⃣ Clone Repository

git clone https://github.com/yourusername/LucidSQL-AI.git
cd LucidSQL-AI

2️⃣ Create Virtual Environment (Recommended)

python -m venv venv

Activate Environment

Windows

venv\Scripts\activate

Mac/Linux

source venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

Or manually:

pip install streamlit pandas langchain langchain-community langchain-ollama

4️⃣ Install Ollama

Download from:

πŸ‘‰ https://ollama.com

Verify installation:

ollama --version

5️⃣ Download Llama 3 Model (One-Time Setup)

ollama run llama3

After this step β†’ fully offline usage.


6️⃣ Run Application

streamlit run app.py

Open in browser:

http://localhost:8501

πŸ’¬ Example Queries

Try asking:

  • Show all students with grade A
  • Average score by subject
  • Top 5 highest scoring students
  • Count students per subject
  • List students with score above 80

🎯 Use Cases

  • AI-powered data exploration
  • Business intelligence dashboards
  • SQL learning tools
  • Database assistants
  • Analytics systems
  • Enterprise internal tools

πŸ” Security

  • Schema-restricted SQL generation
  • Safe result handling
  • No direct user SQL execution
  • Local data processing

πŸš€ Future Improvements

  • Chat-style conversational interface
  • Automatic data visualization
  • Multi-database support (MySQL/PostgreSQL)
  • Query explanation feature
  • SQL optimization suggestions
  • Query history tracking
  • Authentication system
  • Cloud deployment

πŸ‘¨β€πŸ’» Developer

Upayan Chatterjee AI & Data Systems Enthusiast β€’ Full Stack Developer


⭐ Contributing

Contributions are welcome!

  1. Fork repository
  2. Create feature branch
  3. Commit changes
  4. Open pull request

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages