Skip to content

[3주차] 도메인 구현 - 오세룡#109

Open
letter333 wants to merge 8 commits intoLoopers-dev-lab:letter333from
letter333:WEEK3-clean
Open

[3주차] 도메인 구현 - 오세룡#109
letter333 wants to merge 8 commits intoLoopers-dev-lab:letter333from
letter333:WEEK3-clean

Conversation

@letter333
Copy link

@letter333 letter333 commented Feb 26, 2026

📌 Summary

  • 배경: WEEK3 과제로 커머스 API 전체 도메인 구현 필요
  • 목표: 회원, 주소, 브랜드, 카테고리, 상품, 주문, 좋아요 도메인 TDD 방식으로 구현
  • 결과: 전체 521개 테스트 통과, E2E 테스트로 API 동작 검증 완료

🧭 Context & Decision

문제 정의

  • 현재 동작/제약: 기본 프로젝트 구조만 존재, 도메인 로직 없음
  • 문제(또는 리스크): 커머스 플랫폼의 핵심 기능 부재
  • 성공 기준(완료 정의): 모든 API 엔드포인트 동작, 테스트 통과

선택지와 결정

  • 고려한 대안 1:

    • A: 단순 CRUD 중심 구현
    • B: 도메인 주도 설계(DDD) 패턴 적용
  • 최종 결정: B - DDD 패턴 적용 (Entity, Repository, Service 계층 분리)

  • 트레이드오프: 초기 설계 복잡도 증가 vs 유지보수성/확장성 향상

  • 추후 개선 여지: 이벤트 기반 아키텍처 도입 고려

  • 고려한 대안 2:

    • A: 도메인 계층 완전 순수성 유지
    • B: 약간의 스프링 의존 허용
  • 최종 결정: B - @component, Page등 약간의 의존 유지

  • 트레이드오프: 수동 빈 등록으로 순수성 유지 vs 생산성을 위한 약간의 의존

  • 추후 개선 여지: List로 반환한 뒤 필요한 계층에서 Page로 감싸는 방식 고려

🏗️ Design Overview

변경 범위

  • 영향 받는 모듈/도메인: commerce-api 전체
  • 신규 추가: Member, Address, Brand, Category, Product, Order, Like 도메인
  • 제거/대체: 없음

주요 컴포넌트 책임

  • Domain Layer: 비즈니스 로직 캡슐화 (Entity, Repository 인터페이스, Service)
  • Application Layer: 유즈케이스 오케스트레이션 (Facade, Command, Info DTO)
  • Infrastructure Layer: 영속성 구현 (JPA Entity, Repository 구현체)
  • Interfaces Layer: REST API (Controller, DTO, ApiSpec)

🔁 Flow Diagram

Main Flow

sequenceDiagram
  autonumber
  participant Client
  participant Controller
  participant Facade
  participant Service
  participant Repository
  participant DB
  
  Client->>Controller: HTTP Request
  Controller->>Facade: Command/Query
  Facade->>Service: 도메인 로직 호출
  Service->>Repository: 데이터 조회/저장
  Repository->>DB: SQL 실행
  DB-->>Repository: 결과
  Repository-->>Service: Domain Entity
  Service-->>Facade: Domain Entity
  Facade-->>Controller: Info DTO
  Controller-->>Client: ApiResponse
Loading

📝 Commit History (도메인별 정리 - 8개 커밋)

# 커밋 주요 내용
1 docs: 설계 문서 및 프로젝트 기본 설정 CLAUDE.md, 설계 문서, ErrorType 추가, AdminValidator
2 feat: Member 도메인 구현 회원가입, 로그인, 프로필 조회 API
3 feat: Address 도메인 구현 배송지 CRUD, 기본 배송지 설정
4 feat: Brand 도메인 구현 브랜드 CRUD, N+1 최적화 배치 조회
5 feat: Category 도메인 구현 카테고리 CRUD
6 feat: Product 도메인 구현 상품 CRUD, 검색, SOLDOUT 자동 전환, 옵션/이미지
7 feat: Order 도메인 구현 주문 생성/취소, 트랜잭션 경계 최적화
8 feat: Like 도메인 구현 좋아요 토글, 상품 좋아요 수 연동

✅ Test Plan

  • 전체 테스트 통과 (521개)
  • E2E 테스트 (Admin API 23개 포함)
  • 통합 테스트 (TestContainers)

🔧 주요 개선 사항

  1. 트랜잭션 경계 최적화: 주문 취소 시 재고 복구를 먼저 수행하여 롤백 안전성 확보
  2. N+1 쿼리 최적화: 브랜드 배치 조회 (IN 쿼리) 도입
  3. Product SOLDOUT 자동 전환: 재고 0 시 자동 품절 처리
  4. Admin API E2E 테스트: 상품 관리 API 전체 E2E 테스트 추가

🤖 Generated with Claude Code

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

letter333 and others added 8 commits February 27, 2026 02:05
- CLAUDE.md 프로젝트 규칙 문서 추가
- 요구사항, 시퀀스, 클래스, ERD 설계 문서 작성
- ErrorType FORBIDDEN, CONFLICT 추가
- AdminValidator, PasswordEncoderConfig 추가
- ApiControllerAdvice 예외 처리 보강

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Member Entity, Repository, Service 계층 구현
- MemberFacade 유즈케이스 오케스트레이션
- 회원가입 API (loginId 중복 검증, 비밀번호 암호화)
- 로그인 API (인증 처리)
- 프로필 조회 API
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Address Entity, Repository, Service 계층 구현
- AddressFacade 유즈케이스 오케스트레이션
- 배송지 CRUD API (생성, 조회, 수정, 삭제)
- 기본 배송지 설정 기능
- 회원별 배송지 목록 조회
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Brand Entity, Repository, Service 계층 구현
- BrandFacade 유즈케이스 오케스트레이션
- Brand Admin API (CRUD) 구현
- Brand 사용자 API (목록/상세 조회) 구현
- N+1 쿼리 최적화를 위한 배치 조회 메서드 추가
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Category Entity, Repository, Service 계층 구현
- CategoryFacade 유즈케이스 오케스트레이션
- Category Admin API (CRUD) 구현
- Category 사용자 API (목록/상세 조회) 구현
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Product, ProductOption, ProductImage Entity 구현
- ProductValidator를 통한 도메인 검증 로직 캡슐화
- ProductStatus (ACTIVE, STOP, SOLDOUT) 상태 관리
- 재고 0일 때 SOLDOUT 자동 전환 로직
- LIKES_DESC 정렬 지원 (좋아요 수 내림차순)
- Product Admin API (CRUD, 상태/할인 관리)
- 상품 검색 (키워드, 카테고리 필터링)
- QueryDSL 기반 동적 쿼리 구현
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Order, OrderProduct Entity 구현
- OrderStatus (PENDING, PAID, SHIPPING, DELIVERED, CANCELLED) 상태 관리
- OrderProductStatus (NORMAL, CANCELLED) 개별 상품 상태
- 주문 생성 시 재고 차감 로직
- 주문 취소 시 재고 복구 (트랜잭션 경계 최적화: 복구 먼저)
- Order Admin API (목록 조회, 상태 변경)
- 주문 기간별 필터링 (OrderPeriod)
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Like Entity, Repository, Service 계층 구현
- LikeFacade 유즈케이스 오케스트레이션
- 좋아요 토글 API (추가/취소)
- TargetType (PRODUCT) 지원
- 상품 좋아요 수 실시간 연동
- 통합 테스트 및 E2E 테스트 작성

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant