How li2589920489/ai-cs-agent works
This is an ecommerce customer-support application with a Next.js buyer/agent workspace and a FastAPI backend. The main workflow is message intake, Triage handoff to a business agent, tool-backed order/product/policy work, and a streamed reply or human escalation. Separate branches cover knowledge administration and retrieval, tenant authentication, MCP exposure, and Taobao/Douyin integrations. Edges reflect README statements or the supplied source index and excerpts; unsampled routes and integrations are represented only where documented.
Main entry points: chat_service.py Chat orchestration · main.py FastAPI routes · tools.py Business tools · pipeline.py RAG retrieval
Components 23
Customer experience
- Support workspace
ui/app/page.tsx - Chat interface
ui/components/chat-panel.tsx - Stream decoder
ui/lib/chat-stream.ts
Conversation and agents
- FastAPI routes
python-backend/main.py - Chat orchestration
python-backend/chat_service.py - Ecommerce agents
python-backend/ecommerce/agents.py - Airline agents
python-backend/airline/agents.py - Conversation context
python-backend/ecommerce/context.py
Business capabilities
- Business tools
python-backend/ecommerce/tools.py - Order and returns
python-backend/order_store.py - Human escalation
python-backend/main.py
Knowledge and retrieval
- Knowledge management
python-backend/knowledge_store.py - Document import
python-backend/doc_importer.py - RAG retrieval
python-backend/rag/pipeline.py - Text embeddings
python-backend/rag/embedding.py - BM25 retrieval
python-backend/rag/bm25.py - Result reranking
python-backend/rag/reranker.py
Persistence and integrations
- Tenant authentication
python-backend/auth.py - Session memory
python-backend/memory_store.py - MCP tools
python-backend/mcp_server.py - Taobao adapter
python-backend/taobao_adapter.py - Douyin adapter
python-backend/douyin_adapter.py
Other components
- Buyer / agent
Connections 24
- Buyer / agent → Support workspace: uses
- Support workspace → Chat interface: renders
ui/app/page.tsx - Chat interface → Stream decoder: streams through
ui/lib/chat-stream.ts - Stream decoder → FastAPI routes: posts messages
- FastAPI routes → Chat orchestration: invokes
python-backend/main.py - Chat orchestration → Ecommerce agents: runs triage
python-backend/chat_service.py - Chat orchestration → Conversation context: builds context
python-backend/chat_service.py - Chat orchestration → Session memory: uses sessions
python-backend/chat_service.py - Ecommerce agents → Business tools: dispatches tools
python-backend/ecommerce/agents.py - Business tools → Order and returns: reads and updates
python-backend/ecommerce/tools.py - Business tools → Knowledge management: queries knowledge
python-backend/ecommerce/tools.py - Business tools → RAG retrieval: searches
python-backend/ecommerce/tools.py - RAG retrieval → Text embeddings: embeds queries
python-backend/rag/pipeline.py - RAG retrieval → BM25 retrieval: retrieves terms
python-backend/rag/pipeline.py - RAG retrieval → Result reranking: reranks results
python-backend/rag/pipeline.py - FastAPI routes → Tenant authentication: protects routes
python-backend/main.py - FastAPI routes → Knowledge management: serves management
python-backend/main.py - FastAPI routes → Document import: imports documents
python-backend/main.py - FastAPI routes → Human escalation: manages tickets
python-backend/main.py - Chat orchestration → Airline agents: supports legacy flow
python-backend/chat_service.py - MCP tools → Knowledge management: exposes tools
- MCP tools → Order and returns: exposes tools
- Taobao adapter → Chat orchestration: shares chat logic
python-backend/taobao_adapter.py - Douyin adapter → Chat orchestration: shares chat logic