backend-conventionslisted
Install: claude install-skill ryokkon624/scrum-agent-base
# Backend Conventions
hw-hub-backend・hw-hub-batchの設計規約・実装方針。
---
## 1. アーキテクチャ(DDDライク 3層構造)
```
Presentation層 → Application層 → Domain層
↑
Infrastructure層 ─────┘
```
- Controller は Application Service を呼び出す。Repository を直接呼ばない
- Request/Response DTO は Controller 層に閉じる。Application Service には渡さない
- Entity(MyBatis Generator生成)は Infrastructure 層に閉じる。上位層へ出さない
- `com.hwhub.backend.domain.enums` 配下の自動生成Enumは編集禁止
### オブジェクト種別と層ごとの依存ルール
| 層 | オブジェクト種別 | Presentation | Application | Domain | Infrastructure | メモ |
| -------------- | --------------------------- | :----------: | :---------: | :----: | :------------: | ---------------------------------------------------------- |
| Presentation | request/response DTO | ○ | × | × | × | class / record どちらでも可 |
| Application | Presentation層への戻り値DTO | ○ | ○ | × | × | Service の Inner Class として record で実装 |
| Domain | Model | ○ | ○ | ○ | ○ | 業務的な単位・業務処理あり |
| Domain | 参照系Model | ○ | ○ | ○ | ○ | record で実装 |
| Domain | 検索条件VO | ○