This file provides guidance to an AI coding tool when working with code in this repository.
Apache HugeGraph is a fast-speed and highly-scalable graph database that supports billions of vertices and edges. It is compliant with Apache TinkerPop 3 and supports both Gremlin and Cypher query languages.
Technology Stack:
- Java 11+ (required)
- Apache Maven 3.5+
- Apache TinkerPop 3.5.1
- gRPC for distributed communication
- RocksDB as default storage backend
This is a Maven multi-module project with 7 main modules:
- hugegraph-server: Core graph engine, REST APIs, and backend implementations (13 submodules)
- hugegraph-pd: Placement Driver (meta server) for distributed deployments (8 submodules)
- hugegraph-store: Distributed storage backend with RocksDB and Raft (9 submodules)
- hugegraph-commons: Shared utilities (locks, configs, RPC framework)
- hugegraph-struct: Data structure definitions
- install-dist: Distribution packaging
- hugegraph-cluster-test: Cluster integration tests
Client Layer (Gremlin/Cypher queries, REST APIs)
↓
Server Layer (hugegraph-server)
├─ REST API Layer (hugegraph-api): GraphAPI, SchemaAPI, GremlinAPI, CypherAPI, AuthAPI
├─ Graph Engine Layer (hugegraph-core): Schema management, traversal optimization, task scheduling
└─ Backend Interface: Abstraction over storage backends
↓
Storage Layer (pluggable backends)
├─ RocksDB (default, embedded)
├─ HStore (distributed, production)
└─ Legacy: MySQL, PostgreSQL, Cassandra, ScyllaDB, HBase, PaloFor production distributed deployments:
- hugegraph-pd: Service discovery, partition management, metadata coordination
- hugegraph-store: Distributed storage with Raft consensus (typically 3+ nodes)
- hugegraph-server: Multiple server instances (typically 3+)
All inter-service communication uses gRPC with Protocol Buffers.
- Pluggable Backend Architecture: Storage backends implement the
BackendStoreinterface, allowing new backends without modifying core code - TinkerPop Compliance: Full Apache TinkerPop 3 implementation with custom optimization strategies
- gRPC Communication: All distributed components communicate via gRPC (proto definitions in
*/grpc/directories) - Multi-Language Queries: Native Gremlin support + OpenCypher implementation in
hugegraph-api/opencypher
# Verify Java version (11+ required)
java -version
# Verify Maven version (3.5+ required)
mvn -version# Clean build with all modules
mvn clean install -DskipTests
# Build with tests
mvn clean install
# Build specific module (e.g., server only)
mvn clean install -pl hugegraph-server -am -DskipTests# Unit tests (memory backend)
mvn test -pl hugegraph-server/hugegraph-test -am -P unit-test
# Core tests with specific backend
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,memory
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,hbase
# API tests with backend
mvn test -pl hugegraph-server/hugegraph-test -am -P api-test,rocksdb
# TinkerPop compliance tests (for release branches)
mvn test -pl hugegraph-server/hugegraph-test -am -P tinkerpop-structure-test,memory
mvn test -pl hugegraph-server/hugegraph-test -am -P tinkerpop-process-test,memory# Build and test hugegraph-struct first (dependency)
mvn install -pl hugegraph-struct -am -DskipTests
# Test PD module
mvn test -pl hugegraph-pd/hg-pd-test -am
# Test Store module
mvn test -pl hugegraph-store/hg-store-test -am# License header check (Apache RAT)
mvn apache-rat:check
# Code style check (EditorConfig)
mvn editorconfig:check
# Compile with warnings
mvn clean compile -Dmaven.javadoc.skip=trueScripts are located in hugegraph-server/hugegraph-dist/src/assembly/static/bin/:
# Initialize storage backend
bin/init-store.sh
# Start server
bin/start-hugegraph.sh
# Stop server
bin/stop-hugegraph.sh
# Gremlin console
bin/gremlin-console.sh
# Enable authentication
bin/enable-auth.sh# Build distribution tarball (auto-enabled by default)
mvn clean package -DskipTests
# Skip assembly creation (if needed)
mvn clean package -DskipTests -Dskip-assembly-hugegraph
# Output: install-dist/target/hugegraph-<version>.tar.gz- Server configs:
hugegraph-server/hugegraph-dist/src/assembly/static/conf/hugegraph.properties- Main server configurationrest-server.properties- REST API settingsgremlin-server.yaml- Gremlin server configuration
- PD configs:
hugegraph-pd/hg-pd-dist/src/assembly/static/conf/ - Store configs:
hugegraph-store/hg-store-dist/src/assembly/static/conf/
- PD protos:
hugegraph-pd/hg-pd-grpc/src/main/proto/ - Store protos:
hugegraph-store/hg-store-grpc/src/main/proto/
- Graph engine:
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/ - REST APIs:
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/ - Backend implementations:
hugegraph-server/hugegraph-{backend}/(e.g.,hugegraph-rocksdb)
Configure your IDE to use .editorconfig for code style and style/checkstyle.xml for Checkstyle rules
When adding third-party dependencies:
- Add license files to
install-dist/release-docs/licenses/ - Declare dependency in
install-dist/release-docs/LICENSE - Append NOTICE info to
install-dist/release-docs/NOTICE(if upstream has NOTICE) - Update
install-dist/scripts/dependency/known-dependencies.txt(runregenerate_known_dependencies.sh)
When working on storage backends:
- All backends extend
hugegraph-server/hugegraph-coreabstractions - Implement the
BackendStoreinterface - Each backend is a separate Maven module in
hugegraph-server/ - Backend selection is configured in
hugegraph.propertiesvia thebackendproperty
When modifying .proto files:
- Generated Java code goes to
*/grpc/packages (excluded from Apache RAT checks) - Run
mvn clean compileto regenerate gRPC stubs - Generated files are in
target/generated-sources/protobuf/
Authentication is optional and disabled by default:
- Enable via
bin/enable-auth.shor configuration - Auth implementation:
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/auth/ - Multi-level: Users, Groups, Projects, Targets, Access control
- Required for production deployments
# Use Maven's -Dtest parameter
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,memory -Dtest=YourTestClassFor distributed development:
- Build struct module first:
mvn install -pl hugegraph-struct -am -DskipTests - Build PD:
mvn clean package -pl hugegraph-pd -am -DskipTests - Build Store:
mvn clean package -pl hugegraph-store -am -DskipTests - Build Server with HStore backend:
mvn clean package -pl hugegraph-server -am -DskipTests
See Docker Compose example: hugegraph-server/hugegraph-dist/docker/example/
- Enable detailed logging in
hugegraph-server/hugegraph-dist/src/assembly/static/conf/log4j2.xml - Use
bin/dump-conf.shto view effective configuration - Arthas diagnostics tool is included (version 3.7.1)
- Monitor with
bin/monitor-hugegraph.sh
The project uses multiple GitHub Actions workflows:
server-ci.yml: Server module tests (memory, rocksdb, hbase backends)pd-store-ci.yml: PD and Store module testscommons-ci.yml: Commons module testscluster-test-ci.yml: Distributed cluster integration testslicence-checker.yml: Apache RAT license validation
hugegraph-commonsis a shared dependency for all moduleshugegraph-structmust be built before PD and Store- Server backends depend on
hugegraph-core
- Version is managed via
${revision}property (currently1.7.0) - Flatten Maven plugin used for CI-friendly versioning