# higress-group/himarket architecture

> Architecture diagram of the GitHub repository higress-group/himarket, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/higress-group/himarket
- Repository: https://github.com/higress-group/himarket

## Overview

1. **Repository shape**
   - This is a monorepo with a Java backend and two React/TypeScript frontends, plus a separate sandbox runtime and deployment automation.
   - The backend is split into `himarket-bootstrap` (application entrypoint), `himarket-server` (HTTP/API and business logic), and `himarket-dal` (entities, repositories, converters, domain support types).

2. **Primary runtime architecture**
   - `himarket-bootstrap` is the Spring Boot executable. It wires security, MVC, WebSocket, Swagger, async execution, Flyway migration, and request filtering.
   - `himarket-server` contains the core service layer and controllers. `himarket-dal` owns persistence models and JPA repositories. This gives a clean boundary between transport/business logic and database access.

3. **Backend domain boundary**
   - The backend is organized around productized AI capabilities: **models**, **MCP servers**, **agents/skills**, **portals**, **consumers**, **developers**, **gateways**, **Nacos instances**, **sandbox instances**, and **chat/coding sessions**.
   - DTOs are separated from entities, and many configuration objects are stored as typed JSON/value objects with converters in `himarket-dal`.

4. **API and request flow**
   - Both frontends call the backend over REST.
   - The developer portal also uses WebSocket and SSE-style flows for chat/coding experiences, especially in HiCoding and live session screens.
   - Response wrapping, exception handling, and auth are centralized in backend `core/advice`, `core/security`, and custom annotations like admin/developer/public access markers.

5. **Admin portal**
   - `himarket-web/himarket-admin` is the operator-facing console.
   - It manages products, categories, gateways, portals, MCP creation, sandbox deployment, observability, and platform settings.
   - It is a Vite-built React app with typed API clients and UI components tailored to platform administration.

6. **Developer portal**
   - `himarket-web/himarket-frontend` is the user-facing AI marketplace and experience center.
   - It supports login/registration, browsing APIs/models/MCPs/skills, subscriptions, profile management, HiChat, and HiCoding.
   - This frontend is multilingual and heavily stateful, with hooks/context for auth, coding sessions, portal config, WebSocket sessions, and UI state.

7. **HiChat subsystem**
   - The backend `service/hichat` area manages model selection, tool invocation, chat formatting, and LLM adapters.
   - It includes model-specific services for OpenAI and DashScope, plus tool and chatbot managers.
   - The frontend chat UI consumes this to present conversation history, attachments, MCP tool calls, and multi-model comparison.

8. **HiCoding and sandbox subsystem**
   - HiCoding is a distinct subsystem spanning backend services, WebSocket handlers, runtime/session orchestration, and a separate sandbox process.
   - The backend coordinates sandbox acquisition, initialization, skill download, filesystem readiness, terminal access, and remote runtime adapters.
   - The `sandbox/sidecar-server` is a Node.js service exposing exec, file, session, and terminal WebSocket endpoints; it is the isolated execution boundary for code editing and command execution.

9. **Gateway / MCP / product orchestration**
   - The backend contains dedicated operators and clients for different gateway types: Higress, APIG, Apsara, and related AI gateway variants.
   - MCP support is first-class: server metadata, endpoints, tool config parsing, transport resolution, sandbox deploy/undeploy orchestration, and config sync helpers are all explicit backend services.
   - Products are the abstraction layer that packages these capabilities for publication, subscription, and versioned release.

10. **Infrastructure integration**
    - **MySQL** is the main persistent store, with Flyway migrations defining schema evolution.
    - **Nacos** is used for configuration/distribution and appears in both deployment scripts and backend services.
    - **Higress / AI Gateway** is a foundational external dependency for exposing AI resources.
    - The platform also integrates with observability and log services, including SLS-related controllers/services.
    - External LLM providers such as OpenAI and DashScope are accessed through backend adapters rather than directly from the UI.

11. **Deployment model**
    - The repo supports local execution, Docker Compose, Helm/Kubernetes, Podman, and Alibaba Cloud ComputeNest packaging.
    - Deployment templates include the backend, both frontends, MySQL, sandbox components, and support services.
    - Post-start hooks initialize admin accounts, AI model settings, portal developer accounts, and Nacos synchronization, which suggests the platform expects bootstrapping after infrastructure comes up.

12. **How to draw the architecture**
    - Put the **backend service** in the center, with arrows to **MySQL**, **Nacos**, **Higress/AI Gateway**, **SLS/observability**, **LLM providers**, and the **sandbox runtime**.
    - Put the **admin portal** and **developer portal** as separate clients hitting the backend.
    - Show the **sandbox** as an isolated execution environment connected back to the backend through HTTP/WebSocket and session orchestration.
    - Model **products** as the packaging layer that sits above models, MCP servers, skills, and agents, because that is the core business abstraction of the platform.

Main entry points: [`himarket-server/src/main/java/com/alibaba/himarket`](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket) (Server), [`himarket-server/src/main/java/com/alibaba/himarket/service/ProductService.java`](https://github.com/higress-group/himarket/blob/main/himarket-server/src/main/java/com/alibaba/himarket/service/ProductService.java) (Products), [`himarket-dal/src/main/java/com/alibaba/himarket`](https://github.com/higress-group/himarket/tree/main/himarket-dal/src/main/java/com/alibaba/himarket) (DAL), [`sandbox/sidecar-server/server.js`](https://github.com/higress-group/himarket/blob/main/sandbox/sidecar-server/server.js) (Sandbox Sidecar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_bootstrap["Bootstrap<br/>Spring Boot entrypoint"]
  node_server["Server<br/>API and services"]
  node_dal[("DAL<br/>Persistence model")]
  node_product["Products<br/>Packaging layer"]
  node_mcp["MCP Orchestration<br/>MCP lifecycle"]
  node_gateway["Gateway Ops<br/>Gateway integration"]
  node_hichat["HiChat<br/>Chat runtime"]
  node_hicoding["HiCoding<br/>Coding workspace"]
  node_portalid["Portal Identity<br/>Auth and portal config<br/>[PortalService.java]"]
end

subgraph group_web["Web Frontends"]
  node_admin["Admin Portal<br/>React admin console<br/>[App.tsx]"]
  node_developer["Developer Portal<br/>React experience app<br/>[App.tsx]"]
end

subgraph group_runtime["Execution Runtime"]
  node_sandbox["Sandbox Sidecar<br/>Node runtime<br/>[server.js]"]
end

subgraph group_infra["Infrastructure"]
  node_mysql[("MySQL<br/>Primary database")]
  node_nacos[("Nacos<br/>Config distribution")]
  node_gatewayinfra["Higress / AI Gateway<br/>External gateway"]
  node_sls["Observability<br/>SLS and logging"]
  node_llm(("LLM Providers<br/>OpenAI and DashScope"))
end

node_admin -->|"REST"| node_server
node_developer -->|"REST"| node_server
node_developer -.->|"WebSocket/SSE"| node_server
node_bootstrap -->|"wires"| node_server
node_bootstrap -->|"starts with"| node_dal
node_server -->|"reads/writes"| node_dal
node_dal -->|"JPA"| node_mysql
node_server -->|"syncs"| node_nacos
node_server -->|"exposes"| node_gatewayinfra
node_server -->|"observes"| node_sls
node_server -->|"adapts"| node_llm
node_server -->|"orchestrates"| node_sandbox
node_server -->|"packages"| node_product
node_product -->|"includes"| node_mcp
node_product -->|"includes"| node_gateway
node_product -->|"targets"| node_portalid
node_mcp -->|"deploys to"| node_sandbox
node_gateway -->|"drives"| node_gatewayinfra
node_hichat -->|"invokes"| node_llm
node_hicoding -->|"executes in"| node_sandbox
node_hicoding -->|"sessions"| node_server
node_portalid -->|"auth"| node_server

click node_bootstrap "https://github.com/higress-group/himarket/blob/main/himarket-bootstrap/src/main/java/com/alibaba/himarket/HiMarketApplication.java"
click node_server "https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket"
click node_dal "https://github.com/higress-group/himarket/tree/main/himarket-dal/src/main/java/com/alibaba/himarket"
click node_product "https://github.com/higress-group/himarket/blob/main/himarket-server/src/main/java/com/alibaba/himarket/service/ProductService.java"
click node_mcp "https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/mcp"
click node_gateway "https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/gateway"
click node_hichat "https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/hichat"
click node_hicoding "https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/hicoding"
click node_portalid "https://github.com/higress-group/himarket/blob/main/himarket-server/src/main/java/com/alibaba/himarket/service/PortalService.java"
click node_admin "https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-admin/src/App.tsx"
click node_developer "https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/src/App.tsx"
click node_sandbox "https://github.com/higress-group/himarket/blob/main/sandbox/sidecar-server/server.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_server,node_dal,node_product,node_mcp,node_gateway,node_hichat,node_hicoding,node_portalid toneBlue
class node_admin,node_developer toneAmber
class node_sandbox toneMint
class node_mysql,node_nacos,node_gatewayinfra,node_sls,node_llm toneRose
```

## Components

### Backend

Spring Boot entrypoint, API/service layer, and persistence boundary

- [Bootstrap](https://github.com/higress-group/himarket/blob/main/himarket-bootstrap/src/main/java/com/alibaba/himarket/HiMarketApplication.java): Spring Boot entrypoint · Application wiring for security, MVC, WebSocket, Flyway, and filters · `himarket-bootstrap/src/main/java/com/alibaba/himarket/HiMarketApplication.java`
- [Server](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket): API and services · Controllers, service layer, auth, advice, and domain orchestration · `himarket-server/src/main/java/com/alibaba/himarket`
- [DAL](https://github.com/higress-group/himarket/tree/main/himarket-dal/src/main/java/com/alibaba/himarket): Persistence model · Entities, repositories, converters, and typed value objects · `himarket-dal/src/main/java/com/alibaba/himarket`
- [Products](https://github.com/higress-group/himarket/blob/main/himarket-server/src/main/java/com/alibaba/himarket/service/ProductService.java): Packaging layer · Product publication, subscriptions, refs, and category composition · `himarket-server/src/main/java/com/alibaba/himarket/service/ProductService.java`
- [MCP Orchestration](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/mcp): MCP lifecycle · Server metadata, transport resolution, config sync, and sandbox deploy orchestration · `himarket-server/src/main/java/com/alibaba/himarket/service/mcp`
- [Gateway Ops](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/gateway): Gateway integration · Operators and clients for Higress, APIG, Apsara, and AI gateway variants · `himarket-server/src/main/java/com/alibaba/himarket/service/gateway`
- [HiChat](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/hichat): Chat runtime · Model selection, tool invocation, chat formatting, and LLM adapters · `himarket-server/src/main/java/com/alibaba/himarket/service/hichat`
- [HiCoding](https://github.com/higress-group/himarket/tree/main/himarket-server/src/main/java/com/alibaba/himarket/service/hicoding): Coding workspace · Session orchestration, WebSocket routing, remote workspace, terminal, and sandbox control · `himarket-server/src/main/java/com/alibaba/himarket/service/hicoding`
- [Portal Identity](https://github.com/higress-group/himarket/blob/main/himarket-server/src/main/java/com/alibaba/himarket/service/PortalService.java): Auth and portal config · Portal settings, OIDC/OAuth2, login, developer/admin identity flows · `himarket-server/src/main/java/com/alibaba/himarket/service/PortalService.java`

### Web Frontends

Operator and developer React clients

- [Admin Portal](https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-admin/src/App.tsx): React admin console · Operator-facing UI for products, gateways, portals, MCP, sandbox, and observability · `himarket-web/himarket-admin/src/App.tsx`
- [Developer Portal](https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/src/App.tsx): React experience app · Marketplace, profile, chat, coding, subscriptions, and multilingual user flows · `himarket-web/himarket-frontend/src/App.tsx`

### Execution Runtime

Isolated sandbox process used for coding and tool execution

- [Sandbox Sidecar](https://github.com/higress-group/himarket/blob/main/sandbox/sidecar-server/server.js): Node runtime · Isolated exec, files, sessions, and terminal WebSocket boundary · `sandbox/sidecar-server/server.js`

### Infrastructure

External services and deployment targets

- **MySQL**: Primary database · Persistent store with Flyway-managed schema evolution
- **Nacos**: Config distribution · Configuration and service metadata sync target
- **Higress / AI Gateway**: External gateway · Traffic exposure layer for models, APIs, and MCP-related routes
- **Observability**: SLS and logging · Log, metrics, and scenario query integration
- **LLM Providers**: OpenAI and DashScope · External model backends accessed through server adapters

## Connections

- Admin Portal → Server: REST · Admin UI calls platform APIs
- Developer Portal → Server: REST · Developer UI calls marketplace and session APIs
- Developer Portal → Server: WebSocket/SSE · Live chat and coding streams
- Bootstrap → Server: wires · Bootstraps application modules and request pipeline
- Bootstrap → DAL: starts with · Loads persistence layer and migrations
- Server → DAL: reads/writes · Domain services persist through repositories
- DAL → MySQL: JPA · Repositories store entities in MySQL
- Server → Nacos: syncs · Configuration and market metadata integration
- Server → Higress / AI Gateway: exposes · Publishes model, API, and MCP endpoints through gateways
- Server → Observability: observes · Log and telemetry queries
- Server → LLM Providers: adapts · Chat services invoke external LLM providers
- Server → Sandbox Sidecar: orchestrates · Acquires, initializes, and monitors sandbox sessions
- Server → Products: packages · Products unify models, skills, MCP, and other offerings
- Products → MCP Orchestration: includes · Products can bundle MCP servers and configs
- Products → Gateway Ops: includes · Products reference gateway-backed resources
- Products → Portal Identity: targets · Portal settings and identity flows shape publication and access
- MCP Orchestration → Sandbox Sidecar: deploys to · MCP sandbox deployment and transport setup
- Gateway Ops → Higress / AI Gateway: drives · Gateway operators configure external exposure layers
- HiChat → LLM Providers: invokes · Chat runtime calls model adapters
- HiCoding → Sandbox Sidecar: executes in · Coding sessions rely on the isolated runtime boundary
- HiCoding → Server: sessions · WebSocket handlers and session orchestration live behind backend APIs
- Portal Identity → Server: auth · Login, OAuth2, OIDC, and portal settings are served by backend APIs
