Build
Overview
Section titled “Overview”GitLab Knowledge Graph has two parts: a backend (Rust workspace crates) and a frontend (Node workspace packages).
- Backend (Rust crates): define the data model, API, and services (e.g.,
crates/http-server-desktop,crates/database,crates/indexer). - Frontend (Node workspace packages):
@gitlab-org/gkg(packages/gkg/src): TypeScript bindings generated from Rust viats-rs.@gitlab-org/gkg-frontend(packages/frontend): Vue + Vite UI that depends on@gitlab-org/gkg.
The http-server-desktop crate embeds the frontend dist into the final gkg binary. Docs (packages/docs) build separately.
Build order
Section titled “Build order”- Generate TypeScript bindings from Rust via
ts-rs.
mise run bindings-gen# equivalentcargo test export_bindings --features no-frontendWe commit generated bindings to git; rebuild them whenever you change the Rust types that drive the API (primarily in crates/http-server-desktop).
- Build the frontend packages.
npm cinpm run build --workspace=@gitlab-org/gkg-frontendThe Rust HTTP server (crates/http-server-desktop) embeds packages/frontend/dist into the binary. Without --features no-frontend, the binary requires these assets to exist.
- Build the main binary (
gkg).
cargo build --release --bin gkgⓘ If you do not need the web UI, you can skip Node installation and frontend builds. Use the
no-frontendfeature when building:
cargo build --release --bin gkg --features no-frontendDocs build:
npm cinpm run build --workspace=docsⓘ Please check the
mise.tomlconfiguration file for many useful commands.
Speed up your builds
Section titled “Speed up your builds”Builds with the --release profile can take significantly more time than debug builds. Unless you want to run benchmarks, prefer debug builds to test the functionality of gkg.
Kuzu dynamic linking
Section titled “Kuzu dynamic linking”By default, Kuzu is built and statically linked to gkg, which makes the build at least much slower. For quicker
builds and tests, we recommend downloading the Kuzu binaries and using dynamic linking instead.
To do this:
-
Download and unpack the distributed
libkuzulibrary files. -
Set up your environment variables:
export KUZU_SHARED=1export KUZU_INCLUDE_DIR=/path/to/kuzu/includeexport KUZU_LIBRARY_DIR=/path/to/kuzu/lib- Now
cargo buildwill skip the complex Kuzu build step!
⚠️ Make sure your dynamic libraries match the Kuzu version specified in
Cargo.toml, otherwise you may encounter errors during build or runtime!
Code Quality Requirements
Section titled “Code Quality Requirements”The project enforces strict code quality standards:
- Unused imports fail builds: The workspace is configured with
unused_imports = "deny", meaning any unused imports will cause compilation to fail - Clippy linting: All clippy warnings are treated as errors (
-D warnings) - Formatting: Code must pass
rustfmtchecks
Run quality checks locally:
# Check for unused imports and other issuescargo check --workspace
# Run clippy linting (matches CI configuration)mise run rust-clippy
# Format codemise run rust-fmt:fixThe pre-commit hooks will automatically fix most issues, but it’s good practice to run these commands manually during development.