How jys0615/agent-khu works
Agent KHU is a personalized campus-information assistant. A student uses the React app to sign in and ask a question; the backend loads session context, routes simple questions through SLM/RAG or complex ones through Claude tool use, calls campus MCP services, then returns a response (including SSE streaming). The map includes the documented domain services and storage. Some MCP implementations and routing code were not excerpted, so their documented connections are cited to the README rather than inferred from names.
Main entry points: mcp_client.py MCP HTTP client · complex_handler.py Agent loop · App.tsx React app · auth.py Authentication routes
Components 27
Student application
- React app
frontend/src/App.tsx - Chat interface
frontend/src/components/ChatInterface.tsx - Chat API client
frontend/src/api/chat.ts - Auth API client
frontend/src/api/auth.ts
AI and API
- Chat stream route
backend/app/routers/chat_stream.py - Agent loop
backend/app/agent/complex_handler.py - Tool executor
backend/app/agent/tool_executor.py - Tool definitions
backend/app/agent/tools_definition.py - SLM classifier
backend/app/slm_agent.py - RAG search
backend/app/rag_agent.py - Response builder
backend/app/agent/result_builder.py - MCP HTTP client
backend/app/mcp_client.py - Authentication routes
backend/app/routers/auth.py
Persistence and memory
- Redis cache and sessions
backend/app/cache.py - PostgreSQL data
backend/app/database.py
Campus information services
- Classroom service
mcp-servers/classroom-mcp/server.py - Notice service
mcp-servers/notice-mcp/server.py - Meal service
mcp-servers/meal-mcp/server.py - Library service
mcp-servers/library-mcp/server.py - Course service
mcp-servers/course-mcp/server.py - Curriculum service
mcp-servers/curriculum-mcp/server.py - Shuttle service
mcp-servers/shuttle-mcp/server.py
Campus data sources
- Meal scraper
mcp-servers/meal-mcp/scraper.py - Library scraper
mcp-servers/library-mcp/scrapers/library_scraper.py - Notice crawler
mcp-servers/notice-mcp/crawler.py
Other components
- Student
- Campus websites
Connections 30
- Student → React app: uses
README.md - React app → Chat interface: renders
frontend/src/App.tsx - Chat interface → Chat API client: submits question
- Chat API client → Chat stream route: requests SSE
README.md - React app → Auth API client: authenticates
- Auth API client → Authentication routes: calls auth API
frontend/src/api/auth.ts - Chat stream route → Agent loop: routes question
README.md - Agent loop → SLM classifier: classifies
README.md - Agent loop → RAG search: searches simple query
README.md - Agent loop → Tool executor: dispatches tools
backend/app/agent/complex_handler.py - Agent loop → Tool definitions: selects tools
backend/app/agent/complex_handler.py - Tool executor → MCP HTTP client: calls tools
backend/app/agent/tool_executor.py - Agent loop → Response builder: builds response
backend/app/agent/complex_handler.py - Agent loop → Redis cache and sessions: loads and saves turns
README.md - Authentication routes → Redis cache and sessions: caches credentials
backend/app/routers/auth.py - Authentication routes → PostgreSQL data: reads and writes users
backend/app/routers/auth.py - MCP HTTP client → Classroom service: calls over HTTP
README.md - MCP HTTP client → Notice service: calls over HTTP
README.md - MCP HTTP client → Meal service: calls over HTTP
README.md - MCP HTTP client → Library service: calls over HTTP
README.md - MCP HTTP client → Course service: calls over HTTP
README.md - MCP HTTP client → Curriculum service: calls over HTTP
README.md - MCP HTTP client → Shuttle service: calls over HTTP
README.md - Classroom service → PostgreSQL data: queries
mcp-servers/classroom-mcp/server.py - Meal service → Meal scraper: uses
- Library service → Library scraper: uses
- Notice service → Notice crawler: uses
- Meal scraper → Campus websites: fetches menus
- Notice crawler → Campus websites: crawls notices
- Library scraper → Campus websites: fetches availability