Skip to content

Denny-Lin/ai-agent-ecommerce-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Agent E-commerce Backend

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.


Features

  • 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

Project Structure

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

Architecture

User
 ↓
FastAPI API (/agent)
 ↓
LLM (Ollama)
 ↓
AI Agent Logic
 ↓
Tool Functions
 ├ get_products()
 ├ get_order()
 └ cancel_order()
 ↓
FastAPI Backend APIs
 ↓
In-memory Data Store

Installation

Clone the repository:

git clone https://github.com/yourname/ai-agent-ecommerce-backend.git
cd ai-agent-ecommerce-backend

Create a virtual environment:

/opt/homebrew/opt/python@3.11/bin/python3.11 -m venv venv

Activate the environment:

Mac / Linux:

source venv/bin/activate

Windows:

venv\Scripts\activate

Install dependencies:

pip install -r requirements.txt

Install Ollama

Download and install Ollama from the official website:

https://ollama.com/download

After installation, start the Ollama server:

ollama serve

Using Cloud Models

This project can use Ollama cloud models such as:

  • gpt-oss:20b-cloud
  • deepseek-v3.1-cloud

Make sure you login first:

ollama login

Run Backend Server

Start the FastAPI server:

uvicorn backend.server:app --reload

Server will run at:

http://127.0.0.1:8000

API documentation:

http://127.0.0.1:8000/docs

Testing

Run agent evaluation tests:

pytest tests/test_agent.py -s

Learning Objectives

This project demonstrates:

  • AI agent tool calling
  • Backend API interaction
  • FastAPI service development
  • Local LLM integration
  • AI + backend architecture design

Future Improvements

Potential extensions:

  • PostgreSQL database
  • Retrieval-Augmented Generation (RAG)
  • Chat UI interface
  • Authentication and user accounts
  • Order tracking integration
  • Customer support ticket system

About

Agentic AI e-commerce backend with FastAPI demonstrating tool calling and AI-driven workflows

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages