A fullstack multi-agent customer support system with intelligent routing, specialized agents, and real-time streaming responses.
- 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
- 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
- Frontend: React 18 + TypeScript + Tailwind CSS
- Backend: Hono.js + TypeScript
- Database: PostgreSQL + Drizzle ORM
- AI: OpenRouter (Claude 3.5 Sonnet)
- Monorepo: Turborepo + pnpm
- Node.js 18+
- PostgreSQL
- pnpm
- OpenRouter API key
- Clone the repository
git clone <your-repo-url>
cd customer-support-ai- Install dependencies
pnpm install- Setup PostgreSQL database
# Create database
psql -U postgres
CREATE DATABASE customer_support;
\q- Configure environment variables
# Create .env in apps/api
cd apps/apiCreate .env file:
DATABASE_URL="postgresql://postgres:YOUR_PASSWORD@localhost:5432/customer_support"
ANTHROPIC_API_KEY="your_openrouter_key"
PORT=3000
NODE_ENV=development- Setup database schema
# From apps/api
pnpm db:push
pnpm seed- Start backend
# From apps/api
pnpm dev- Start frontend (new terminal)
# From apps/web
npm start- Open browser
http://localhost:3001
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
POST /api/chat/messages- Send message (streaming)GET /api/chat/conversations/:id- Get conversationGET /api/chat/conversations- List conversationsDELETE /api/chat/conversations/:id- Delete conversation
GET /api/agents/agents- List all agentsGET /api/agents/agents/:type/capabilities- Get agent info
GET /api/health- Server status
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"
- β 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
Tables:
conversations- User conversation sessionsmessages- Individual chat messagesorders- Sample order datainvoices- Sample invoice datarefunds- 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)
- Analyzes query intent using Claude
- Classifies as SUPPORT/ORDER/BILLING
- Delegates to appropriate specialist
- Handles general inquiries
- Provides troubleshooting help
- Answers FAQs
Tools:
get_order_details- Fetches order info from DBcheck_delivery_status- Gets tracking details
Tools:
get_invoice_details- Retrieves invoice datacheck_refund_status- Checks refund progress
- β 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
- β Monorepo with Turborepo (+30 points)
- β Real-time typing indicators
- β Agent reasoning display
- β Character-by-character streaming
- β Database seeding
- β Comprehensive logging
[Link to Loom video walkthrough]
- β 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)
cd apps/api
pnpm build
# Deploy dist/ foldercd apps/web
npm run build
# Deploy build/ folderCreated by [Your Name]
MIT
---
## Step 15: Create .gitignore
Create `customer-support-ai/.gitignore`:
node_modules/ .pnp .pnp.js
coverage/
dist/ build/ .next/
.env .env.local .env.development.local .env.test.local .env.production.local
npm-debug.log* yarn-debug.log* pnpm-debug.log*
.vscode/ .idea/ *.swp *.swo
.DS_Store Thumbs.db
drizzle/