Skip to content

Graceli95/Agentic_Customer_Project1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

215 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Advanced Multi-Agent Customer Service AI

An intelligent, agentic customer service system powered by LangChain v1.0+ and LangGraph.

Current Status: Phase 6 Complete βœ… - MVP PRODUCTION READY

This is a complete, portfolio-ready multi-agent customer service system featuring:

  • πŸ€– Multi-Provider LLMs: AWS Bedrock (Nova Lite) for routing + OpenAI (GPT-4o-mini) for generation
  • πŸ”„ Real-Time Streaming: Server-Sent Events (SSE) with user toggle
  • πŸ“š Advanced RAG/CAG: Pure RAG, Pure CAG, and Hybrid strategies
  • 🎯 4 Specialized Agents: Technical Support, Billing, Compliance, and General Information
  • πŸ§ͺ Production Quality: 145 tests passing (91% coverage)

A supervisor agent intelligently routes queries to specialized workers while maintaining conversation memory across routing.

πŸš€ Quick Start

# 1. Clone the repository
git clone <repository-url>
cd Agentic_Customer_Project1

# 2. Set up the backend (FastAPI + LangChain)
cd backend
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY
uvicorn main:app --reload

# 3. In a new terminal, set up the frontend (Next.js + TypeScript)
cd frontend
pnpm install
cp .env.example .env.local
# Edit .env.local if needed (default: http://localhost:8000)
pnpm dev

Access the application:


✨ Features (Phase 6 Complete - MVP Ready)

πŸ€– Multi-Provider LLM Architecture

  • Supervisor Agent: AWS Bedrock Nova Lite ($0.06/1M tokens) for cost-effective routing
  • Worker Agents: OpenAI GPT-4o-mini ($0.15/1M tokens) for high-quality responses
  • Automatic Fallback: Gracefully falls back to OpenAI if AWS unavailable
  • 11% Cost Savings: Optimized model selection for each task

πŸ”„ Real-Time Streaming Responses

  • Server-Sent Events (SSE): Token-by-token streaming for immediate user feedback
  • Toggle Mode: Switch between streaming (real-time) and standard (single response)
  • Smooth UX: No flicker, graceful error recovery, visual indicators
  • Production Ready: Full error handling and session continuity

πŸ“š Advanced RAG/CAG Knowledge System

  • Pure RAG (Technical & General): Dynamic document retrieval from ChromaDB
  • Hybrid RAG/CAG (Billing): First query retrieves, subsequent queries use cache
  • Pure CAG (Compliance): Pre-loaded context for instant, consistent responses
  • 8 Document Repository: 2 documents per domain (technical, billing, compliance, general)

🎯 4 Specialized Worker Agents

πŸ› οΈ Technical Support (Pure RAG)

  • Errors, bugs, crashes, and software malfunctions
  • Installation, configuration, and setup issues
  • Performance problems and diagnostics
  • Step-by-step troubleshooting from knowledge base

πŸ’³ Billing Support (Hybrid RAG/CAG)

  • Payment methods and processing
  • Invoice inquiries and unexpected charges
  • Subscription management (upgrade, downgrade, cancel)
  • Cached pricing information after first query

πŸ“‹ Compliance (Pure CAG)

  • Terms of Service and policy questions
  • Privacy policy and data collection practices
  • GDPR, CCPA, and data protection regulations
  • Instant responses from pre-loaded documents

πŸ“š General Information (Pure RAG)

  • Company background and mission
  • Service offerings and features
  • Getting started guides and onboarding
  • Dynamic retrieval from general knowledge base

πŸ”€ Intelligent Routing & Memory

  • Domain-specific query analysis and routing
  • Conversation context maintained across routing
  • Session persistence across page refreshes
  • Clear conversation to start fresh
  • Detailed logging (πŸ”€ ROUTING, βœ‹ DIRECT indicators)

🎨 Modern Full-Stack Interface

  • Backend: FastAPI with /chat and /chat/stream endpoints
  • Frontend: Next.js 16 with TypeScript and Tailwind CSS
  • Real-time Updates: Token-by-token streaming display
  • User Controls: Streaming toggle, clear conversation, error handling
  • Type Safety: Full TypeScript + Pydantic validation

βœ… Production Quality

  • 145 Automated Tests: 129 unit + 16 integration tests
  • 91% Code Coverage: All worker agents thoroughly tested
  • Comprehensive Docs: Setup guides, architecture, API docs
  • Error Handling: Graceful fallbacks and user-friendly messages
  • LangSmith Support: Full tracing and debugging
  • AWS Setup Guide: Complete 409-line setup documentation

πŸš€ Try It Out

  1. Start the application (see Quick Start above)
  2. Open http://localhost:3000
  3. Test streaming: Enable streaming toggle (lightning bolt icon)
  4. Test technical query: "Getting Error 500 when logging in"
    • Watch response stream token-by-token
    • Check logs for πŸ”€ ROUTING to Technical Support
  5. Test billing query: "What are your pricing plans?"
    • First query retrieves from vector store (RAG)
    • Second query uses cached policies (CAG)
  6. Test compliance query: "What's your data retention policy?"
    • Instant response from pre-loaded compliance docs
  7. Test memory: Follow up with "Can you explain more?"
    • Context maintained across routing

πŸ“‹ Table of Contents


🎯 Overview

This project implements a production-ready, intelligent customer service AI system powered by LangChain v1.0+, AWS Bedrock, and OpenAI.

MVP Complete - All 6 Phases Finished:

A sophisticated multi-agent system featuring:

  • πŸ€– Multi-Provider LLMs: AWS Bedrock Nova Lite for routing, OpenAI GPT-4o-mini for generation
  • πŸ”„ Real-Time Streaming: Server-Sent Events (SSE) with user toggle between streaming/standard modes
  • πŸ“š Advanced RAG/CAG: Pure RAG, Pure CAG, and Hybrid strategies for optimal knowledge retrieval
  • 🎯 4 Specialized Agents: Technical Support, Billing, Compliance, and General Information
  • 🧠 Stateful Memory: Conversation context maintained across routing with InMemorySaver
  • πŸ”€ Intelligent Routing: Domain-specific query analysis and agent selection
  • 🎨 Modern Full-Stack: FastAPI backend + Next.js frontend with TypeScript
  • πŸ§ͺ Production Quality: 145 tests (91% coverage), comprehensive error handling

Key Technologies:

Component Technology Purpose
Backend FastAPI + Python 3.11+ REST API and agent orchestration
AI Framework LangChain v1.0+ & LangGraph Multi-agent system and workflows
LLM Providers AWS Bedrock + OpenAI Multi-provider strategy for cost optimization
Vector Store ChromaDB Document retrieval and semantic search
Frontend Next.js 16 + TypeScript Modern, responsive web interface
Styling Tailwind CSS v4 Beautiful, utility-first design
Package Manager pnpm Fast, efficient dependency management
Testing pytest + TypeScript 145 automated tests, 91% coverage

πŸ—οΈ Architecture

Phase 6 Complete - Production-Ready Multi-Agent System:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Frontend (Next.js + TypeScript)             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Chat Interface (with Streaming Toggle)            β”‚ β”‚
β”‚  β”‚  β€’ Real-time SSE streaming or standard responses   β”‚ β”‚
β”‚  β”‚  β€’ Message history with session persistence        β”‚ β”‚
β”‚  β”‚  β€’ User controls (clear, toggle streaming)         β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ POST /chat or /chat/stream
                          β”‚ {message, session_id}
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚            Backend (FastAPI + LangChain v1.0+)           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ /chat (standard) β”‚  β”‚ /chat/stream (SSE streaming) β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             Supervisor Agent (AWS Nova Lite)             β”‚
β”‚  β€’ Analyzes query domain (technical/billing/etc.)       β”‚
β”‚  β€’ Routes to appropriate worker agent                    β”‚
β”‚  β€’ Fallback to OpenAI GPT-4o-mini if AWS unavailable    β”‚
β”‚  β€’ Memory: InMemorySaver (cross-routing context)        β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚           β”‚             β”‚              β”‚
       ↓           ↓             ↓              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Technical β”‚ β”‚ Billing  β”‚ β”‚Complianceβ”‚ β”‚   General    β”‚
β”‚ Support  β”‚ β”‚ Support  β”‚ β”‚          β”‚ β”‚ Information  β”‚
β”‚          β”‚ β”‚          β”‚ β”‚          β”‚ β”‚              β”‚
β”‚ Pure RAG β”‚ β”‚ Hybrid   β”‚ β”‚ Pure CAG β”‚ β”‚  Pure RAG    β”‚
β”‚GPT-4o-mi β”‚ β”‚RAG/CAG   β”‚ β”‚GPT-4o-mi β”‚ β”‚ GPT-4o-mini  β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚            β”‚            β”‚               β”‚
     ↓            ↓            ↓               ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              RAG/CAG Knowledge System                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  ChromaDB    β”‚  β”‚   Cache    β”‚  β”‚  Pre-loaded    β”‚ β”‚
β”‚  β”‚  Vector      β”‚  β”‚  Session   β”‚  β”‚  Compliance    β”‚ β”‚
β”‚  β”‚  Store       β”‚  β”‚  Billing   β”‚  β”‚  Documents     β”‚ β”‚
β”‚  β”‚ (Technical,  β”‚  β”‚  Policies  β”‚  β”‚  (ToS, PP)     β”‚ β”‚
β”‚  β”‚  General)    β”‚  β”‚            β”‚  β”‚                β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components:

  • Multi-Provider LLMs: AWS Nova Lite ($0.06/1M) for supervisor, OpenAI GPT-4o-mini ($0.15/1M) for workers
  • Streaming Support: SSE for real-time responses, standard mode for single-response
  • 4 Worker Agents: Technical (Pure RAG), Billing (Hybrid), Compliance (Pure CAG), General (Pure RAG)
  • Knowledge Strategies:
    • Pure RAG: Dynamic retrieval from ChromaDB
    • Hybrid RAG/CAG: First query retrieves, subsequent use cache
    • Pure CAG: Pre-loaded static documents
  • Session Memory: InMemorySaver maintains context across routing
  • Automatic Fallback: Graceful degradation to OpenAI if AWS unavailable
  • Type Safety: Full TypeScript + Pydantic validation

For detailed architecture documentation, see:


βœ… Prerequisites

Before setting up this project, ensure you have the following installed:

Required for Backend

  • Python 3.11 or higher (Python 3.13 recommended)
    python3 --version  # Should be 3.11+
  • pip (Python package manager, usually comes with Python)
  • virtualenv or venv (for isolated Python environments)

Required for Frontend

  • Node.js v20 or higher
    node --version  # Should be v20+
  • pnpm v9 or higher (recommended package manager)
    # Install pnpm if needed
    npm install -g pnpm
    pnpm --version  # Should be v9+

Optional but Recommended

  • Docker & Docker Compose - For containerized deployment
  • Git - For version control (should already be installed)
  • Visual Studio Code - Recommended IDE with extensions:
    • Python
    • ESLint
    • Tailwind CSS IntelliSense
    • Prettier

API Keys Required

You'll need an OpenAI API key to run the agents:

  1. OpenAI API Key: Get from https://platform.openai.com/api-keys
  2. (Optional) LangSmith API Key: For debugging and tracing - https://smith.langchain.com/
  3. (Optional) AWS Credentials: If using AWS Bedrock models

πŸ“ Monorepo Structure

This is a monorepo containing both backend and frontend in a single repository:

Agentic_Customer_Project1/
β”œβ”€β”€ backend/                    # Python FastAPI backend
β”‚   β”œβ”€β”€ agents/                 # Agent modules (Phase 2-3)
β”‚   β”‚   β”œβ”€β”€ simple_agent.py     # Phase 2: Simple agent (reference)
β”‚   β”‚   β”œβ”€β”€ supervisor_agent.py # Phase 3: Supervisor βœ…
β”‚   β”‚   └── workers/            # Phase 3: Specialized workers βœ…
β”‚   β”‚       β”œβ”€β”€ billing_support.py    # Billing worker βœ…
β”‚   β”‚       β”œβ”€β”€ compliance.py         # Compliance worker βœ…
β”‚   β”‚       β”œβ”€β”€ general_info.py       # General info worker βœ…
β”‚   β”‚       └── technical_support.py  # Technical worker βœ…
β”‚   β”œβ”€β”€ data/                   # Data and documents
β”‚   β”‚   └── docs/              # Document repositories (Phase 5+)
β”‚   β”‚       β”œβ”€β”€ technical/     # Technical documentation
β”‚   β”‚       β”œβ”€β”€ billing/       # Billing documents
β”‚   β”‚       └── compliance/    # Compliance documents
β”‚   β”œβ”€β”€ tests/                  # Backend tests (54 tests βœ…)
β”‚   β”‚   β”œβ”€β”€ test_main.py        # API + routing integration tests
β”‚   β”‚   β”œβ”€β”€ test_agent.py       # Phase 2 agent tests
β”‚   β”‚   β”œβ”€β”€ test_supervisor.py  # Supervisor unit tests βœ…
β”‚   β”‚   └── test_technical_worker.py # Worker unit tests βœ…
β”‚   β”œβ”€β”€ utils/                  # Utility functions
β”‚   β”œβ”€β”€ main.py                # FastAPI app with supervisor routing βœ…
β”‚   β”œβ”€β”€ test_routing_logs.sh   # Routing test script βœ…
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   β”œβ”€β”€ .env.example          # Environment variables template
β”‚   β”œβ”€β”€ Dockerfile            # Backend container config
β”‚   └── README.md             # Backend documentation (Phase 3 βœ…)
β”‚
β”œβ”€β”€ frontend/                   # Next.js TypeScript frontend
β”‚   β”œβ”€β”€ app/                   # Next.js App Router pages
β”‚   β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ lib/                   # Frontend utilities
β”‚   β”œβ”€β”€ public/                # Static assets
β”‚   β”œβ”€β”€ package.json          # Frontend dependencies
β”‚   β”œβ”€β”€ tsconfig.json         # TypeScript configuration
β”‚   β”œβ”€β”€ .env.example          # Environment variables template
β”‚   └── README.md             # Frontend documentation
β”‚
β”œβ”€β”€ tasks/                      # Project management
β”‚   β”œβ”€β”€ 0001-prd-project-setup.md        # Phase 1 PRD
β”‚   β”œβ”€β”€ tasks-0001-prd-project-setup.md  # Phase 1 tasks
β”‚   β”œβ”€β”€ 0002-prd-simple-agent.md         # Phase 2 PRD
β”‚   β”œβ”€β”€ tasks-0002-prd-simple-agent.md   # Phase 2 tasks
β”‚   β”œβ”€β”€ 0003-prd-multi-agent-supervisor.md     # Phase 3 PRD βœ…
β”‚   └── tasks-0003-prd-multi-agent-supervisor.md # Phase 3 tasks βœ…
β”‚
β”œβ”€β”€ .github/                    # GitHub workflows and templates
β”‚   └── workflows/             # CI/CD pipelines
β”‚
β”œβ”€β”€ PHASE3_MULTI_AGENT_DEMO_GUIDE.md  # Phase 3 demo guide βœ…
β”œβ”€β”€ docker-compose.yml         # Docker orchestration
β”œβ”€β”€ ARCHITECTURE.md            # System architecture docs
β”œβ”€β”€ FLOWCHARTS.md             # Process flow diagrams
β”œβ”€β”€ PHASED_DEVELOPMENT_GUIDE.md # Development roadmap
β”œβ”€β”€ CONTRIBUTING.md           # Contribution guidelines
└── README.md                 # This file (Phase 3 βœ…)

Key Points:

  • Backend and Frontend are completely independent and can be developed separately
  • Each has its own dependencies, environment variables, and documentation
  • They communicate via REST API (backend exposes endpoints, frontend consumes them)
  • Both can be run independently or together using Docker Compose

πŸ› οΈ Setup Instructions

Backend Setup (Python + FastAPI)

  1. Navigate to backend directory:

    cd backend
  2. Create and activate virtual environment:

    # Create virtual environment
    python3 -m venv venv
    
    # Activate it
    # On macOS/Linux:
    source venv/bin/activate
    # On Windows:
    venv\Scripts\activate
  3. Install dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
  4. Configure environment variables:

    cp .env.example .env
    # Edit .env and add your API keys
    nano .env  # or use your preferred editor

    Required variables:

    OPENAI_API_KEY=your_openai_api_key_here
    ENVIRONMENT=development
    LOG_LEVEL=INFO
  5. Run the backend:

    uvicorn main:app --reload
    # Or simply:
    python main.py
  6. Verify it's working:

πŸ“š For detailed backend documentation, see backend/README.md


Frontend Setup (Next.js + TypeScript)

  1. Navigate to frontend directory:

    cd frontend
  2. Install dependencies:

    pnpm install
    # Or if you prefer npm:
    npm install
  3. Configure environment variables:

    cp .env.example .env.local
    # Edit if needed (default backend URL is http://localhost:8000)
  4. Run the development server:

    pnpm dev
    # Or with npm:
    npm run dev
  5. Verify it's working:

πŸ“š For detailed frontend documentation, see frontend/README.md


Docker Setup (Optional)

To run both backend and frontend using Docker:

# From the project root
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Note: Docker Compose configuration will be added in a future task.


πŸ”„ Development Workflow

Starting Development

  1. Start backend (Terminal 1):

    cd backend
    source venv/bin/activate  # Activate venv
    uvicorn main:app --reload
  2. Start frontend (Terminal 2):

    cd frontend
    pnpm dev
  3. Start coding!

    • Backend changes auto-reload with --reload flag
    • Frontend changes auto-reload with Fast Refresh

Code Quality

Backend (Python):

cd backend
# Lint and format
ruff check .
ruff format .

# Run tests
pytest

Frontend (TypeScript):

cd frontend
# Lint
pnpm lint

# Type check
pnpm build  # This runs TypeScript compiler

Git Workflow

This project follows GitHub Flow with feature branches:

  1. Create feature branch from main:

    git checkout main
    git pull origin main
    git checkout -b feat/your-feature-name
  2. Make changes and commit using Conventional Commits:

    git add .
    git commit -m "feat: add user authentication" \
               -m "- Added login endpoint" \
               -m "- Added JWT token generation"
  3. Push and merge:

    git push -u origin feat/your-feature-name
    git checkout main
    git merge --no-ff feat/your-feature-name
    git push origin main

πŸ“š For detailed contribution guidelines, see CONTRIBUTING.md

GitHub Branch Protection Rules

To maintain code quality and prevent accidental changes to the main branch, it's recommended to enable branch protection rules on GitHub.

⚠️ Note: Branch protection rules can only be configured through the GitHub web interface and require repository admin access.

Recommended Protection Rules for main Branch

  1. Navigate to Repository Settings:

    • Go to your repository on GitHub
    • Click Settings (requires admin access)
    • Click Branches in the left sidebar
    • Click Add branch protection rule
  2. Configure Branch Name Pattern:

    • Set Branch name pattern to: main
  3. Enable Required Status Checks:

    • βœ… Require status checks to pass before merging
    • βœ… Require branches to be up to date before merging
    • Select required checks:
      • Backend (Python) - Ruff
      • Frontend (TypeScript) - ESLint
      • Backend Tests (pytest) (optional but recommended)
      • Frontend TypeScript Check (optional but recommended)
  4. Enable Pull Request Requirements (Optional but Recommended):

    • βœ… Require a pull request before merging
    • βœ… Require approvals: Set to 1 or more reviewers
    • βœ… Dismiss stale pull request approvals when new commits are pushed
  5. Additional Recommended Settings:

    • βœ… Require conversation resolution before merging
    • βœ… Do not allow bypassing the above settings (keeps even admins accountable)
    • βœ… Restrict who can push to matching branches (optional for team environments)
  6. Click "Create" to save the protection rules

What This Protects Against

  • ❌ Direct pushes to main without review (if PR required)
  • ❌ Merging code that fails linting checks
  • ❌ Merging code that fails tests
  • ❌ Merging code with unresolved review comments
  • ❌ Accidentally force-pushing to main

For Solo Development

If you're working alone and find PR requirements too restrictive:

  • Enable only the required status checks (linting and tests)
  • Skip the "Require pull request" option
  • You can still push directly to main, but linting/tests must pass

Testing Branch Protection

After enabling, try to:

  1. Push directly to main - Should be blocked if PR required
  2. Create a PR with failing tests - Should show checks failing
  3. Fix the issues and push again - Checks should pass and allow merge

More Information


πŸ§ͺ Testing

Automated Tests

Backend Tests (54 passing, 64% coverage):

cd backend
source venv/bin/activate

# Run all tests (unit only, fast)
pytest

# Run with integration tests (mocked, no tokens used)
pytest --run-integration

# Run with coverage report
pytest --cov=. --cov-report=html

# Run specific test suites
pytest tests/test_main.py -v              # API + routing integration (37 tests)
pytest tests/test_supervisor.py -v        # Supervisor unit tests (15 tests)
pytest tests/test_technical_worker.py -v  # Worker unit tests (19 tests)
pytest tests/test_agent.py -v             # Phase 2 agent tests (10 tests)

# View coverage report
open htmlcov/index.html

Test Breakdown:

  • Unit Tests (44 tests): Fast, mocked, no API calls
    • 15 supervisor tests
    • 19 technical worker tests
    • 10 Phase 2 agent tests (reference)
  • Integration Tests (10 tests): Full endpoint routing tests (mocked supervisor)
    • Technical query routing
    • General query handling
    • Context maintenance across routing
    • Error handling scenarios

Frontend Linting & Type Checks:

cd frontend

# Run ESLint
pnpm lint

# TypeScript type checking
pnpm tsc --noEmit

Run All Tests (CI-style):

# From project root
./scripts/test-all.sh

# Or use Make commands
make test        # Run all tests
make lint        # Run all linters

Manual Testing Guide

Multi-Agent Routing Testing (Phase 3):

  1. Start the application:

    # Terminal 1: Backend
    cd backend && source venv/bin/activate && uvicorn main:app --reload
    
    # Terminal 2: Frontend
    cd frontend && pnpm dev
  2. Test technical query routing:

    • Open http://localhost:3000
    • Type: "Getting Error 500 when logging in"
    • Expected: Technical troubleshooting response
    • Check logs: Should see πŸ”€ ROUTING: Query routed to worker agent
  3. Test general query direct handling:

    • Type: "Hello! How are you?"
    • Expected: Friendly greeting response
    • Check logs: Should see βœ‹ DIRECT: Supervisor handled query directly
  4. Test conversation memory across routing:

    • Type: "I'm having an installation problem"
    • Type: "What did I just say?"
    • Expected: AI remembers the installation problem
    • Verify: Context maintained across routing
  5. Test session persistence:

    • Refresh the page (F5)
    • Type: "Do you remember my issue?"
    • Verify: AI still remembers (session persisted)
  6. Test clear conversation:

    • Click "Clear Conversation" button
    • Type: "What was my problem?"
    • Verify: AI doesn't remember (new session)

Test Routing with Script:

cd backend
chmod +x test_routing_logs.sh
./test_routing_logs.sh
# Watch logs for πŸ”€ ROUTING and βœ‹ DIRECT indicators

For comprehensive manual testing scenarios, see MANUAL_TESTING.md


πŸ› Troubleshooting

Common Issues

Backend: Module Not Found

# Make sure virtual environment is activated
source backend/venv/bin/activate
pip install -r backend/requirements.txt

Backend: OpenAI API Key Error

# Check your .env file has the key set
cat backend/.env | grep OPENAI_API_KEY

# Make sure it's not quoted and has no spaces
OPENAI_API_KEY=sk-...

Backend: Port 8000 Already in Use

# Kill process using port 8000
lsof -ti:8000 | xargs kill -9

# Or use a different port
uvicorn main:app --reload --port 8001

Frontend: Module Not Found

# Clear cache and reinstall
cd frontend
rm -rf .next node_modules
pnpm install

Frontend: Port 3000 Already in Use

# Use a different port
pnpm dev -- -p 3001

Python SSL Certificate Error (macOS)

# Install Python certificates
/Applications/Python\ 3.*/Install\ Certificates.command

Debug Mode

Backend:

# Set LOG_LEVEL=DEBUG in .env
LOG_LEVEL=DEBUG

# Or run with debug logging
uvicorn main:app --reload --log-level debug

Frontend:

# Next.js shows detailed errors in development mode by default
pnpm dev

Enable LangSmith Tracing (Recommended for Debugging Agents)

Add to backend/.env:

LANGSMITH_TRACING=true
LANGSMITH_API_KEY=your_langsmith_key
LANGSMITH_PROJECT=customer-service-ai

View execution traces at: https://smith.langchain.com/


πŸ“š Documentation

This project includes comprehensive documentation:

Document Description
README.md This file - Project overview, quick start, and Phase 2 features
MANUAL_TESTING.md NEW - Step-by-step manual testing guide with 10 test cases
backend/README.md UPDATED - Backend setup, /chat API docs, LangSmith tracing
frontend/README.md Frontend setup, component guide, and styling documentation
ARCHITECTURE.md Complete system architecture, design patterns, and technical decisions
FLOWCHARTS.md Visual process flows, sequence diagrams, and system interactions
PHASED_DEVELOPMENT_GUIDE.md Development roadmap with phases, milestones, and implementation details
CONTRIBUTING.md Contribution guidelines, Git workflow, and coding standards
DEVELOPMENT.md NEW - Developer setup guide and best practices
CI_VERIFICATION.md NEW - Local vs CI test command mapping
Makefile NEW - Convenient make commands for common tasks
agentic-customer-specs.md Original project specifications and requirements
tasks/ PRDs and task lists for feature development

🀝 Contributing

We follow a structured development process:

  1. PRDs (Product Requirements Documents): Define what we're building
  2. Task Lists: Break down PRDs into actionable tasks
  3. Feature Branches: One branch per sub-task
  4. Conventional Commits: Clear, semantic commit messages
  5. Testing: All features must include tests
  6. Documentation: Update relevant docs with changes

For complete contribution guidelines, see CONTRIBUTING.md


πŸŽ“ Project Context

This project is part of the ASU VibeCoding curriculum, demonstrating:

  • Modern full-stack development
  • AI/ML integration with LangChain v1.0+
  • Multi-agent system design
  • REST API development
  • TypeScript and type safety
  • Responsive web design
  • DevOps practices (Docker, CI/CD)

πŸ“„ License

This project is part of the ASU VibeCoding curriculum.


πŸ”— Quick Links


πŸ“ž Support

For questions or issues:

  1. Check this README and relevant documentation
  2. Review the specific component README (backend or frontend)
  3. Enable debug logging and LangSmith tracing
  4. Check GitHub issues for known problems
  5. Review test files for usage examples

πŸŽ‰ MVP Complete - All 6 Phases Finished!

What We Built:

Phase 1-4: Foundation βœ…

  • βœ… FastAPI backend + Next.js frontend infrastructure
  • βœ… Simple agent foundation with LangChain v1.0+
  • βœ… Multi-agent supervisor architecture
  • βœ… 4 specialized worker agents (Technical, Billing, Compliance, General)

Phase 5: RAG/CAG Integration βœ…

  • βœ… Pure RAG for Technical & General (ChromaDB vector retrieval)
  • βœ… Hybrid RAG/CAG for Billing (first query retrieves, then caches)
  • βœ… Pure CAG for Compliance (pre-loaded static documents)
  • βœ… 8 sample documents across 4 domains
  • βœ… Document indexing pipeline (index_documents.py)

Phase 6: Multi-Provider LLMs & Streaming βœ…

  • βœ… AWS Bedrock Nova Lite for supervisor routing ($0.06/1M tokens)
  • βœ… OpenAI GPT-4o-mini for worker generation ($0.15/1M tokens)
  • βœ… Real-time SSE streaming with token-by-token display
  • βœ… User toggle between streaming/standard modes
  • βœ… 11% cost savings vs single-provider strategy

Final System Features:

πŸ€– Multi-Provider LLM Strategy

  • AWS Nova Lite for routing decisions (60% cheaper)
  • OpenAI GPT-4o-mini for response generation
  • Automatic fallback mechanism

πŸ”„ Real-Time Streaming

  • Server-Sent Events (SSE) implementation
  • Token-by-token response display
  • User-controlled streaming toggle

πŸ“š Advanced Knowledge System

  • 3 RAG/CAG strategies optimized per domain
  • ChromaDB vector store with 8 documents
  • Session-based caching for billing queries

🎯 4 Specialized Agents

  • Technical Support (Pure RAG)
  • Billing Support (Hybrid RAG/CAG)
  • Compliance (Pure CAG)
  • General Information (Pure RAG)

πŸ§ͺ Production Quality

  • 145 automated tests (91% coverage)
  • Comprehensive error handling
  • Full TypeScript + Pydantic validation
  • LangSmith tracing support

Development Timeline:

  • βœ… Phase 1: Project Setup & Infrastructure
  • βœ… Phase 2: Simple Agent Foundation (20/20 tasks)
  • βœ… Phase 3: Multi-Agent Supervisor (13/13 tasks)
  • βœ… Phase 4: Additional Workers (11/11 tasks)
  • βœ… Phase 5: RAG/CAG Integration (10/10 tasks)
  • βœ… Phase 6: Multi-Provider LLMs & Streaming (3/3 tasks)

Ready for Submission:

  • βœ… GitHub repository with complete source code
  • βœ… Comprehensive README and setup instructions
  • πŸ“Ή Next: Record 5-10 minute YouTube demo video

System Architecture:

User β†’ Frontend (Streaming Toggle) β†’ Backend API (/chat or /chat/stream)
        ↓
    Supervisor (AWS Nova Lite + fallback)
        ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚Technicalβ”‚Billing β”‚Complianceβ”‚ General β”‚
    β”‚(Pure RAG)β”‚(Hybrid)β”‚(Pure CAG)β”‚(Pure RAG)β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
    ChromaDB / Cache / Pre-loaded Docs

Version: 1.0.0 (MVP Complete)
Last Updated: December 9, 2025
Status: Phase 6 Complete βœ… - PRODUCTION READY MVP
LangChain Version: 1.0+
All Requirements Met: Backend, Frontend, RAG/CAG, Multi-Provider LLMs, Streaming


Built with ❀️ using Vibe Coding Strategy
ASU VibeCoding Project - Advanced Customer Service AI

About

Intelligent agentic customer service system

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors