βοΈ Translate natural language into secure, production-ready SQL β built for real-world enterprise use.
β Built with LangChain, FastAPI, Streamlit, and your preferred LLMs.
π Enforces schema validation, RBAC, RLS, and query sanitization.
The Schema-Aware AI SQL Agent bridges the gap between LLMs and production databases.
It turns plain English into SQL β safely β with full guardrails in place.
Built entirely in Python with open-source tools, itβs designed for environments where security, compliance, and accuracy matter.
π¬ Watch the Walkthrough Video
π https://youtu.be/8PF6nWXB8iE
- π¬ Natural language to SQL with LLMs (OpenAI, OpenRouter, Ollama)
- π Role-based access control (RBAC) and row-level security (RLS)
- β Schema-aware validation and SQL sanitization
- π§ Memory-aware chat agent with clarification flow
- βοΈ REST API + Streamlit front-end
- π§ͺ Sample PostgreSQL database (Northwind) included for testing
A high-level view from UI to LLM to SQL execution:
Prefer a visual walkthrough? Watch the full setup & architecture demo here
git clone https://github.com/raedmajid/schema-aware-ai-sql-agent
cd schema-aware-ai-sql-agent
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then edit with your valuesStart the backend:
uvicorn backend.api.api:app --host 127.0.0.1 --port 8000 --reloadStart the frontend UI:
python3 -m streamlit run frontend/chat_UI.pyAccess the app at http://localhost:8501
For detailed setup, advanced features, and system architecture, see:
π README_FULL.md
Tip: Use Ctrl+Shift+V (or Cmd+Shift+V on Mac) in most editors to preview markdown files.
MIT License β use it, modify it, build on it.
