Skip to content

#121 refactor(architecture): Global Layout, Route Guard, Query Key Factory, 타입 분리 아키텍처 리팩토링 - #126

Merged
kaeuhy merged 2 commits into
developfrom
#121-refactor-route-fetch
Apr 1, 2026
Merged

#121 refactor(architecture): Global Layout, Route Guard, Query Key Factory, 타입 분리 아키텍처 리팩토링#126
kaeuhy merged 2 commits into
developfrom
#121-refactor-route-fetch

Conversation

@kaeuhy

@kaeuhy kaeuhy commented Apr 1, 2026

Copy link
Copy Markdown
Member

🛠️ 설명 (Description)

  • 이번 PR에서는 라우팅 구조와 API/타입 구조를 전반적으로 리팩토링하여, 인증 흐름 일관성, 레이아웃 중복 제거, TanStack Query 캐시 키 일관성, 도메인 기반 파일 구조 개선을 진행했습니다.
  • 이를 통해 페이지 단위에서 흩어져 있던 인증/레이아웃/쿼리 키 로직을 중앙에서 관리할 수 있도록 아키텍처를 재구성했습니다.

📝 변경 사항 요약 (Summary)

  • GlobalLayout 도입으로 Header/Footer를 전역 레이아웃에서 관리하고, 개별 페이지의 중복 레이아웃 코드를 제거했습니다.

  • RouteGuard 컴포넌트를 추가하여 ‎type="private" | "public" 기반으로 인증/비인증 접근 제어를 통합 관리하고, 각 페이지 내부의 ‎localStorage 토큰 체크 로직을 제거했습니다.

  • queryKeys.ts에 Query Key Factory 패턴을 도입하여 ‎performanceKeys, ‎reviewKeys, ‎seatKeys, ‎paymentKeys를 정의하고, TanStack Query 전역에서 동일한 쿼리 키를 사용하도록 통일했습니다.

  • WaitingRoom과 SeatSelectPage에서 사용하던 좌석/좌석 상태 쿼리 키를 ‎["seats", stadiumId], ‎["seatStatus", scheduleId]에서 ‎seatKeys.definitions(stadiumId), ‎seatKeys.states(scheduleId)로 변경하여 캐시 키 불일치로 인한 버그를 해결했습니다.

  • API 디렉토리를 도메인별(‎auth/, ‎performance/, ‎payment/, ‎reservation/)로 분리하고, 이에 따라 모든 import 경로를 새로운 구조에 맞게 수정했습니다.

  • ApiDataTypes.ts에 집중되어 있던 타입들을 ‎auth.ts, ‎performance.ts, ‎reservation.ts, ‎payment.ts로 분리하고, ‎ApiDataTypes.ts는 기존 이름을 유지하면서 re-export 허브로 동작하도록 변경해 하위 호환성을 유지했습니다.

  • 로그인/마이페이지/메인/공연/결제 관련 페이지 컴포넌트에서 GlobalLayout/RouteGuard/Query Key Factory 도입에 맞춰 레이아웃 및 데이터 패칭 로직을 정리했습니다.

🔗 관련 이슈 (Related Issues)

☑️ 체크리스트 (Checklist)

  • 코드가 프로젝트 코딩 컨벤션을 따릅니다.
  • 테스트 코드가 작성되었고, 통과했습니다.
  • 변경 사항에 대한 문서화가 완료되었습니다.
  • 필요한 경우, 다른 팀원에게 리뷰를 요청했습니다.
  • CI/CD 파이프라인이 성공했습니다.

👀 리뷰어를 위한 참고 사항 (Notes for Reviewers)

➕ 추가 정보 (Additional Information)

…ctory, 타입 분리 아키텍처 리팩토링

- GlobalLayout 도입
  - Header/Footer 전역 관리, Layout Route 패턴 적용
  - 모든 페이지에서 Header/Footer 중복 import 및 렌더링 코드 제거
- RouteGuard 통합 컴포넌트 구현
  - type="private" | "public" prop으로 인증/비인증 접근 제어
  - 페이지 내부 수동 localStorage 토큰 체크 코드 제거
  - 로그인 후 원래 페이지 복귀 지원 (state.from → sessionStorage)
- Query Key Factory 패턴 도입
  - queryKeys.ts에서 모든 queryKey 중앙 관리
  - 계층적 구조(all → lists → list(param))로 부분 캐시 무효화 지원
  - WaitingRoom ↔ SeatSelectPage 간 캐시 키 불일치 버그 수정
- API 디렉토리 도메인별 분리
  - auth/, performance/, payment/, reservation/ 서브디렉토리로 재편
  - 내부/외부 import 경로 전체 업데이트
- ApiDataTypes.ts 타입 분리
  - 도메인별 타입 파일 생성 (auth.ts, performance.ts, reservation.ts, payment.ts)
  - PascalCase 네이밍 컨벤션 통일
  - re-export 허브를 통한 하위호환성 유지

Resolves: #121
See also: None
@kaeuhy
kaeuhy requested a review from Geunone2 April 1, 2026 05:15
@kaeuhy kaeuhy self-assigned this Apr 1, 2026
@kaeuhy kaeuhy added status: review 코드 리뷰 중 type: refactor 리팩토링 labels Apr 1, 2026
@kaeuhy kaeuhy changed the title #121 refactor(architecture): Global Layout, Route Guard, Query Key Fa… #121 refactor(architecture): Global Layout, Route Guard, Query Key Factory, 타입 분리 아키텍처 리팩토링 Apr 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the application's routing and layout structure by introducing a GlobalLayout component and a centralized RouteGuard for authentication. It also modularizes API types into domain-specific files and implements a centralized queryKeys factory for TanStack Query. Redundant Header and Footer components were removed from individual pages. Feedback was provided regarding the redundant use of the <main> tag in FailPage.tsx and SuccessPage.tsx, which conflicts with the <main> tag already present in the new GlobalLayout.

Comment thread src/pages/payment/FailPage.tsx Outdated
Comment thread src/pages/payment/SuccessPage.tsx

@Geunone2 Geunone2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

무분별하게 존재했던 QueryKey를 효율적으로 관리하도록 리팩토링 한 노력이 보이네요.
또한 다른 개발자가 알기 어려웠던 폴더 구조 역시, 이번 리팩토링을 통해 좀 더 세분화되어 알기 쉽게 구조가 잡힌 것 같습니다. 고생 많으셨습니다!

Comment thread src/pages/about/AboutPage.tsx Outdated
…ctory, 타입 분리 아키텍처 리팩토링 코드 리뷰 반영

- AboutPage: 가독성을 위해 하드코딩된 배경 이미지 URL 문자열을 IMAGE_URL 상수로 분리하고 인라인 스타일로 적용
- SuccessPage, FailPage: GlobalLayout 컴포넌트와의 중복을 방지하고 웹 표준을 준수하기 위해 <main> 태그를 <div> 태그로 변경
- SendSeatsButton.test: 패키지 구조 변경에 맞춰 jest.mock()의 API 참조 경로를 '../../../api/reservation/reservation.ts'로 올바르게 수정하여 CI 테스트 실패 해결

Resolves: #121
See also: None
@kaeuhy kaeuhy added status: done 완료됨 and removed status: review 코드 리뷰 중 labels Apr 1, 2026
@kaeuhy
kaeuhy merged commit f0d49dc into develop Apr 1, 2026
4 checks passed
@kaeuhy
kaeuhy deleted the #121-refactor-route-fetch branch April 1, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: done 완료됨 type: refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants