Skip to content

nayefroqaya/ecommerce-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-commerce Assistant – Multi-Agent System

This project implements a production-ready multi-agent customer service system for an e-commerce platform.
It supports multi-turn conversations and enforces business policies for:

  • Order Cancellation (with 24-hour rule)
  • Order Tracking
  • Product Information (knowledge base)
  • Session-based memory and state management
  • Structured and predictable outputs
  • Observability with logging
  • Mock external APIs using Beeceptor
  • Dockerized deployment

No third-party agent frameworks (LangChain, AutoGen, etc.) are used.
All agents are built from scratch in Python.


Architecture Overview

image

Agents

OrderCancellationAgent

Validates order ID format: ORD-XXXX

Calls /order-details to check order age

Enforces 24-hour cancellation policy

Calls /order-cancel only if eligible

OrderTrackingAgent

Validates order ID

Calls /order-track

Returns order status and estimated delivery date

ProductInfoAgent

📦 Project Structure

app/
 ├── main.py
 ├── agents.py
 ├── state.py
 ├── ml_intent.py
 ├── product_knowledge.json
Dockerfile
docker-compose.yml
requirements.txt
README.md
architecture.png

🧠 Extra - Simple Machine Learning Component (Intent Classification)

This project includes an optional lightweight ML component to improve intent routing in the OrchestratorAgent.

What it does

Instead of relying only on keyword rules (e.g., checking if the message contains the word "cancel" or "track"), the orchestrator can use a small TF-IDF + Naive Bayes model to classify the user’s intent into one of:

  • cancel → route to OrderCancellationAgent
  • track → route to OrderTrackingAgent
  • product → route to ProductInfoAgent

This makes routing more robust for messages like:

  • “I want a refund for my purchase” → cancel
  • “Where is my package?” → track

Where it lives (files)

  • app/ml_intent.py → trains a small classifier and exposes predict_intent(message)
  • app/main.py → calls predict_intent() inside the Orchestrator routing logic

How to enable/disable

In app/main.py:

  • Set USE_ML_INTENT = True to enable
  • Set USE_ML_INTENT = False to disable and use keyword routing only

How to test the ML routing

Send these requests to POST /chat (via Swagger UI at /docs or curl):

Cancel intent (no "cancel" keyword):

{"session_id":"ml1","message":"I want a refund for my purchase ORD-1234"}



###  Compliance with Challenge Requirements

Multi-agent architecture: ✅

Order cancellation & tracking policies: ✅

24-hour rule: ✅

Multi-turn state management: ✅

Structured outputs: ✅

Observability (logging): ✅

Mock APIs (Beeceptor): ✅

Dockerized: ✅

No third-party agent frameworks used: ✅

Supports multi-turn context via last_product







About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors