A backend system that enables users to interact with e-commerce data using natural language instead of writing SQL. This project bridges the gap between non-technical queries and structured databases by leveraging a locally deployed large language model.
This application acts as an intelligent query layer on top of an e-commerce dataset. Users can ask business questions in plain English, and the system interprets the intent, generates optimized SQL queries, executes them, and returns structured results in real time.
The entire pipeline runs locally, ensuring data privacy and eliminating dependency on external APIs.
- Replaces traditional dashboards with a conversational interface
- Demonstrates practical use of LLMs in backend systems
- Eliminates the need for manual SQL writing
- Designed for fast iteration and extensibility
- User submits a natural language query
- LLM interprets intent and generates SQL
- Query is validated and executed on SQLite
- Results are formatted and returned via API
- (Optional) Response is streamed token-by-token
| Layer | Description |
|---|---|
| Language Model | Local LLaMA 3 model via Ollama for SQL generation |
| API Layer | FastAPI service handling requests and responses |
| Data Layer | SQLite database populated from Excel datasets |
| Processing Layer | Python scripts for transformation and execution |
E-commerce-ai-agent/
├── api_server.py # API entry point
├── llama_sql_generator.py # Converts text → SQL
├── llama_sql_executor.py # Handles SQL execution
├── load_data_to_db.py # Data ingestion script
├── ecommerce.db # Local database
├── Product-Level *.xlsx # Source data files
├── test_database_queries.py# Debug/testing utilities
├── README.md # Documentation
├── resume.md # Project summary
- Business performance analysis without traditional BI tools
- Rapid ad-hoc querying of sales and marketing data
- Internal analytics assistant for non-technical teams
- Prototype for AI-powered data copilots
- SQL generation handled by a local LLM
- No cloud dependencies or external API costs
- Modular Python design for easy extension and maintenance
- Streaming responses improve interactivity and user experience
git clone https://github.com/hectorr-st/E-commerce-ai-agent.git
cd E-commerce-ai-agent
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
ollama run llama3
python load_data_to_db.py
uvicorn api_server:app --reload