Skip to content

Refactor: 프로젝트 구조 리팩토링#1

Merged
dungbik merged 2 commits intomainfrom
refactor/project-structure
Apr 3, 2026
Merged

Refactor: 프로젝트 구조 리팩토링#1
dungbik merged 2 commits intomainfrom
refactor/project-structure

Conversation

@dungbik
Copy link
Copy Markdown
Contributor

@dungbik dungbik commented Apr 3, 2026

Summary by CodeRabbit

릴리스 노트

  • Documentation

    • FlipNote Notification Service 사용 가이드 및 환경 설정 문서 추가
  • Bug Fixes

    • FCM 알림 전송 시 서버 오류 및 토큰 검증 처리 개선
    • 무효한 토큰에 대한 더 나은 오류 분류 및 처리
  • Refactor

    • 알림 조회 API 응답 형식 개선
    • FCM 토큰 등록 프로세스 간소화

@dungbik dungbik requested a review from stoneTiger0912 April 3, 2026 18:32
@dungbik dungbik self-assigned this Apr 3, 2026
@dungbik dungbik added the enhancement New feature or request label Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

FlipNote 알림 서비스의 아키텍처를 재구성하여, DTO와 예외 클래스를 적절한 계층(application, domain, infrastructure, interfaces)으로 이동하고, 서비스 메서드 시그니처를 변경하며, FCM 전송 결과 처리를 위한 새로운 도메인 모델을 도입하는 광범위한 레이어링 및 패키지 재정렬.

Changes

Cohort / File(s) Summary
README 문서
README.md
FlipNote 알림 서비스 설명, 기술 스택, 시작 가이드, 필수 환경변수, CI/CD 동작, 디렉토리 구조 문서화
Application 계층 서비스 재구성
src/main/java/flipnote/notification/application/FcmSender.java, src/main/java/flipnote/notification/application/FcmTokenService.java, src/main/java/flipnote/notification/application/NotificationCommandService.java, src/main/java/flipnote/notification/application/NotificationQueryService.java
service 서브패키지에서 application 계층으로 승격, 메서드 시그니처 변경 (요청 DTO 대신 커맨드/문자열 매개변수 사용), FCM 결과 처리 로직 단순화
Application DTO 모델링
src/main/java/flipnote/notification/application/dto/command/NotificationListCommand.java, src/main/java/flipnote/notification/application/dto/result/FcmSendResult.java, src/main/java/flipnote/notification/application/dto/result/NotificationResult.java, src/main/java/flipnote/notification/application/dto/result/PagedResult.java
새로운 커맨드, 결과 DTO 추가 (NotificationListCommand, FcmSendResult, PagedResult), NotificationResponse를 NotificationResult로 이름 변경, @JsonFormat 제거
Application 계층 DTO 제거
src/main/java/flipnote/notification/application/dto/request/NotificationListRequest.java, src/main/java/flipnote/notification/application/port/FcmSender.java, src/main/java/flipnote/notification/common/response/CursorPagingResponse.java
요청 기반 DTO 및 레거시 port 인터페이스 제거, 공통 응답 모델 제거
Domain 계층 구조화
src/main/java/flipnote/notification/domain/common/BizException.java, src/main/java/flipnote/notification/domain/common/CommonErrorCode.java, src/main/java/flipnote/notification/domain/common/ErrorCode.java, src/main/java/flipnote/notification/domain/notification/NotificationErrorCode.java
예외 클래스를 common.exception에서 domain.common으로 이동, NotificationErrorCode를 domain.notification으로 이동
Domain 엔티티 및 저장소
src/main/java/flipnote/notification/domain/notification/Notification.java, src/main/java/flipnote/notification/domain/fcmtoken/FcmTokenRepository.java
Notification 엔티티 필드 가시성을 private으로 명시화, FCM 토큰 저장소에 명시적 JPQL DELETE 쿼리 및 @Transactional 추가
Infrastructure 설정 및 메시징
src/main/java/flipnote/notification/infrastructure/config/AppConfig.java, src/main/java/flipnote/notification/infrastructure/config/SwaggerConfig.java, src/main/java/flipnote/notification/infrastructure/persistence/JpaAuditingConfig.java, src/main/java/flipnote/notification/infrastructure/messaging/*
Jackson LocalDateTime 직렬화 설정 추가, Swagger 기본 포트 변경 (8081→8086), JpaAuditingConfig 이동, 메시징 클래스를 infrastructure.messaging으로 이동
FCM 인프라 구현
src/main/java/flipnote/notification/infrastructure/fcm/FirebaseFcmSender.java
반환 타입을 BatchResponse에서 FcmSendResult로 변경, 예외 처리 로직 추가 (BizException 변환), 토큰 분류 헬퍼 메서드 추가
HTTP 인터페이스 계층 구축
src/main/java/flipnote/notification/interfaces/http/NotificationController.java, src/main/java/flipnote/notification/interfaces/http/NotificationControllerDocs.java, src/main/java/flipnote/notification/interfaces/http/common/*, src/main/java/flipnote/notification/interfaces/http/dto/request/*
rest 패키지를 http로 재명명, 새로운 CursorPagingResponse 및 공통 HTTP 클래스 추가, request DTO를 인터페이스 계층으로 이동, GlobalExceptionHandler 재위치 및 응답 형식 변경 (String→ApiResponse)

시퀀스 다이어그램

sequenceDiagram
    participant Client
    participant NotificationController
    participant NotificationQueryService
    participant NotificationRepository
    participant PagedResult as PagedResult Factory
    participant CursorPagingResponse as CursorPagingResponse Factory
    participant Response

    Client->>NotificationController: GET /notifications<br/>(NotificationListRequest)
    NotificationController->>NotificationController: req.toCommand()
    NotificationController->>NotificationQueryService: getNotifications(userId, NotificationListCommand)
    NotificationQueryService->>NotificationRepository: findAll(PageRequest)
    NotificationRepository-->>NotificationQueryService: List<Notification>
    NotificationQueryService->>NotificationQueryService: 목록 자르기 & hasNext 계산
    NotificationQueryService->>NotificationQueryService: NotificationResult 매핑
    NotificationQueryService->>PagedResult: of(content, hasNext, nextCursor)
    PagedResult-->>NotificationQueryService: PagedResult<NotificationResult>
    NotificationQueryService-->>NotificationController: PagedResult<NotificationResult>
    NotificationController->>CursorPagingResponse: from(PagedResult)
    CursorPagingResponse-->>NotificationController: CursorPagingResponse
    NotificationController-->>Response: ResponseEntity<CursorPagingResponse>
    Response-->>Client: 200 OK + 페이징 응답
Loading
sequenceDiagram
    participant Client
    participant NotificationController
    participant NotificationCommandService
    participant FirebaseFcmSender
    participant Firebase as Firebase Messaging
    participant FcmSendResult as FcmSendResult Factory
    participant FcmTokenService

    Client->>NotificationController: POST /notify (title, body, tokens)
    NotificationController->>NotificationCommandService: sendFcmNotification(...)
    NotificationCommandService->>FirebaseFcmSender: sendEachForMulticast(tokens, title, body)
    FirebaseFcmSender->>Firebase: sendEachForMulticast(message)
    Firebase-->>FirebaseFcmSender: BatchResponse
    FirebaseFcmSender->>FirebaseFcmSender: toSendResult(BatchResponse)<br/>분류: validTokens vs invalidTokens
    FirebaseFcmSender->>FcmSendResult: new FcmSendResult(...)
    FcmSendResult-->>FirebaseFcmSender: FcmSendResult
    FirebaseFcmSender-->>NotificationCommandService: FcmSendResult
    NotificationCommandService->>FcmTokenService: deleteInvalidTokens(invalidTokens)
    FcmTokenService-->>NotificationCommandService: 완료
    NotificationCommandService-->>Client: 응답
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 패키지를 정렬하고 계층을 나누니,
응용과 도메인이 이제 구분되네!
DTO는 인터페이스로, 예외는 도메인으로,
깔끔한 아키텍처 위에 서비스 춤을 춘다네! ✨
커맨드와 결과로, 흐름이 명확하니,
유지보수도 이제 토끼 점프처럼 가볍구나!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 PR의 주요 변경사항인 프로젝트 구조 리팩토링을 명확하게 설명하고 있으며, 간결하고 의미 있는 표현을 사용하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/project-structure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dungbik dungbik merged commit 1b4e0ed into main Apr 3, 2026
2 of 3 checks passed
@dungbik dungbik deleted the refactor/project-structure branch April 3, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant