Inspiration

The inspiration for SQL_Chat_AI came from the common challenge of non-technical users struggling to access and query databases without SQL knowledge. In my data analysis experience, I've seen how AI like ChatGPT can simplify complex tasks. I wanted to create an accessible tool that lets anyone "chat" with their data using natural language, bridging the gap between AI and databases. Built for a hackathon, it showcases how free LLMs can power practical apps to democratize data insights.

What it does

SQL_Chat_AI is an AI agent that converts natural language queries (e.g., "Top 5 employees by salary") into SQL, executes them on SQLite or MySQL databases, and returns human-readable answers. Users configure DB/LLM via a React UI, which calls a FastAPI backend. It supports free LLMs like Groq, handles conversational follow-ups with memory, and ingests data from CSVs—making data querying intuitive and cost-free.

How we built it

We started with data ingestion scripts (db_prep_*.py) using Pandas/SQLAlchemy to load CSVs into DBs. The core AI in agent.py uses LangChain's create_sql_agent with free LLMs (Groq/OpenRouter) and conversation memory. Backend (backend.py) is FastAPI with /connect and /query endpoints. Frontend (App.js) is React with forms for DB config, Axios for API calls, and chat history display. We iterated on imports for LangChain compatibility and tested with sample data.

Challenges we ran into

LangChain's evolving API caused import errors (e.g., moved modules like ConversationBufferMemory), fixed by version upgrades and venv recreates. Dependency conflicts (Pydantic/LangChain-core) required pinning. Integrating free LLMs involved key setup and rate limit handling. DB connections (especially MySQL auth) and CORS for local dev were tricky, solved with middleware and dynamic URIs.

Accomplishments that we're proud of

We built a full-stack, end-to-end app that's fully functional with free resources—no paid APIs needed. It handles real conversational queries with memory, supports multiple DBs, and includes sample data for easy demos. Overcoming LangChain issues made it robust, and the clean UI/backend separation ensures scalability. Proudest: Making advanced AI accessible for hackathon-level deployment.

What we learned

Deepened expertise in LangChain for NL-to-SQL agents and modular imports. Learned full-stack integration: React state management/Axios, FastAPI async APIs, and ETL with Pandas. Gained insights into free LLM ecosystems (e.g., Groq's speed) and handling env configs securely. Troubleshooting taught venv best practices and dependency resolution.

What's next for SQL_Chat_AI: NL-to-SQL Agent

Add more free LLMs (e.g., Ollama local), support advanced queries (joins/aggregates), and integrate visualizations (e.g., charts from query results). Enhance security with query validation/user auth, deploy to cloud (Vercel/Heroku), and expand to other DBs like PostgreSQL. Open-source contributions for community features like multi-language support.

Built With

  • agenticai
  • fastapi
  • langchain
  • react
Share this project:

Updates