Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI-Powered Customer Support System

A fullstack multi-agent customer support system with intelligent routing, specialized agents, and real-time streaming responses.

🎯 Features

βœ… Multi-Agent Architecture

  • Router Agent: Analyzes queries and routes to appropriate specialist
  • Support Agent: Handles FAQs, troubleshooting, general inquiries
  • Order Agent: Manages order status, tracking, delivery queries
  • Billing Agent: Handles invoices, refunds, payment issues

βœ… Advanced Capabilities

  • Real-time Streaming: AI responses stream character-by-character
  • Tool Integration: Agents query real database for order/invoice/refund data
  • Context Awareness: Maintains conversation history across messages
  • Smart Routing: Automatically selects the right agent based on query intent
  • Database Persistence: All conversations and messages saved

βœ… Tech Stack

  • Frontend: React 18 + TypeScript + Tailwind CSS
  • Backend: Hono.js + TypeScript
  • Database: PostgreSQL + Drizzle ORM
  • AI: OpenRouter (Claude 3.5 Sonnet)
  • Monorepo: Turborepo + pnpm

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL
  • pnpm
  • OpenRouter API key

Installation

  1. Clone the repository
git clone <your-repo-url>
cd customer-support-ai
  1. Install dependencies
pnpm install
  1. Setup PostgreSQL database
# Create database
psql -U postgres
CREATE DATABASE customer_support;
\q
  1. Configure environment variables
# Create .env in apps/api
cd apps/api

Create .env file:

DATABASE_URL="postgresql://postgres:YOUR_PASSWORD@localhost:5432/customer_support"
ANTHROPIC_API_KEY="your_openrouter_key"
PORT=3000
NODE_ENV=development
  1. Setup database schema
# From apps/api
pnpm db:push
pnpm seed
  1. Start backend
# From apps/api
pnpm dev
  1. Start frontend (new terminal)
# From apps/web
npm start
  1. Open browser
http://localhost:3001

πŸ“ Project Structure

customer-support-ai/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                    # Hono backend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/         # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/    # Request handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ services/       # Business logic & agents
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/     # Error handling, rate limiting
β”‚   β”‚   β”‚   β”œβ”€β”€ tools/          # Agent tools (DB queries)
β”‚   β”‚   β”‚   └── db/             # Database schema & seed
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── web/                    # React frontend
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ components/     # UI components
β”‚       β”‚   └── hooks/          # Custom React hooks
β”‚       └── package.json
β”‚
β”œβ”€β”€ package.json               # Root config
β”œβ”€β”€ turbo.json                 # Turborepo config
└── README.md

🎯 API Endpoints

Chat Endpoints

  • POST /api/chat/messages - Send message (streaming)
  • GET /api/chat/conversations/:id - Get conversation
  • GET /api/chat/conversations - List conversations
  • DELETE /api/chat/conversations/:id - Delete conversation

Agent Endpoints

  • GET /api/agents/agents - List all agents
  • GET /api/agents/agents/:type/capabilities - Get agent info

Health Check

  • GET /api/health - Server status

πŸ§ͺ Testing

Manual Testing Queries

Order Queries:

"What is the status of order ORD-001?"
"Track my order ORD-002"
"Where is order ORD-003?"

Billing Queries:

"Check invoice INV-001"
"What's the status of refund REF-001?"
"Show me my invoice INV-002"

Support Queries:

"How do I reset my password?"
"What are your shipping options?"
"I need help with my account"

Expected Behavior

  • βœ… Router selects correct agent (ORDER/BILLING/SUPPORT)
  • βœ… Agent uses appropriate tools to fetch data
  • βœ… Responses stream in real-time
  • βœ… Reasoning steps displayed
  • βœ… Conversations persist in database

πŸ’Ύ Database Schema

Tables:

  • conversations - User conversation sessions
  • messages - Individual chat messages
  • orders - Sample order data
  • invoices - Sample invoice data
  • refunds - Sample refund data

Sample Data:

  • 3 orders (ORD-001, ORD-002, ORD-003)
  • 3 invoices (INV-001, INV-002, INV-003)
  • 2 refunds (REF-001, REF-002)

πŸ€– Agent System

Router Agent

  • Analyzes query intent using Claude
  • Classifies as SUPPORT/ORDER/BILLING
  • Delegates to appropriate specialist

Support Agent

  • Handles general inquiries
  • Provides troubleshooting help
  • Answers FAQs

Order Agent

Tools:

  • get_order_details - Fetches order info from DB
  • check_delivery_status - Gets tracking details

Billing Agent

Tools:

  • get_invoice_details - Retrieves invoice data
  • check_refund_status - Checks refund progress

✨ Key Features Implemented

Required Features βœ…

  • βœ… Multi-agent architecture with router
  • βœ… 3 specialized sub-agents
  • βœ… Tool calling with database queries
  • βœ… Conversation context persistence
  • βœ… Streaming AI responses
  • βœ… RESTful API design
  • βœ… Error handling middleware
  • βœ… Rate limiting
  • βœ… PostgreSQL + Drizzle ORM

Bonus Features βœ…

  • βœ… Monorepo with Turborepo (+30 points)
  • βœ… Real-time typing indicators
  • βœ… Agent reasoning display
  • βœ… Character-by-character streaming
  • βœ… Database seeding
  • βœ… Comprehensive logging

🎬 Demo Video

[Link to Loom video walkthrough]


πŸ“ Assignment Requirements Met

  • βœ… Controller-Service pattern
  • βœ… Clean separation of concerns
  • βœ… Proper error handling
  • βœ… Multi-agent system with router
  • βœ… 3 specialized agents (Support, Order, Billing)
  • βœ… Agent tools querying database
  • βœ… Conversation context maintained
  • βœ… RESTful API endpoints
  • βœ… Streaming responses
  • βœ… Real-time typing indicator
  • βœ… React frontend
  • βœ… Hono backend
  • βœ… PostgreSQL database
  • βœ… Turborepo monorepo (+30 bonus)

πŸš€ Deployment

Backend (Railway/Render)

cd apps/api
pnpm build
# Deploy dist/ folder

Frontend (Vercel/Netlify)

cd apps/web
npm run build
# Deploy build/ folder

πŸ‘¨β€πŸ’» Developer

Created by [Your Name]

πŸ“„ License

MIT


---

## Step 15: Create .gitignore

Create `customer-support-ai/.gitignore`:

Dependencies

node_modules/ .pnp .pnp.js

Testing

coverage/

Production

dist/ build/ .next/

Environment

.env .env.local .env.development.local .env.test.local .env.production.local

Logs

npm-debug.log* yarn-debug.log* pnpm-debug.log*

Editor

.vscode/ .idea/ *.swp *.swo

OS

.DS_Store Thumbs.db

Database

drizzle/

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages