i built a tool that lets anyone talk to a database and get visual charts
https://github.com/nonvegetable/nl2sql
non-technical teams shouldn't have to wait days for basic, critical data reports just because the data engineering team is constantly backlogged with basic query requests. it bottlenecks business decisions for weeks.
so to fix that, i let my typical curious, over-engineering brain build an autonomous data assistant to eliminate that exact delay.
i created nl2sql, an AI-driven, model-agnostic pipeline that lets anyone ask plain-English questions like "show me last quarter's clothing sales" and instantly receive structured data reports along with interactive charts.
here is how i engineered the system and structured the repository:
app.py: the main frontend user interface built using streamlit, giving non-tech users a clean, dead-simple chat dashboard to ask questions and view immediate visual reports.
generate_sql.py: the core autonomous engine. it handles context-aware schema linking via a chromadb vector database, routes the query to an llm, and runs a resilient agentic self-correction loop that automatically catches and patches sql syntax bugs on the fly.
sync_schema.py: this script manages database state and syncs the required relational table schemas directly into the vector database for high-accuracy embedding lookup.
docker-compose.yml & Dockerfile: containerizes the entire pipeline so it can be spun up seamlessly alongside any production postgresql instance.
why it’s built this way:
fully model-agnostic: you don't get locked into expensive cloud apis. you can seamlessly plug in your own local llms via ollama, or easily route queries through cloud provider api keys like openai, anthropic claude, or google gemini.
strict security: it isolates all data access using read-only postgresql execution roles, ensuring the agent can never accidentally modify or delete actual database records.
built using python, streamlit, postgresql, sqlalchemy, chromadb, and docker.
current deployment bottleneck
right now, i am only using docker and docker compose to spin this up locally. since this is designed to be hit by non-tech teams, i am looking for proper production deployment strategies. what would you recommend for hosting a streamlit + local llm/vector db stack securely in the cloud without breaking the bank?
would love to know what you guys think about the architecture, or if you've handled text-to-sql pipelines differently in production!
(used gemini for grammar)