Skip to content

Latest commit

 

History

History
230 lines (174 loc) · 9.22 KB

developer-guide.md

File metadata and controls

230 lines (174 loc) · 9.22 KB

Developer guide

This guide helps you get started developing HAMi-WebUI.

Dependencies

Make sure you have the following dependencies installed before setting up your developer environment:

macOS

We recommend using Homebrew for installing any missing dependencies:

brew install git
brew install go
brew install node@24
brew install protobuf
export PATH="$(brew --prefix node@24)/bin:$PATH"
corepack enable

Download HAMi-WebUI

We recommend using the Git command-line interface to download the source code for the HAMi-WebUI project:

  1. Open a terminal and run git clone https://github.com/Project-HAMi/HAMi-WebUI.git. This command downloads HAMi-WebUI to a new hami-webui directory in your current directory.
  2. Open the HAMi-WebUI directory in your favorite code editor.

For alternative ways of cloning the HAMi-WebUI repository, refer to GitHub's documentation.

Bootstrap local dependencies

Run dependency installation explicitly once from the repository root. Normal build and development commands never update dependencies as a side effect.

make bootstrap
export PATH="$(go env GOPATH)/bin:$PATH"
make -C server bootstrap
pnpm exec playwright install chromium

make bootstrap uses the committed lockfile and fails instead of rewriting it. The server bootstrap installs the pinned Go code generators; protoc remains a system prerequisite. Re-run the relevant bootstrap command only after its dependency or tool versions change. On Linux, use pnpm exec playwright install --with-deps chromium when Chromium's system libraries are not already installed.

Build and run HAMi-WebUI

Chart 2 deploys one application image and one container. Its Go process serves the built Vue application on port 3000, invokes the versioned API handler in-process, and exposes readiness, metrics, and diagnostics on the internal port 8000.

Node.js and pnpm remain build and test dependencies for the Vue application. They are not present in the production image.

Backend development

The backend reads the active kubeconfig context and server/config/config.yaml. Select a development cluster you are authorized to inspect and configure a reachable Prometheus address before starting it.

Build the SPA assets, generate the Go API code, and launch hami-webui from the repository root:

make build
make -C server generate
(cd server && go run ./cmd/hami-webui --conf ./config/config.yaml --static-dir ../public --listen-address 127.0.0.1:8080)

cmd/hami-webui defaults --listen-address to :3000 (for standalone use without Vite) and serves /metrics and /readyz on :8000 (from server/config/config.yaml). Passing 127.0.0.1:8080 leaves :3000 free for the Vite development server.

Frontend development

Start the backend on 127.0.0.1:8080, then run make dev in the repository root. This starts the Vite development server; NestJS is not part of the browser development path. Vite forwards /api/v1/* directly to HAMI_WEBUI_BACKEND_URL (default http://127.0.0.1:8080) without stripping a prefix.

Open http://localhost:3000/. Set HAMI_WEBUI_BACKEND_URL when the backend uses another origin:

HAMI_WEBUI_BACKEND_URL=http://127.0.0.1:18000 make dev

Before opening a pull request, run the checks for the area you changed:

make verify
make -C server verify
bash scripts/verify-chart.sh  # when the Helm chart changes

The root verification target covers Vue lint and tests, the production asset build, the Go Web entry, and its HTTP and Chromium contracts. The server target generates code before building, vetting, and testing every Go package. CI calls the same granular Make targets so local and pull-request behavior stay aligned.

To exercise the standalone Web entry while changing its static-serving contract:

make build build-web-entry
server/build/web-entry --static-dir ./public --backend-url http://127.0.0.1:8080

The backend API listener must be available at --backend-url for /api/v1/* requests in this standalone mode.

Detail page sections

Use BlockBox with variant="detail" for the main information, resource and allocation sections on detail pages. Pass the section heading through title and heading actions through the extra slot, so the shared component owns the space around the heading and content.

Spacing layer Detail section rule
Card padding 12px top, 16px on the other sides
Section heading 16px, weight 500, line height 28px
Heading to content 8px
Between sibling sections 16px
Before the trend controls 24px

Do not add a second top margin to the first content element or override these values independently on each page. A flex or grid parent that owns the section gap should clear its children's outer margins. Internal allocation diagrams, tables and chart legends keep their own content spacing; the default BlockBox variant remains available for chart and dashboard cards.

Check Chinese and English at 1280, 1366, 1440 and 1920 CSS pixels when changing these shared rules. Include long device names, multiple devices, help buttons, and loading or unavailable states, as well as the normal populated view.

Chart 2 application contract

The official image owns its OCI entrypoint; the Chart does not inject an implementation-specific command. The image runs as a numeric non-root user and is verified on amd64 and arm64 with a read-only root filesystem.

The public listener exposes the SPA and only the versioned HAMi Web API below /api/v1/*. Internal /metrics and /readyz endpoints remain on port 8000 for readiness probes and Prometheus scraping. The browser API calls the backend handler directly in-process; there is no loopback reverse proxy.

The unified application accepts these optional environment variables:

Variable Default Purpose
HAMI_WEBUI_LISTEN_ADDRESS :3000 Public Web listener; the Chart requires :3000
HAMI_WEBUI_STATIC_DIR /apps/public Built Vue asset directory
HAMI_WEBUI_BASE_PATH / Public URL prefix; the reverse proxy must preserve it
HAMI_WEBUI_FRAME_ANCESTORS_JSON unset JSON framing allowlist; [] blocks all parents
HAMI_WEBUI_HEALTHCHECK_URL http://127.0.0.1:3000/health_check Target used only by --healthcheck

HAMI_WEBUI_BACKEND_URL and HAMI_WEBUI_PROXY_TIMEOUT apply only to the standalone Web-entry development binary. They are intentionally absent from the Chart 2 in-process runtime. The public port, health endpoint, and versioned API prefix are compatibility contracts; filesystem paths and executable names are not.

The application can serve the SPA below a configured base path and emit a validated CSP frame-ancestors policy. These are runtime settings, not Vite build variables. The unprefixed /health_check remains stable for Chart probes. When installing with Helm, use frontend.basePath and frontend.frameAncestors; the Chart owns the corresponding generated environment variables so its Ingress checks and access notes describe the actual runtime. Direct image and local binary users can continue using the environment variables above.

Chart 2 Service and probe topology

The primary Service routes browser traffic to port 3000. An independently labelled *-backend ClusterIP Service routes port 8000 to the same container and is the only Service selected by the included ServiceMonitor. The backend component label belongs to this discovery Service, not to a separate workload or authorization boundary. The primary Service never exposes port 8000 in Chart 2.

The startup probe waits for /readyz on port 8000 for up to 300 seconds so Kubernetes informer caches can synchronize. After startup, readiness and liveness probe /health_check on port 3000. This separates slow initial data bootstrap from the ongoing ability to serve the Web entry.

Build a Docker image

Build the same application image used by development publication, Chart 2, and release candidates:

make build-image

The resulting image is tagged hami-webui:dev. Override DOCKER_IMAGE, VERSION, or PLATFORM when a local integration environment needs another tag or architecture:

make build-image \
  DOCKER_IMAGE=my-registry/hami-webui \
  VERSION=test \
  PLATFORM=linux/amd64

This target builds one local image and never pushes it. Stable multi-platform images, the Helm chart, release tag, and release notes are published only through the verified release process.

Chart 1.3 rollback restores its complete two-image deployment. Do not combine a Chart 1.x frontend or backend image with the Chart 2 templates; see the Helm migration guide.