An AI agent powered e-commerce backend built with FastAPI.
This project demonstrates how an AI agent can interact with backend APIs using tool calling to perform e-commerce related tasks.
The system uses a LLM (Ollama) to decide which tools to call.
- AI Agent with tool calling
- LLM integration using Ollama (local or cloud models)
- FastAPI backend service
- Order management API
- Product query API
- Example AI-agent interaction workflow
ai-agent-ecommerce-backend/
│
├── backend/
│ └── server.py
│
├── agent/
│ └── agent.py
│
├── tools/
│ └── order_tools.py
│
├── models/
│ ├── order.py
│ └── product.py
│
├── tests/
│ └── test_api.py
│
├── requirements.txt
└── README.md
User
↓
FastAPI API (/agent)
↓
LLM (Ollama)
↓
AI Agent Logic
↓
Tool Functions
├ get_products()
├ get_order()
└ cancel_order()
↓
FastAPI Backend APIs
↓
In-memory Data Store
Clone the repository:
git clone https://github.com/yourname/ai-agent-ecommerce-backend.git
cd ai-agent-ecommerce-backendCreate a virtual environment:
/opt/homebrew/opt/python@3.11/bin/python3.11 -m venv venvActivate the environment:
Mac / Linux:
source venv/bin/activateWindows:
venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtDownload and install Ollama from the official website:
After installation, start the Ollama server:
ollama serveThis project can use Ollama cloud models such as:
- gpt-oss:20b-cloud
- deepseek-v3.1-cloud
Make sure you login first:
ollama loginStart the FastAPI server:
uvicorn backend.server:app --reloadServer will run at:
http://127.0.0.1:8000
API documentation:
http://127.0.0.1:8000/docs
Run agent evaluation tests:
pytest tests/test_agent.py -sThis project demonstrates:
- AI agent tool calling
- Backend API interaction
- FastAPI service development
- Local LLM integration
- AI + backend architecture design
Potential extensions:
- PostgreSQL database
- Retrieval-Augmented Generation (RAG)
- Chat UI interface
- Authentication and user accounts
- Order tracking integration
- Customer support ticket system