Agent Skillsiflytek/skillhub › backend-module-structure

backend-module-structure

GitHub

规范后端 Maven 多模块架构的代码放置与依赖方向,明确各层职责及包路径,指导新增或重构代码时正确选择模块。

.agents/skills/backend-module-structure/SKILL.md iflytek/skillhub

Trigger Scenarios

添加或修改 Java 后端代码 创建新的服务、控制器、仓库或实体 跨文件重构后端代码 审查后端代码放置

Install

npx skills add iflytek/skillhub --skill backend-module-structure -g -y
More Options

Non-standard path

npx skills add https://github.com/iflytek/skillhub/tree/main/.agents/skills/backend-module-structure -g -y

Use without installing

npx skills use iflytek/skillhub@backend-module-structure

指定 Agent (Claude Code)

npx skills add iflytek/skillhub --skill backend-module-structure -a claude-code -g -y

安装 repo 全部 skill

npx skills add iflytek/skillhub --all -g -y

预览 repo 内 skill

npx skills add iflytek/skillhub --list

SKILL.md

Frontmatter
{
    "name": "backend-module-structure",
    "license": "Apache-2.0",
    "description": "Rules for the SkillHub backend Maven multi-module clean architecture. Ensures agents place new code in the correct module and respect dependency direction."
}

Backend Module Structure Skill

Trigger

Use this skill when:

  • Adding or modifying Java backend code
  • Creating new services, controllers, repositories, or entities
  • Refactoring backend code across files
  • Reviewing backend code placement

Rules

Dependency Direction

The design-doc dependency direction:

app → domain, auth, search, storage, infra, notification
infra → domain          # implements domain repository interfaces
auth → domain
search → domain
notification → domain
storage → (independent) # pure SPI

Design intent: skillhub-domain should be the innermost layer, defining entities, repository interfaces, and domain services without depending on infra, auth, search, or storage.

Code reality: skillhub-domain declares a Maven dependency on skillhub-storage (via pom.xml), and several domain services (SkillHardDeleteService, SkillDownloadService, SkillPublishService, SkillGovernanceService, SkillQueryService, SkillStorageDeletionCompensationService) import com.iflytek.skillhub.storage.ObjectStorageService. This is an existing deviation from the ideal clean architecture. New code should avoid adding further cross-module dependencies from domain.

Where to Place Code

Code Type Module Java Package
Entity / Value Object skillhub-domain com.iflytek.skillhub.domain.{submodule}/
Repository Interface skillhub-domain com.iflytek.skillhub.domain.{submodule}/
Domain Service skillhub-domain com.iflytek.skillhub.domain.{submodule}/service/
Domain Event skillhub-domain com.iflytek.skillhub.domain/event/
Domain Exception skillhub-domain com.iflytek.skillhub.domain/shared/exception/
JPA Repository Impl skillhub-infra com.iflytek.skillhub.infra.repository/
Controller skillhub-app com.iflytek.skillhub.controller/
App Service skillhub-app com.iflytek.skillhub.service/
Query Repository skillhub-app com.iflytek.skillhub.repository/
DTO / Response skillhub-app com.iflytek.skillhub.dto/
OAuth2 / Auth Config skillhub-auth com.iflytek.skillhub.auth/
Search SPI / Impl skillhub-search com.iflytek.skillhub.search/
Storage SPI / Impl skillhub-storage com.iflytek.skillhub.storage/
Notification Service skillhub-notification com.iflytek.skillhub.notification/

Maven Modules

The parent POM (server/pom.xml) defines 7 modules with spring-boot-starter-parent:3.2.3:

skillhub-app | skillhub-domain | skillhub-auth | skillhub-search
skillhub-storage | skillhub-infra | skillhub-notification

Repository vs Query Repository

  • Domain Repository (skillhub-domain): Aggregate reads, state transitions, rule evaluation. Returns domain objects. Defined as interfaces, implemented in skillhub-infra via Spring Data JPA.
  • Query Repository (com.iflytek.skillhub.repository): Read-model assembly, joins multiple sources, presentation projection. Returns DTOs. Implemented directly in skillhub-app.

Current query repositories:

  • GovernanceQueryRepository / JpaGovernanceQueryRepository
  • MySkillQueryRepository / JpaMySkillQueryRepository
  • ProfileReviewQueryRepository / JpaProfileReviewQueryRepository
  • AdminSkillReportQueryRepository / JpaAdminSkillReportQueryRepository

When a new read use case arrives:

  1. If it's for state transition or domain rule → domain repository port
  2. If it's for page/list/detail response assembly with joins → app query repository
  3. If it's a thin single-aggregate read → direct domain repository call from app service
  4. If direct SQL/EntityManager is needed → add class-level comment explaining why

Building Backend Tests

Never run ./mvnw -pl skillhub-app clean test directly under server/. Use:

make test-backend-app   # skillhub-app + dependencies (includes -am)
make test-backend       # all backend modules

Running clean test on skillhub-app alone can fall back to stale artifacts from the local Maven repository, surfacing misleading cannot find symbol and signature-mismatch errors.

User Identity Type

User identity is always String throughout the codebase. This covers:

  • Authentication, API params, permissions, audit
  • Resource owner, creator, reviewer, actor, submittedBy
  • All user-associated fields

The UserAccount entity uses @Column(length = 128) for its ID. The platform needs to support external SSO/OIDC/SCIM identity sources whose UIDs are typically stable strings.

Version History

  • ac46ad5 Current 2026-07-25 07:07

Same Skill Collection

.agents/skills/api-and-namespace-design/SKILL.md
.agents/skills/code-conventions/SKILL.md
.agents/skills/dev-workflow/SKILL.md
.agents/skills/frontend-conventions/SKILL.md
.agents/skills/pr-submission/SKILL.md
.agents/skills/skill-lifecycle/SKILL.md
.agents/skills/testing-and-ci/SKILL.md
builtin-skills/skills/ai-claim-checker/SKILL.md
builtin-skills/skills/daily-standup-journal/SKILL.md
builtin-skills/skills/decision-matrix/SKILL.md
builtin-skills/skills/diagram-maker/SKILL.md
builtin-skills/skills/documentation-writer/SKILL.md
builtin-skills/skills/exam-ready/SKILL.md
builtin-skills/skills/frontend-design/SKILL.md
builtin-skills/skills/linkedin-post-formatter/SKILL.md
builtin-skills/skills/meeting-note-summarizer/SKILL.md
builtin-skills/skills/retrieval-practice-generator/SKILL.md
builtin-skills/skills/storytelling-advisor/SKILL.md
builtin-skills/skills/study-strategy-selector/SKILL.md
builtin-skills/skills/time-blocking-scheduler/SKILL.md
builtin-skills/skills/video-frames/SKILL.md
builtin-skills/skills/weather/SKILL.md

Metadata

Files
0
Version
d2403bb
Hash
59fe19b2
Indexed
2026-07-25 07:07

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 04:13
浙ICP备14020137号-1 $mapa de visitantes$