
Spec
ApiHug 2.0 Architecture Design and Spec-Driven Development Guide for Large Language Models
Starting with ApiHug 2.0, we’ve undertaken significant refactoring to better support large language model–assisted collaborative development (Vibe Coding). Key improvements include:
These changes aim to streamline the development workflow and enhance collaboration with AI models. Please note that this release introduces substantial breaking changes due to core architectural updates.
Updated on 2026-01-03
ApiHug 2.0 is optimized for LLM (Large Language Model) driven development workflows through simplified protocol types, unified plugin context, and Spec-Driven development specifications, significantly improving the accuracy and consistency of AI code generation.
Background: Wrapper types (like google.protobuf.Int32Value) increase the burden of LLM understanding and easily lead to chaotic code generation.
Mandatory Specification: Use native proto3 basic types
| ❌ Deprecated Type | ✅ Standard Type |
|---|---|
google.protobuf.Int32Value | int32 |
google.protobuf.Int64Value | int64 |
google.protobuf.UInt64Value | uint64 |
google.protobuf.DoubleValue | double |
hope.common.BoolType | bool |
Example:
// ❌ Wrong approach
message OldRequest {
google.protobuf.Int32Value user_id = 1;
hope.common.BoolType is_active = 2;
}
// ✅ Correct approach
message NewRequest {
int32 user_id = 1;
bool is_active = 2;
}
Version Requirement: SDK ≥ 2.1.0-RELEASE
Architecture Changes:
com.apihug.wire, com.apihug.stubproto module + app modulecom.apihug.hopeapp moduleAdvantages:
gradle/libs.versions.toml:
[versions]
apihugVersion = "2.1.0-RELEASE"
[plugins]
# ❌ Deprecated (removed)
# hope-wire = { id = "com.apihug.wire", version.ref = "apihugVersion" }
# hope-stub = { id = "com.apihug.stub", version.ref = "apihugVersion" }
# ✅ Unified plugin
hope = { id = "com.apihug.hope", version.ref = "apihugVersion" }
hope-repl = { id = "com.apihug.repl", version.ref = "apihugVersion" }
build.gradle:
plugins {
id "java"
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependency)
alias(libs.plugins.hope) // ✅ Unified plugin
// ⚠️Remove the Liquibase plugin—it was never actively used and now causes dependency conflicts after the upgrade.⚠️
// alias(libs.plugins.liquibase)
}
hope {
debug = false
verbose = false
// Optional features
// enableFrontVue = true // Vue.js frontend generation
// enableMcp = true // MCP experimental feature
}
Detailed Configuration Reference:
ApiHug defines three core specifications based on Protocol Buffers extension capabilities:
| Specification Name | Scope | Documentation Link |
|---|---|---|
| API Directive Specification | Service/Method/Message/Field | View Details |
| Database Directive Specification | Domain Entity/Column | View Details |
| Enum Type Specification | Enum/EnumValue | View Details |
┌─────────────────────────────────────────┐
│ API Layer (api/) │
│ - RESTful interface definition │
│ - OpenAPI/Swagger documentation │
│ - Request/Response DTO │
└─────────────┬───────────────────────────┘
│
│ Forbid cross-layer reference
│
┌─────────────┴───────────────────────────┐
│ Domain Layer (domain/) │
│ - JPA Entity │
│ - Database table structure │
│ - DDL/Liquibase │
└─────────────┬───────────────────────────┘
│
│ Allow shared reference
│
┌─────────────┴───────────────────────────┐
│ Infra Layer (infra/) │
│ - Enum constants │
│ - Error codes │
│ - Global configuration │
└─────────────────────────────────────────┘
Architecture Principles:
BMAD (Breakthrough Method for Agile AI Driven Development): AI-driven development methodology based on ApiHug specifications.
Prerequisites: Requires installation of ApiHug REPL
| Path | Description | Use Cases |
|---|---|---|
/bmad:bmw:workflows:apihug-proto-design | Proto design workflow | Auto-generate API/Domain/Enum proto files |
/bmad:bmw:workflows:apihug-end-to-end | End-to-end development process | Complete implementation from requirements to code |
/bmad:bmw:workflows:apihug-project-review | Project review workflow | Code specification check and optimization suggestions |
/bmad:bmw:workflows:apihug-app-implement | Application implementation workflow | Generate Service layer code based on proto |
/bmad:bmw:agents:apihug | ApiHug intelligent agent | Interactive proto file writing assistance |
Detailed Usage:
Int32Value, etc.)PascalCase (messages) and snake_case (fields)description field instead of proto commentsTo upgrade to 2.1.0+ execute:
hope-wire and hope-stub from gradle/libs.versions.tomlbuild.gradle with alias(libs.plugins.hope)proto module into app module./gradlew clean build to verify build