[Refactor/#14] 도메인 모듈 패키지 구조·경계 검증 방식 변경 및 infrastructure:db 설정 골격 - #15
Open
tnals0924 wants to merge 4 commits into
Open
[Refactor/#14] 도메인 모듈 패키지 구조·경계 검증 방식 변경 및 infrastructure:db 설정 골격#15tnals0924 wants to merge 4 commits into
tnals0924 wants to merge 4 commits into
Conversation
…경계는 ArchUnit으로 강제
Collaborator
|
sangrae2325
approved these changes
Sep 5, 2026
Collaborator
|
jjunh33
approved these changes
Sep 7, 2026
xeoxxn
self-requested a review
September 7, 2026 05:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
🎯 해결하려는 문제가 무엇인가요?
엔티티 26개를 추가하는 #13에 앞서, 그 코드가 올라갈 도메인 모듈의 구조와 경계 검증 방식을 먼저 정한다. 아울러
infrastructure:db가 실제 MySQL에 붙을 수 있는 설정 골격을 만든다. 이 PR은 기존 member 코드에만 적용하며 새 테이블·엔티티는 포함하지 않는다.❓ 왜 해결해야 하나요?
internal)은 도메인·계층 단위로 패키지를 나누고 싶은 요구와 맞지 않았다.impl하나를 감추려고 공개 패키지마다@NamedInterface를 달아야 한다. 도메인이 늘수록 부담이 커진다.⭐ 어떻게 해결했나요?
{module}.domain.{도메인}.{domain|repository|service|service.impl}. 도메인 객체만 있는 도메인도 계층 패키지를 생략하지 않는다.@ApplicationModule(type = OPEN)으로 두고,service.impl차단은 ArchUnit 테스트DomainImplAccessTests가 담당한다. 규칙은 두 개 —..service.impl..은 같은 패키지 안에서만 참조 가능,..service.impl..에 public 클래스 금지.@Getter+@EqualsAndHashCode+ private 전체 생성자 +static of(...)). setter는 Lombok으로 만들지 않고 필요한 필드에만 수동으로 둔다.deleted_at DATETIME→is_deleted TINYINT(1)(BaseSoftDeleteEntity.isDeleted).application-infrastructure-db.yml(MySQL,ddl-auto: validate, Flyway),.env.example의DB_*,BaseCreatedTimeEntity, db 모듈의 도메인 모듈 의존.contextLoads를 제거했다. 남는 테스트는ModularityTests(모듈 간 순환·의존)와DomainImplAccessTests(impl 경계)다.🧩 이 PR의 한계 & 트레이드오프
verify()의 역할이 모듈 간 순환·의존 검사로 줄고, 모듈 내부 경계는 ArchUnit이 맡는다.contextLoads가 없어져 Entity 매핑 오류는 애플리케이션 기동(bootRun)에서만 드러난다.coding-style.md2-1절(도메인 객체 record)과flyway-migration.md(deleted_at예시)는 이 PR에서 고치지 않았다. 별도 docs 작업이 필요하다.⛓️ 기존 기능에 미치는 영향
Member가 record에서 클래스로 바뀌어 접근자가id()→getId(), 생성이new Member(...)→Member.of(...)로 바뀐다. 현재 호출처는MemberJpaEntity뿐이다.Member.studentNo→studentId로 이름을 바꿨다.MemberService등 member 타입의 패키지가 바뀐다. 현재 다른 모듈에서 참조하는 곳은infrastructure:db뿐이며 함께 수정했다.bootstrap/application.yaml이application-infrastructure-db.yml을 import하므로 기동 시DB_URL/DB_USERNAME/DB_PASSWORD환경변수가 필요하다.🔀 Edge Case & 실패 시나리오
service.impl에 public 클래스를 두거나 다른 패키지에서 참조하면DomainImplAccessTests가 실패한다. 실험으로 확인했다(임시 파일은 제거).package-info.java(OPEN)를 빠뜨리면 그 모듈의 하위 패키지 참조가verify()에서 실패한다.📋 검토한 대안과 선택 이유
@NamedInterface를 공개 계층 패키지마다 선언: 정확하지만 도메인당package-info.java3개가 늘고 하나만 빠져도verify()가 깨진다. 처음 이 방식으로 구현했다가 OPEN + ArchUnit으로 바꿨다.internal) 유지: 어노테이션이 필요 없지만 도메인·계층 단위 패키지를 포기해야 한다.ddl-auto: create-drop유지: Entity 매핑 검증에는 유용하지만 DB를 쓰는 테스트를 두지 않기로 한 방침과 어긋나 제거했다.💬 리뷰 포인트
[r]architecture.md4-3절 — 패키지 구조와 OPEN + ArchUnit 방식에 동의하는지[r]DomainImplAccessTests규칙 1이 같은 도메인의service패키지에서impl을 참조하는 것도 막는데, 이 강도가 적절한지[c]도메인 객체를 record 대신 클래스로 두는 결정(coding-style.md2-10·2-11절과의 정합)[c]is_deletedboolean으로의 변경