backend/common is the shared contract layer for all AetherFlow backend services. Microservices should depend on these contracts instead of redefining response wrappers, error codes, JWT helpers, MQ event envelopes, or shared DTOs.
Use com.aetherflow.common.core.Result<T> for every controller and Feign response.
Required conventions:
- Success:
Result.success(data) - Empty success:
Result.success() - Failure: throw
BusinessException; do not manually assemble error JSON in business code. traceIdandpathfields are reserved for request correlation and can be filled by filters/interceptors.
Use ErrorCode as the stable interface and ResultCode as the default shared enum.
Service-specific modules may define their own enum:
public enum WorkflowErrorCode implements ErrorCode {
DAG_INVALID(42001, "workflow dag invalid");
private final int code;
private final String message;
}Do not create another unrelated error-code interface in a microservice.
Use BaseEntity for new MyBatis Plus entities when the table has:
id
created_at
updated_at
Existing entities may migrate to it in service-specific tasks. Do not migrate multiple services in the same feature branch unless the task explicitly covers it.
Use:
JwtPropertiesJwtUserClaimsJwtTokenProvider
Gateway validates JWT and forwards:
X-User-Id
X-Username
X-Roles
Business services should consume these headers instead of parsing JWT again unless they own an auth-specific concern.
Internal endpoints under /internal/** are service-to-service APIs and should not be exposed through Gateway unless a task explicitly approves it.
File metadata registration uses:
- Endpoint:
POST file-service/internal/files/metadata - Header:
X-Internal-File-Token - Token source:
FILE_INTERNAL_TOKEN
ai-service and file-service must use the same FILE_INTERNAL_TOKEN value in shared environments. Gateway routes only public /files/** traffic to file-service; callers should use service discovery for the internal metadata API.
Use MqEvent<T> when publishing cross-service business events. Use TaskMessageDTO and NotifyMessageDTO for the already-defined task and notification flows.
Required event fields:
eventIdeventTypesourceServiceaggregateIdtraceIdoccurredAtpayload
Queue, exchange, and routing-key names must come from RabbitMqNames.
DTOs that cross service boundaries belong in backend/common/src/main/java/com/aetherflow/common/dto.
Internal request classes that are only used by one controller may stay inside that service module.
OpenApiConfig provides shared Swagger metadata and JWT bearer security scheme. Service modules should keep service-specific endpoint annotations in their own controllers, but should not duplicate global OpenAPI configuration.