How ant-design/x works
Main Components
• UI Component Library – At the core are the atomic components (found under directories like components/bubble, components/sender, components/prompts, etc.). These components encapsulate the view layer for various AI chat scenarios.
• Runtime Integration Modules – Modules such as useXAgent, useXChat, XRequest, and XStream provide logic to integrate with external model inference services. They are responsible for handling API requests, streaming responses, and managing conversation data flows.
• Theme and Configuration – There is a dedicated theme layer (in directories like .dumi/theme and components/theme) that manages styling, theming, and customization.
• Documentation & Demo Infrastructure – The .dumi directory and docs folder constitute the documentation site. They show demos, interactive examples, and provide component documentation.
• Testing & Build Infrastructure – Includes directories for tests, scripts, and configuration files (e.g., webpack.config.js, tsconfig.json). These support automated testing and build processes.
• External Integration / API Layer – This layer isn’t a separate service but is integrated via the runtime tools (e.g., XRequest) that connect to external inference services.
Architectural Patterns & Technical Stack
• Use of the Atomic Design paradigm for building UI components.
• Separation of concerns: presentation (UI components and theme), business logic (runtime hooks for data flow and API calls), and infrastructure (documentation, testing, and build configurations).
• Clearly label major modules with their technology – for example, “React Components (TypeScript)” for the UI, “API Integration via XRequest (REST/Streaming)” for the runtime layer, etc.