Understand Chat UI architectural components
mainChat UI is built with SvelteKit, Tailwind, and MongoDB. Its architecture is centered around several key modules:
routes: Contains the majority of backend and frontend logic. Routes are rendered with SSR via SvelteKit. Shared modules are located inlib(client) andlib/server(server).textGeneration: The standard interface for chat features. It handles model output, tool calls, and streaming, emittingMessageUpdates for status updates like new tokens or tool results.endpoints: Provides the streaming interface for OpenAI-compatible endpoints. It fetches and caches models from${OPENAI_BASE_URL}/models.mcp: Implements the Model Context Protocol (MCP) client functionality for tool discovery and execution.llmRouter: Contains routing logic to select models based on request heuristics (e.g., routing to a multimodal model if image input is present, or an agentic route if MCP tools are active).migrations: Manages MongoDB migrations to ensure backwards compatibility during schema changes.