Skip to content

Conversation

@dydals3440
Copy link
Contributor

개요

모바일 앱의 인증 시스템을 전면 개선했습니다. 기존의 수동 라우트 보호 방식을 Expo Router의 Stack.Protected로 전환하고, Context API 기반의 인증 상태 관리를 추가했으며, TokenStore에 메모리 캐싱을 도입하여 성능을 개선했습니다.

변경 유형

  • 새 기능 (feat)

영향 범위

  • Mobile (apps/mobile)

변경 내용

1. Stack.Protected 도입

  • 기존: useEffect + router.replace로 수동 인증 확인
  • 개선: Expo Router SDK 53+의 Stack.Protected 사용
  • 장점: 선언적 라우트 보호, 딥링크 보안 강화, 자동 히스토리 관리

2. Context API 기반 인증 상태 관리

  • AuthStateProvider 신규 추가
  • 기존 DI 패턴(HttpClientProvider, AuthProvider)과 일관성 유지
  • Zustand 대신 Context API 선택 이유:
    • 인증 상태 변경 = 앱 전체 화면 전환 (선택적 구독 불필요)
    • 불필요한 의존성 추가 회피
    • 프로젝트 일관성 유지

3. TokenStore 메모리 캐싱

  • 메모리 캐시 추가로 SecureStore I/O 최소화
  • SecureStore는 영구 저장소로 계속 사용 (보안 유지)
  • 앱 프로세스 종료 시 자동 소멸

4. 코드 정리

  • 전체 코드베이스의 불필요한 JSDoc/주석 제거 (15+ 파일)
  • 훅 사용 예시와 중요 로직 설명은 유지
  • 코드 가독성 대폭 향상

5. 중복 로직 제거

  • app/index.tsx 삭제 (Stack.Protected가 자동 처리)
  • 인증 로직의 단일 책임 원칙 준수

테스트

  • 모든 테스트 통과 (pnpm test)
    • Test Suites: 14 passed
    • Tests: 116 passed
  • 타입 체크 통과 (pnpm typecheck)
  • Linter 통과 (pnpm lint)
  • 테스트 환경에 AuthStateProvider 추가

체크리스트

관련 이슈

Closes #50

추가 정보

  • 24 files changed, 376 insertions(+), 437 deletions(-)
  • 순 코드 감소: 61줄 (중복 제거 및 주석 정리)
  • 보안: OWASP/React Native 보안 가이드 준수
  • 참고 자료: Expo Router Protected Routes, Expo SecureStore

@dydals3440 dydals3440 added type: feat 🚀 신규 기능 - 사용자에게 새로운 비즈니스 가치를 제공하는 작업 scope: mobile 📱 모바일 - Expo 기반 모바일 앱 UI/UX 및 클라이언트 로직 관련 status: needs review 🔍 리뷰 대기 - 작업 완료 후 병목 제거를 위해 팀원의 빠른 피드백이 필요한 상태 labels Jan 20, 2026
@dydals3440 dydals3440 self-assigned this Jan 20, 2026
@dydals3440 dydals3440 requested review from Copilot and hijjoy January 20, 2026 12:49
@gemini-code-assist
Copy link

Summary of Changes

Hello @dydals3440, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

모바일 앱의 인증 시스템을 전면적으로 개선하는 Pull Request입니다. 기존의 수동적인 라우트 보호 방식을 Expo Router의 Stack.Protected로 전환하여 보안과 관리 효율성을 높였습니다. 또한, Context API를 활용한 새로운 인증 상태 관리 시스템을 도입하고, TokenStore에 메모리 캐싱을 적용하여 성능을 최적화했습니다. 이와 함께 코드 가독성을 높이고 중복 로직을 제거하는 등 전반적인 코드 품질 향상도 이루어졌습니다.

Highlights

  • Stack.Protected 도입: 기존 수동 인증 확인 방식을 Expo Router의 Stack.Protected로 전환하여 선언적 라우트 보호, 딥링크 보안 강화, 자동 히스토리 관리를 구현했습니다.
  • Context API 기반 인증 상태 관리: AuthStateProvider를 새로 추가하여 인증 상태를 관리하며, 기존 DI 패턴과의 일관성을 유지하고 불필요한 의존성 추가를 피했습니다.
  • TokenStore 메모리 캐싱: SecureStore I/O를 최소화하기 위해 메모리 캐시를 도입하여 성능을 개선했습니다. 앱 프로세스 종료 시 캐시는 자동 소멸됩니다.
  • 코드 정리 및 중복 로직 제거: 전체 코드베이스에서 불필요한 JSDoc/주석을 제거하고, app/index.tsx를 삭제하여 인증 로직의 단일 책임 원칙을 준수했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

- Context API 기반 AuthStateProvider 추가 (기존 DI 패턴 유지)
- TokenStore 메모리 캐싱으로 성능 개선
- Stack.Protected로 선언적 라우트 보호 (Expo Router SDK 53+)
- 중복 로직 제거 (app/index.tsx 삭제)
- 인증 훅에 AuthState 통합 (use-exchange-code, use-logout)
- 전체 코드베이스 주석 정리 (15+ 파일)
- 테스트 환경에 AuthStateProvider 추가

관련 이슈: #50
@dydals3440 dydals3440 force-pushed the feature/auth-system-improvements branch from 97f860e to 41dd74d Compare January 20, 2026 12:51
Copy link

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

Choose a reason for hiding this comment

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

Code Review

PR은 모바일 앱의 인증 시스템을 Expo Router의 Stack.Protected와 Context API 기반 상태 관리로 전환하고, TokenStore에 메모리 캐싱을 도입하여 전반적인 아키텍처를 개선했습니다. 기존의 수동적인 인증 라우트 보호 로직을 제거하고 선언적인 방식으로 변경하여 코드의 가독성과 유지보수성을 크게 향상시켰습니다. 또한, 불필요한 JSDoc 및 주석을 제거하고 app/index.tsx 파일을 삭제하여 코드베이스를 깔끔하게 정리한 점도 좋습니다. 전반적으로 잘 계획되고 실행된 변경사항입니다.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves the mobile app's authentication system by replacing manual route protection with Expo Router's declarative Stack.Protected, introducing Context API-based auth state management, and adding memory caching to TokenStore for performance optimization.

Changes:

  • Replaced manual useEffect-based route protection with Expo Router's Stack.Protected for declarative, secure route guarding
  • Added AuthStateProvider for centralized authentication state management using Context API
  • Implemented memory caching in TokenStore to reduce SecureStore I/O operations while maintaining security
  • Removed extensive JSDoc comments across 15+ files to improve code readability
  • Deleted redundant app/index.tsx as Stack.Protected now handles route protection automatically

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Updated TypeScript catalog version from ^5.9.0 to ^5.9.3
pnpm-lock.yaml Updated dependency lock file with new package versions
package.json Updated devDependencies: @biomejs/biome and turbo to latest versions
apps/mobile/package.json Added ts-pattern dependency and updated @tanstack/react-query
apps/api/package.json Updated NestJS packages, pino, and resend to latest versions
apps/mobile/uniwind-types.d.ts Reformatted type definitions (removed semicolons)
apps/mobile/src/shared/storage/token-store.ts Added memory caching layer with initialize() method for performance optimization
apps/mobile/src/core/providers/auth-state-provider.tsx New provider for managing global authentication state with TokenStore integration
apps/mobile/src/features/auth/presentation/hooks/use-logout.ts Integrated clearAuth() call from AuthStateProvider
apps/mobile/src/features/auth/presentation/hooks/use-exchange-code.ts Integrated setAuthenticated() call from AuthStateProvider
apps/mobile/src/features/auth/presentation/hooks/use-get-me.ts Removed JSDoc comments
apps/mobile/src/features/auth/presentation/hooks/use-open-kakao-login.ts Removed JSDoc comments
apps/mobile/src/features/auth/presentation/providers/auth.provider.tsx Removed JSDoc comments
apps/mobile/src/features/auth/presentation/constants/auth-query-keys.constant.ts Removed JSDoc comments
apps/mobile/src/features/auth/domain/repositories/auth.repository.ts Removed JSDoc comments
apps/mobile/src/features/auth/domain/models/user.model.ts Removed JSDoc comments and property descriptions
apps/mobile/src/features/auth/data/repositories/auth.repository.impl.ts Removed JSDoc comments
apps/mobile/src/features/auth/application/services/auth.service.ts Removed JSDoc comments, simplified error comment
apps/mobile/src/core/providers/query-provider.tsx Removed inline comment explaining 401 retry logic
apps/mobile/src/core/di/container.ts Removed JSDoc comments
apps/mobile/src/core/di/app-providers.tsx Removed JSDoc comments, added AuthStateProvider to provider hierarchy
apps/mobile/src/shared/testing/test-render.tsx Added AuthStateProvider to test setup, removed comments
apps/mobile/app/_layout.tsx Replaced manual route protection logic with Stack.Protected implementation
apps/mobile/app/index.tsx Deleted file - Stack.Protected handles initial routing
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dydals3440
Copy link
Contributor Author

dydals3440 commented Jan 20, 2026

@hijjoy console 관련 된 부분은 앱 출시 이전에 한번 shared/logger.ts를 만들어서 개발환경일떄는 console.error/info/log로, 배표환경일때는 Sentry를 부분적으로 크리티컬 한 곳만 적용하는 것으로 해보겠습니다!

@dydals3440
Copy link
Contributor Author

@hijjoy 이 방식은 Expo 공식 레이아웃 시스템을 활용하여 ProtectedRoute를 구현하는 권장 방법(참고 영상)을 참고하여 적용해 보았습니다.

주요 구현 포인트와 구조를 정리하면 다음과 같습니다.

🏗️ 구현 핵심 요약

  • Root Layout 활용: Slot 또는 Stack을 감싸는 상위 레이아웃에서 인증 상태를 전역적으로 체크합니다.
  • 인증 상태 분기: useAuth와 같은 Hook을 통해 세션 유무를 판단하고, 인증되지 않은 사용자가 보호된 경로에 접근할 경우 router.replace('/login')를 통해 리다이렉트합니다.
  • 초기 로딩 처리: 인증 정보를 불러오는 동안 SplashScreen을 유지하거나 로딩 인디케이터를 노출하여 깜빡임 현상(Flash of unauthenticated content)을 방지합니다.

해당 영상에서 제시하는 Expo Router의 파일 기반 라우팅 특성을 살려 깔끔하게 구조화해 보았으니 혹시나 더 좋은 방법이 있으면 커멘트 남겨주시면 반영해볼게요~!

@dydals3440 dydals3440 merged commit 2ef1cf8 into main Jan 20, 2026
3 checks passed
@dydals3440 dydals3440 deleted the feature/auth-system-improvements branch January 20, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: mobile 📱 모바일 - Expo 기반 모바일 앱 UI/UX 및 클라이언트 로직 관련 status: needs review 🔍 리뷰 대기 - 작업 완료 후 병목 제거를 위해 팀원의 빠른 피드백이 필요한 상태 type: feat 🚀 신규 기능 - 사용자에게 새로운 비즈니스 가치를 제공하는 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mobile): 인증 시스템 개선 - Stack.Protected & 메모리 캐싱

2 participants