HiMarket Documentation

repository·main·Indexed 22 days ago

https://github.com/higress-group/himarket

An enterprise-grade AI open platform providing a centralized marketplace for managing and distributing AI resources such as LLMs, Agents, and MCP Servers. The platform consists of an infrastructure layer using Higress and Nacos, an AI Open Platform Admin for resource management and policy setting, and an AI Open Platform Portal (AI Hub) for developer registration, product subscription, and debugging via HiChat and HiCoding.

Tokens
48.1K
Snippets
90
Records
199
Agent score
78%

What's inside HiMarket

  1. What is HiMarket?

    main

    HiMarket is an enterprise-grade AI Open Platform built on the Higress AI Gateway. It enables enterprises to build private AI capability markets by unifying the management and distribution of LLMs, MCP Servers, Agents, and Agent Skills.

    Key capabilities include:

    • AI Capability Markets: Model market (with safety and rate limiting), MCP market (converting external APIs to standard MCP), Agent market, Skills market, and Worker market.
    • AI Experience Center: HiChat for model dialogue/testing and HiCoding for secure sandbox-based online programming.
    • Enterprise Management: Product management (auth, traffic control, quotas), observability (tracing, monitoring), metering/billing (token-based), and version management (canary releases, rollbacks).
    • Customization: Portal branding, OIDC identity authentication, and configurable approval workflows.
  2. Navigate HiMarket coding standards

    main

    HiMarket maintains a centralized set of coding standards located in docs/standards/. These standards serve as the source of truth for all new code and active modifications. The standards are organized into Backend and Frontend categories to ensure consistency across the ecosystem.

    Backend Standards

    • Overview: General backend principles (backend/README.md).
    • Structure & Style: Project organization and coding style (backend/project-structure.md).
    • API & REST: Guidelines for Controllers, OpenAPI, and RESTful design (backend/api-controller.md).
    • Logic & Flow: Handling Services, errors, transactions, and events (backend/service-transaction.md).
    • Data Management: Database interactions and Flyway migrations (backend/data-flyway.md).
    • Data Transfer: DTO (Data Transfer Object) and JSON patterns (backend/dto-json.md).
    • Dependencies: Management of backend libraries and modules (backend/dependency-management.md).
    • Security & Observability: Security practices and logging standards (backend/security-logging.md).
    • Testing: Backend testing requirements and patterns (backend/testing.md).

    Frontend Standards

    • Overview: General frontend principles (frontend/README.md).
    • Shared Rules: Rules applicable to all frontend applications (frontend/shared.md).
    • Admin Portal: Specific rules for the Admin frontend (frontend/admin.md).
    • Developer Portal: Specific rules for the Developer portal frontend (frontend/portal.md).
  3. HiMarket Frontend Coding Standards Overview

    main

    HiMarket maintains a tiered frontend standard system. Shared frontend rules are separated from application-specific rules to allow the admin console and developer portal to evolve independently while maintaining a consistent baseline.

    These standards apply to new frontend code and code being actively modified. Existing non-compliant code is considered technical debt and should not be used as a pattern for new development.

    Standard Documentation Areas

    • Shared frontend rules: Common rules across all HiMarket frontend projects.
    • Admin console frontend: Rules specific to the admin console application.
    • Developer portal frontend: Rules specific to the developer portal application.
  4. Understand the HiMarket Backend Architecture

    main

    The HiMarket backend uses a layered Spring Boot architecture with strict unidirectional dependencies. The flow of data and dependencies is as follows:

    Controller $\rightarrow$ Service (Interface + Impl) $\rightarrow$ Repository $\rightarrow$ Entity.

    Data conversion happens alongside this flow:

    • Input: Param (Input DTO) $\rightarrow$ InputConverter $\rightarrow$ Controller
    • Output: Entity $\rightarrow$ OutputConverter $\rightarrow$ Result (Output DTO)

    Module Structure:

    • himarket-dal: Data layer containing Entities, Repositories, AttributeConverters, and enums.
    • himarket-server: Business layer containing Controllers, Services, DTOs (Param/Result), and core framework.
    • himarket-bootstrap: Application entry point and Flyway migrations.

    Base package: com.alibaba.himarket.

  5. Use the API Namespace Pattern

    main

    To maintain clean and discoverable API calls, group related endpoints into namespace objects within lib/api.ts. This allows for structured calling via the namespace rather than importing individual functions.

    Example Namespace Definition:

    export const apiProductApi = {
      createApiProduct: (data: CreateApiProductRequest) => api.post('/products', data),
      getApiProducts: (params: GetApiProductsParams) => api.get('/products', { params }),
      getApiProductDetail: (id: string) => api.get(`/products/${id}`),
      updateApiProduct: (id: string, data: UpdateApiProductRequest) => api.put(`/products/${id}`, data),
      deleteApiProduct: (id: string) => api.delete(`/products/${id}`),
    };

    Example Usage:

    import { apiProductApi } from '@/lib/api';
    
    const res = await apiProductApi.getApiProductDetail(productId);
    import { apiProductApi, gatewayApi } from '@/lib/api';
    
    const res = await apiProductApi.getApiProductDetail(productId);
    const servers = await gatewayApi.getGatewayMcpServers(gatewayId, { page: 1, size: 500 });
  6. Understand the HiMarket Frontend API Layer Structure

    main

    The frontend API layer is organized into a dedicated lib/ directory to separate request logic from UI components.

    • lib/request.ts: Contains the Axios instance and interceptors.
    • lib/api.ts: A unified entry point that re-exports the request instance.
    • lib/sse.ts: A wrapper for SSE (Server-Sent Events) streaming requests.
    • lib/apis/: A directory containing domain-specific API modules (e.g., product.ts, consumer.ts, chat.ts) and a barrel export index.ts to aggregate them.
  7. Follow RESTful API Conventions

    main

    HiMarket follows standard RESTful principles for resource naming and HTTP methods.

    Resource Naming:

    • Use plural nouns for collections: /products.
    • Use kebab-case for multi-word resources: /sandbox-deployments.
    • Use nested resources to express ownership: /api-definitions/{id}/deployments.

    HTTP Methods:

    • GET: Read/query (no state change).
    • POST: Create a resource or trigger an action.
    • PUT: Full update of a resource.
    • PATCH: Partial update of a resource.
    • DELETE: Remove a resource.

    URL Design:

    • Avoid verbs in URLs. Instead of POST /{id}/deploy, use POST /{id}/deployments (treating the deployment as a new resource).
    • Action Endpoints: If an operation doesn't map to CRUD, use a clear resource-oriented path (e.g., POST /{id}/configurations/reload). Use /actions/... only as a last resort when no clear domain sub-resource exists.
  8. Understand the difference between HiChat and HiWork

    main

    HiMarket provides two distinct entry points for AI interaction based on the user's goal:

    HiChat: Intelligent Call Entry

    Purpose: Quick verification and lightweight interaction. Mental Model: "I want to quickly call a model or Agent API to verify its effect." Capabilities:

    • Calling Model and Agent APIs.
    • Multi-model comparison.
    • Multimodal Q&A (images, files).
    • Web search and basic tool call visualization.
    • Conversation history saving/restoration.

    HiWork: Agent Workspace

    Purpose: Complex task execution and delivery (similar to Codex). Mental Model: "I give an Agent a goal, and it plans, executes, and delivers results." Capabilities:

    • Creating work threads and describing task goals.
    • Selecting/switching execution models and Agent Skills.
    • Binding MCP tools and selecting target products/projects.
    • Visualizing execution plans, tool calls, and processes.
    • Confirming or rejecting critical actions.
    • Generating and managing artifacts.
    • Managing task-related memory and continuing via follow-up questions.
  9. How HiMarket system architecture works

    main

    HiMarket is organized into three layers:

    1. Infrastructure: Composed of the AI Gateway, API Gateway, Higress, and Nacos. This layer abstracts underlying AI resources into standardized API products.
    2. AI Open Platform Backend: An administration platform for managers to create portals and manage resources (MCP Servers, Models, Agents, Skills), set authentication policies, and monitor system health via observability dashboards.
    3. AI Open Platform Frontend: A developer portal (AI Market) providing self-service capabilities such as identity registration, credential application, product subscription, and interactive tools like HiChat and HiCoding.
  10. HiMarket Backend Architecture and Layering

    main

    The HiMarket backend follows a strict layered architecture to maintain separation of concerns. You must adhere to the following dependency direction:

    himarket-dal (data layer) $\leftarrow$ himarket-server (business layer) $\leftarrow$ himarket-bootstrap (bootstrap)

    Key Architectural Rules:

    • Controllers: Keep methods thin. They should only handle request validation and delegation. Do not start transactions in the Controller.
    • Service Layer: This is where business logic and transaction boundaries reside. Use Spring's @Transactional here.
    • Entities: Act as persistence data containers only. Do not put business logic inside Entity classes.
    • Cross-Domain Logic: Use Spring Events for side effects or cleanups that involve other modules to avoid tight coupling.
  11. Understand the HiMarket Monorepo Structure

    main

    HiMarket is an AI open platform providing API product management, developer portals, AI chat, Cloud IDE (HiCoding), and MCP Server hosting. The project is organized as a monorepo with the following module structure:

    ModulePathResponsibility
    Backend Data Layerhimarket-dal/Entities, Repositories, field converters, enums, and data layer support
    Backend Business Layerhimarket-server/Controllers, Services, DTOs, permissions, product imports, gateways, Nacos, and MCP
    Backend Bootstrap Layerhimarket-bootstrap/Spring Boot entry points, runtime configurations, packaging, and Flyway migrations
    Admin Portalhimarket-web/himarket-admin/Frontend for administrators (product management, gateway config, user/portal management)
    Developer Portalhimarket-web/himarket-frontend/Frontend for developers (product browsing, subscriptions, AI chat, HiCoding)
    Project Documentationdocs/Architecture design, specialized designs, code standards, and external source indexes
    Auxiliary Scriptsscripts/Automation scripts for local startup, quality checks, and external repository initialization
  12. Understand the HiMarket System Architecture

    main

    HiMarket is an AI open platform built with Java 17 and Spring Boot 3.2.11. It uses a Maven multi-module layered architecture with strict unidirectional dependencies:

    1. himarket-bootstrap (Top Layer): Handles startup configuration, security, WebSocket, database migrations (Flyway), Swagger, and portal resolving.
    2. himarket-server (Middle Layer): Contains the core business logic, including 22 REST Controllers, 22 Service interfaces/implementations, and specialized modules like hichat (AI Chat) and hicoding (Cloud IDE).
    3. himarket-dal (Bottom Layer): The Data Access Layer containing entities, repositories, converters, and support enums. It has no internal dependencies.

    Dependency Flow: himarket-bootstrap $\rightarrow$ himarket-server $\rightarrow$ himarket-dal.