Skip to main content

Product Catalog Chatbot with AI-Enhanced Management System

An intelligent product catalog management platform powered by Docker Model Runner, AI Agents, and Event-Driven Architecture. This system combines conversational AI, intelligent agents, and real-time processing for comprehensive catalog management.

๐ŸŽฏ System Overviewโ€‹

This is a complete AI-enhanced catalog management system featuring:

๐Ÿค– Core AI Componentsโ€‹

  • Chatbot Interface - Natural language product queries and conversations
  • AI Agent Service - Automated vendor evaluation, market research, and customer matching
  • MCP Gateway - Model Context Protocol for AI tool orchestration
  • Model Runner Integration - Local AI model execution with Llama 3.2

๐Ÿ—๏ธ Complete Architectureโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Frontend โ”‚ โ”‚ Agent Portal โ”‚ โ”‚ Chatbot UI โ”‚
โ”‚ Port: 5173 โ”‚ โ”‚ Port: 3001 โ”‚ โ”‚ Port: 5174 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Backend API โ”‚ โ”‚ Agent Service โ”‚ โ”‚ Chatbot API โ”‚
โ”‚ Port: 3000 โ”‚ โ”‚ Port: 7777 โ”‚ โ”‚ Port: 8082 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MCP Gateway โ”‚ โ”‚ Model Runner โ”‚
โ”‚ Port: 8811 โ”‚ โ”‚ (Local AI) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚ โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ PostgreSQL โ”‚ โ”‚ MongoDB โ”‚ โ”‚ Kafka โ”‚
โ”‚ Port: 5432 โ”‚ โ”‚ Port: 27017 โ”‚ โ”‚ Port: 9092 โ”‚
โ”‚ (Products DB) โ”‚ โ”‚ (Agent History) โ”‚ โ”‚ (Event Stream) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Startโ€‹

Prerequisitesโ€‹

  • Docker Desktop with Model Runner enabled
  • At least 8GB RAM (4GB+ for AI models)
  • Docker Compose v2.0+

1. Pull Required Modelsโ€‹

# Pull the AI model for chatbot and agents
docker model pull ai/llama3.2:1B-Q8_0

2. Start All Servicesโ€‹

# Clone the repository
git clone https://github.com/ajeetraina/catalog-service-node-chatbot.git
cd catalog-service-node-chatbot

# Start the complete system
docker compose up -d --build

3. Access the Applicationsโ€‹

ServiceURLDescription
๐Ÿค– Chatbot Interfacehttp://localhost:5174Main chatbot for product queries
๐Ÿ  Main Frontendhttp://localhost:5173Product catalog management
๐Ÿ”ง Agent Portalhttp://localhost:3001AI agent management interface
๐Ÿ“Š Kafka UIhttp://localhost:8080Event streaming monitoring
๐Ÿ—„๏ธ pgAdminhttp://localhost:5050Database administration

๐Ÿ’ฌ Chatbot Capabilitiesโ€‹

Note: After running sh add-products.sh, your chatbot will have access to 50+ sample products for testing these capabilities.

User: "Show me all electronics under $500"
Chatbot: "I found 8 electronics products under $500:

๐Ÿ“ฑ iPhone SE - $399.00
Compact smartphone with A15 Bionic chip

๐ŸŽง Sony WH-1000XM5 - $399.00
Industry-leading noise canceling headphones

โŒš Apple Watch - $249.00
Advanced health and fitness tracking

[Additional products...]

Would you like details about any specific product?"

Intelligent Category Browsingโ€‹

User: "What's popular in home electronics?"
Chatbot: "Based on our catalog data:

๐Ÿ  Smart Home Category (12 products):
โ€ข Smart speakers: 4 products ($49-199)
โ€ข Security cameras: 3 products ($89-299)
โ€ข Smart thermostats: 2 products ($149-249)
โ€ข Home automation hubs: 3 products ($99-349)

The Amazon Echo Dot and Ring Doorbell are our top sellers.
Which type of smart home device interests you?"

Catalog Analyticsโ€‹

User: "Give me a summary of the catalog"
Chatbot: "Here's your catalog overview:

๐Ÿ“Š **Catalog Statistics:**
โ€ข Total Products: 127
โ€ข Active Categories: 8
โ€ข Price Range: $9.99 - $2,499.00
โ€ข Average Price: $186.45
โ€ข New This Week: 5 products

๐Ÿ”ฅ **Top Categories:**
1. Electronics (34 products)
2. Clothing (28 products)
3. Home & Garden (21 products)

Is there a specific category you'd like to explore?"

๐Ÿค– AI Agent Systemโ€‹

The system includes intelligent agents powered by Model Runner:

๐Ÿ” Vendor Intake Agentโ€‹

  • Purpose: Evaluates new product submissions
  • Scoring: 0-100 AI-powered evaluation
  • Criteria: Product quality, market fit, pricing analysis
  • Integration: Kafka events trigger automatic evaluation

๐Ÿ“ˆ Market Research Agentโ€‹

  • Purpose: Automated competitor analysis
  • Features: Price comparison, feature analysis, market positioning
  • Data Sources: Web scraping, API integrations via MCP Gateway
  • Output: Comprehensive market reports

๐ŸŽฏ Customer Match Agentโ€‹

  • Purpose: Analyzes customer preferences and buying patterns
  • Intelligence: ML-based recommendation engine
  • Personalization: Tailored product suggestions
  • History: Stored in MongoDB for continuous learning

๐Ÿ“‹ Catalog Management Agentโ€‹

  • Purpose: Maintains and optimizes product catalog
  • Automation: Auto-categorization, price updates, inventory sync
  • Quality Control: Duplicate detection, data validation
  • Optimization: SEO improvements, description enhancement

โš™๏ธ Model Runner Configurationโ€‹

Supported Modelsโ€‹

ModelSizePerformanceUse Case
ai/llama3.2:1B-Q4_01GBFastChatbot, basic agents
ai/llama3.2:1B-Q8_01.5GBBalancedRecommended
ai/llama3.2:3B-Q4_02GBHigh QualityComplex agent tasks

Environment Configurationโ€‹

# Model Runner integration in compose.yaml
models:
llama_model:
model: ai/llama3.2:1B-Q8_0

# Services using Model Runner
chatbot-backend:
models:
llama_model:
endpoint_var: MODEL_RUNNER_URL
model_var: MODEL_RUNNER_MODEL

agent-service:
models:
llama_model:
endpoint_var: MODEL_RUNNER_URL
model_var: MODEL_RUNNER_MODEL

mcp-gateway:
models:
llama_model:
endpoint_var: MODEL_RUNNER_URL
model_var: MODEL_RUNNER_MODEL

๐Ÿ”ง Core Services Deep Diveโ€‹

Chatbot Backend (chatbot-backend)โ€‹

  • Port: 8082
  • Purpose: Natural language processing for product queries
  • AI Integration: Direct Model Runner connection
  • Database: PostgreSQL for product data
  • Features: Intent recognition, smart search, conversation context

Agent Service (agent-service)โ€‹

  • Port: 7777
  • Purpose: AI agents for automation and intelligence
  • Event Processing: Kafka-based event handling
  • Databases: PostgreSQL (catalog) + MongoDB (history)
  • Agents: Vendor evaluation, market research, customer matching

MCP Gateway (mcp-gateway)โ€‹

  • Port: 8811
  • Purpose: AI tool orchestration and integration
  • Protocols: Server-Sent Events (SSE) transport
  • Tools: fetch, brave, resend, curl, mongodb
  • Role: Enables agents to access external data sources

Backend API (backend)โ€‹

  • Port: 3000
  • Purpose: Core catalog management API
  • Database: PostgreSQL primary, MongoDB secondary
  • Integration: Agent service communication
  • Features: CRUD operations, vendor management, analytics

๐Ÿ“Š Event-Driven Architectureโ€‹

Kafka Integrationโ€‹

# Kafka configuration for real-time processing
kafka:
image: apache/kafka:latest
ports: ["9092:9092", "9093:9093"]

# Event flow examples:
# 1. New product โ†’ Agent evaluation โ†’ Catalog update
# 2. User query โ†’ Agent research โ†’ Enhanced response
# 3. Price change โ†’ Market analysis โ†’ Competitive insights

Event Typesโ€‹

  • Product Events: Creation, updates, deletions
  • Agent Events: Evaluation results, research findings
  • User Events: Interactions, preferences, feedback
  • System Events: Health checks, performance metrics

๐Ÿ—„๏ธ Database Architectureโ€‹

PostgreSQL (Primary Database)โ€‹

-- Core product catalog
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
category VARCHAR(100),
price DECIMAL(10, 2),
vendor_id VARCHAR(100),
ai_score INTEGER, -- AI evaluation score
status VARCHAR(20) DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Vendor management
CREATE TABLE vendors (
id VARCHAR(100) PRIMARY KEY,
name VARCHAR(255),
evaluation_score INTEGER,
status VARCHAR(20)
);

MongoDB (Agent History)โ€‹

// Agent interaction history
{
agentType: "vendor_evaluation",
productId: "12345",
evaluation: {
score: 85,
reasoning: "High quality, competitive pricing",
criteria: ["quality", "price", "market_fit"]
},
timestamp: "2025-01-15T10:30:00Z"
}

// Customer interaction patterns
{
sessionId: "abc123",
interactions: [
{ query: "electronics under $200", results: 5 },
{ action: "view_product", productId: "67890" }
],
preferences: ["electronics", "budget_conscious"]
}

๐Ÿ› ๏ธ API Endpointsโ€‹

Chatbot API (localhost:8082)โ€‹

# Natural language chat
POST /api/chat
{
"message": "Show me laptops for programming"
}

# Product search with filters
GET /api/products/search?q=laptop&category=electronics&maxPrice=1500

# Get conversation context
GET /api/context/{sessionId}

Agent Service API (localhost:7777)โ€‹

# Trigger vendor evaluation
POST /api/agents/evaluate-vendor
{
"vendorId": "tech_corp_001",
"products": ["product_123", "product_456"]
}

# Get market research report
GET /api/agents/market-research/{productId}

# Customer preference analysis
POST /api/agents/analyze-customer
{
"customerId": "user_789",
"interactionHistory": [...]
}

Main Backend API (localhost:3000)โ€‹

# Product management
GET /api/products
POST /api/products
PUT /api/products/{id}
DELETE /api/products/{id}

# Vendor management
GET /api/vendors
POST /api/vendors
GET /api/vendors/{id}/evaluation

# Analytics
GET /api/analytics/summary
GET /api/analytics/trends

๐Ÿ” Development & Testingโ€‹

Local Development Setupโ€‹

# Start infrastructure only
docker compose up postgres mongodb kafka -d

# Run services locally for development
cd chatbot-backend && npm run dev # Port 8082
cd agent-service && npm run dev # Port 7777
cd backend && npm run dev # Port 3000

Health Checksโ€‹

# Check all service health
curl http://localhost:3000/health # Backend
curl http://localhost:8082/health # Chatbot
curl http://localhost:7777/health # Agents
curl http://localhost:8811/health # MCP Gateway

# Check Model Runner status
docker model ls
docker model info ai/llama3.2:1B-Q8_0

Testing the Chatbotโ€‹

# Test natural language queries
curl -X POST http://localhost:8082/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "What are your most expensive electronics?"}'

# Test product search
curl "http://localhost:8082/api/products/search?q=smartphone&maxPrice=800"

# Test category lookup
curl http://localhost:8082/api/categories

๐Ÿ“ˆ Monitoring & Observabilityโ€‹

Service Monitoringโ€‹

  • Kafka UI: http://localhost:8080 - Event stream monitoring
  • pgAdmin: http://localhost:5050 - Database monitoring
  • Docker Logs: docker compose logs [service-name]
  • Health Endpoints: Built-in health checks for all services

Performance Metricsโ€‹

# Check resource usage
docker stats

# Monitor model performance
docker model stats ai/llama3.2:1B-Q8_0

# View service logs
docker compose logs -f chatbot-backend
docker compose logs -f agent-service

๐Ÿš€ Adding Products & Dataโ€‹

Automated Product Importโ€‹

# Use the provided import script
./add-products.sh

# Or use the Node.js automation script
npm run import-products

Testing with Sample Dataโ€‹

The system includes comprehensive sample data:

  • 50+ Products across multiple categories
  • Vendor Information with AI evaluations
  • Mock Market Data for agent testing
  • Customer Interaction Patterns for recommendation testing

๐Ÿ”’ Production Considerationsโ€‹

Securityโ€‹

  • Environment Variables: Use Docker secrets for production
  • Network Security: Configure proper firewall rules
  • Database Security: Enable PostgreSQL/MongoDB authentication
  • API Security: Implement rate limiting and authentication

Scalingโ€‹

  • Horizontal Scaling: Multiple instances of each service
  • Database Sharding: Partition large datasets
  • Model Optimization: Use quantized models for performance
  • Caching: Redis for frequently accessed data

Deploymentโ€‹

# Production environment variables
environment:
- NODE_ENV=production
- MODEL_RUNNER_URL=${MODEL_RUNNER_URL}
- POSTGRES_HOST=${POSTGRES_HOST}
- KAFKA_BROKERS=${KAFKA_BROKERS}
- MONGODB_URI=${MONGODB_URI}

๐ŸŽฏ Quick Start Checklistโ€‹