This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
HiMarket API Portal Frontend - A React-based developer portal for managing API products, MCP servers, AI agents, and AI models. The portal allows developers to browse, subscribe to, and manage various API products with OAuth/OIDC authentication.
- Framework: React 18 + TypeScript
- Build Tool: Vite 4.5
- UI Library: Ant Design 5.15
- Routing: React Router DOM v6
- HTTP Client: Axios
- Styling: TailwindCSS + PostCSS
- Code Editor: Monaco Editor (for viewing/editing specs)
- Markdown: react-markdown with GFM support
- API Documentation: Swagger UI React
# Install dependencies
npm install
# Start development server (runs on http://0.0.0.0:5173)
npm run dev
# Type checking without building
npm run type-check
# Build for production
npm run build
# Lint code
npm run lint
# Preview production build
npm run preview
# Build and serve
npm run servesrc/router.tsx: Centralized route definitions using React Router v6src/lib/api.ts: Axios instance with request/response interceptors, all API endpointssrc/types/index.ts: Shared TypeScript types for products (REST_API, MCP_SERVER, AGENT_API, MODEL_API)src/types/consumer.ts: Consumer and subscription-related typessrc/App.tsx: Root component with Ant Design ConfigProvider (Chinese locale + Aliyun theme)
- OIDC Providers: Backend provides list of OAuth/OIDC providers (Aliyun, Google, GitHub, etc.)
- Token Storage: Access tokens stored in
localStoragewith keyaccess_token - Request Interceptor: Automatically adds
Authorization: Bearer <token>header to all API requests - Auth Endpoints:
GET /developers/oidc/providers- Get available OIDC providersGET /developers/oidc/callback- Handle OAuth callbackPOST /developers/logout- Logout
The portal manages 4 product types (defined in src/types/index.ts):
-
REST_API: Traditional REST APIs with OpenAPI specs
- Config:
apiConfig.spec(OpenAPI/Swagger spec)
- Config:
-
MCP_SERVER: Model Context Protocol servers
- Config:
mcpConfigwith server name, domains, tools (YAML format) - Two config formats supported: legacy and new nacos format
- Config:
-
AGENT_API: AI agent APIs
- Config:
agentConfig.agentAPIConfigwith routes and protocols
- Config:
-
MODEL_API: AI model APIs
- Config:
modelConfig.modelAPIConfigwith model category and routes
- Config:
Layout Components:
src/components/Layout.tsx: Main layout wrapper with loading skeletonsrc/components/Navigation.tsx: Top navigation bar with user infosrc/components/ProductHeader.tsx: Product detail page header
Consumer Components (in src/components/consumer/):
ConsumerBasicInfo.tsx: Display consumer detailsCredentialManager.tsx: Manage API credentialsSubscriptionManager.tsx: Subscribe/unsubscribe from products with advanced searchAuthConfig.tsx: Authentication configuration
Common Components:
src/components/common/AdvancedSearch.tsx: Reusable search component with filters
- Home: Landing page showcasing all product types
- APIs: Browse REST API products
- MCP: Browse MCP server products
- Agents: Browse AI agent products
- Models: Browse AI model products
- Consumers: Manage consumers (applications)
- Profile: User profile and settings
- Detail Pages: Product-specific views with subscription management
Development proxy configured in vite.config.ts:
- Frontend:
http://0.0.0.0:5173 - Backend:
http://localhost:8080 - API prefix:
/api/v1(from.env) - Proxy rewrites
/api/v1/*to backend root
- Check Status:
getProductSubscriptionStatus(productId)checks if current developer has subscribed - Subscribe:
subscribeProduct(consumerId, productId)creates subscription request - Approval: Backend may auto-approve based on product settings (
autoApproveflag) - Status Management: Subscriptions can be PENDING, APPROVED, or REJECTED
- Unsubscribe:
unsubscribeProduct(consumerId, productId)removes subscription
src/lib/statusUtils.ts: Status badge colors and text mapping for subscriptionssrc/lib/utils.ts: Date formatting and other utilities
Product icons support two types (defined in ProductIcon interface):
URL: Direct image URLBASE64: Base64-encoded image data
The codebase uses discriminated unions for product types. When working with products, check the type field to access type-specific configs:
if (product.type === 'REST_API') {
// Access product.apiConfig
} else if (product.type === 'MCP_SERVER') {
// Access product.mcpConfig
}All API responses follow this pattern:
{
code: string;
message: string | null;
data: T;
}Paginated responses include: content[], totalElements, totalPages, size, number, first, last
The response interceptor in src/lib/api.ts has commented-out error handling for 401/403/404/500. Currently errors are passed through for component-level handling.
Build platform-specific image:
docker buildx build --platform linux/amd64 -t api-portal-frontend:latest .The application uses nginx for serving (see nginx.conf and Dockerfile).
- Uses ESLint with React hooks and React refresh plugins
- TypeScript strict mode enabled
- Tailwind utility classes for styling
- Ant Design components with custom Aliyun theme token
- Chinese locale for Ant Design (zhCN)