A multi-agent AI system that answers business questions in plain English β powered by CrewAI, Google Gemini, and Streamlit.
Northwind Agentic AI is a multi-agent agentic AI system that lets users query the Northwind business database using plain English β no SQL knowledge required.
The system uses 3 specialised AI agents working in sequence:
- SQL Writer Agent β Translates a natural language question into a SQLite query
- SQL Executor Agent β Runs the query against the Northwind database
- Visualizer Agent β Generates a chart and business insight from the results
All agents are orchestrated by CrewAI and presented through a Streamlit web interface with a custom dark theme.
Business data locked inside databases is inaccessible to non-technical users. Analysts spend time writing repetitive queries instead of generating insights. This project solves that by:
- Allowing anyone to ask business questions in plain English
- Automatically generating accurate SQL from natural language
- Turning raw data into visualisations and insights instantly
- Demonstrating a real-world agentic AI pipeline architecture
User (Plain English Question)
β
βΌ
βββββββββββββββββββ
β Streamlit UI β β app.py
β (Dark Theme) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β CrewAI Orchestrator β
β crew/northwind_crew.py β
ββββββββ¬βββββββββββββββ¬ββββββββββββββββ¬ββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββββββ
β Agent 1 β β Agent 2 β β Agent 3 β
βSQL WriterββββΆβExecutor ββββΆβ Visualizer β
ββββββββββββ ββββββββββββ ββββββββββββββββ
β β β
βΌ βΌ βΌ
SQL Query SQLite DB Chart + Insight
Northwind.db (matplotlib)
Northwind-Agentic-AI/
β
βββ agents/ # AI Agent definitions
β βββ sql_writer.py # Agent 1: writes SQL queries
β βββ executer.py # Agent 2: executes SQL
β βββ visualizer.py # Agent 3: generates charts & insights
β
βββ tasks/ # Task instructions for each agent
β βββ sql_task.py
β βββ execute_task.py
β βββ visualizer_task.py
β
βββ crew/ # CrewAI pipeline orchestrator
β βββ northwind_crew.py
β
βββ tools/ # Custom CrewAI tools
β βββ db_tool.py # ExecuteSQLTool β runs SQL on Northwind DB
β
βββ utils/ # Utilities
β βββ llm_factory.py # LLM switcher: Gemini / OpenAI / Groq
β
βββ northwind_db/ # Database manager
β βββ db_manager.py # Auto-downloads northwind.db if missing
β
βββ data/ # Database file (auto-generated)
β βββ northwind.db
β
βββ assets/ # Frontend styling
β βββ styles.css # Dark theme CSS for Streamlit
β
βββ tests/ # Offline tests (no API needed)
β βββ test_db.py
β
βββ app.py # Streamlit web application
βββ .env # API keys (not committed to Git)
βββ .gitignore
βββ requirements.txt
βββ README.md
| Layer | Technology |
|---|---|
| AI Framework | CrewAI |
| LLM β Primary | Google Gemini 2.0 Flash Lite |
| LLM β Alternative | Groq (Llama 3.1 8b Instant) |
| LLM β Alternative | OpenAI GPT-4o Mini |
| LLM Routing | LangChain + LiteLLM |
| Database | SQLite (Northwind dataset) |
| Data Processing | Pandas |
| Visualisation | Matplotlib |
| Web UI | Streamlit |
| Language | Python 3.11 |
- Python 3.11 or higher
- Node.js (optional β only if regenerating the PowerPoint)
- A free API key from one of: Google AI Studio, Groq, or OpenAI
git clone https://github.com/smshelar/northwind-agentic-ai.git
cd northwind-agentic-aipython3.11 -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windowspip install --upgrade pip
pip install -r requirements.txtCreate a .env file in the project root:
# Choose ONE provider and add its key
GOOGLE_API_KEY=your_gemini_key_here
LLM_PROVIDER=google
# Or use Groq (free, fast)
# GROQ_API_KEY=your_groq_key_here
# LLM_PROVIDER=groq
# Or use OpenAI
# OPENAI_API_KEY=your_openai_key_here
# LLM_PROVIDER=openaiπ‘ Get a free Gemini API key at aistudio.google.com β no credit card required.
python tests/test_db.pyAll 7 tests should pass β this confirms your database and chart logic work before spending API quota.
streamlit run app.pyOpen http://localhost:8501 in your browser.
Try asking these in the app:
Sales Analysis
- What were the top 5 products by total sales revenue?
- Which product category generates the most revenue?
- What is the total revenue generated per year?
Customer Analysis
- Which customers have placed the most orders?
- Who are the top 10 customers by total amount spent?
- Which country has the most customers?
Employee Performance
- Which employee has handled the most orders?
- What is the total sales revenue generated by each employee?
Inventory
- Which products are running low on stock?
- Which products have never been ordered?
β οΈ The Northwind database contains data from 1996, 1997, and 1998 only.
Change the LLM_PROVIDER in your .env file β no code changes needed:
| Provider | .env setting |
Model used | Free? |
|---|---|---|---|
| Google Gemini | LLM_PROVIDER=google |
gemini-2.0-flash-lite | β Yes |
| Groq | LLM_PROVIDER=groq |
llama-3.1-8b-instant | β Yes |
| OpenAI | LLM_PROVIDER=openai |
gpt-4o-mini | β Paid |
The tests/test_db.py file validates everything that doesn't need an LLM:
python tests/test_db.pyThis tests:
- β Database connection
- β Available years in the data
- β
Table names (including
[Order Details]with space) - β Top products query
- β Top customers query
- β Monthly revenue query
- β
Chart rendering (saves
test_chart.png)
| Error | Fix |
|---|---|
ModuleNotFoundError: crewai |
Run pip install -r requirements.txt with Python 3.11 venv activated |
GOOGLE_API_KEY not found |
Check .env has no quotes or spaces around the = |
Rate limit exceeded |
Wait 1 minute and retry, or switch LLM_PROVIDER in .env |
No such table: OrderDetails |
Use [Order Details] with square brackets β the schema is fixed in sql_writer.py |
Executor returned non-JSON |
Known issue with small LLMs β SQL now executes directly in Python |
Python 3.9 venv |
Delete venv, recreate with python3.11 -m venv venv |
- Conversation memory β remember previous questions in the session
- Query history β save and replay past questions
- Export results to CSV / Excel
- Better error messages with suggested rephrasing
- Support for multiple databases beyond Northwind
- Voice input β ask questions by speaking
- Dashboard mode β pin favourite charts
- Scheduled email reports
- Fine-tuned SQL model on company-specific schemas
- Role-based access control
- Predictive analytics and trend forecasting
- Integration with Tableau / Power BI
Customers βββ
ββββΆ Orders βββΆ [Order Details] βββΆ Products βββΆ Categories
Employees βββ ββββΆ Suppliers
Shippers βββββββββββΆ Orders
Key tables:
Customersβ company info, country, cityOrdersβ order dates, customer, employee, shipper[Order Details]β products, quantities, prices per orderProductsβ product names, categories, stock levelsEmployeesβ sales rep info
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m "Add my feature" - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
- CrewAI β multi-agent AI framework
- Northwind Dataset β sample business database
- Google Gemini β LLM provider
- Streamlit β web UI framework
- Groq β fast free LLM inference
A practical demonstration of Agentic AI for business intelligence