Skip to content

[Feature/#4] network module 세팅#16

Merged
wjdrjs00 merged 9 commits intodevelopfrom
feature/#4-network-module-setup
Jul 3, 2025
Merged

[Feature/#4] network module 세팅#16
wjdrjs00 merged 9 commits intodevelopfrom
feature/#4-network-module-setup

Conversation

@wjdrjs00
Copy link
Copy Markdown
Member

@wjdrjs00 wjdrjs00 commented Jul 2, 2025

[ PR Content ]

network 모듈 세팅 구현

Related issue

Screenshot 📸

  • N/A

Work Description

  • BaseResponse 구현
  • Interceptor 구현
  • Authenticator 구현

To Reviewers 📢

  • 네트워크 모듈 세팅을 하면서 고민이 많았는데,, 필수적이라 생각되는 것들 먼저 구현을 하고, 추후 구체화하며 추가 및 수정하는 방향이 좋을거 같단 생각에 지금과 같이 구현을 해봤습니다.
  • 궁금하신 부분이나 추가적으로 구현이 필요한 것들에 대해 리뷰 남겨주시면 야무지게 반영해보겠습니다!
  • ⚠️ local.properties에 추가된 속성이 있어 컨플루언스에 공유해두었습니다!

Summary by CodeRabbit

  • 신규 기능

    • 네트워크 통신을 위한 DI 모듈이 추가되어 인증/비인증 OkHttpClient, Retrofit, JSON 직렬화, 로깅 설정 등이 통합적으로 제공됩니다.
    • 인증 토큰을 자동으로 헤더에 추가하는 인터셉터와 401 응답 시 토큰을 갱신하여 재시도하는 인증 기능이 추가되었습니다.
    • 표준화된 네트워크 응답 데이터 클래스가 도입되었습니다.
  • 의존성 추가

    • Retrofit, OkHttp, Kotlinx Serialization 등 네트워크 및 직렬화 관련 라이브러리가 추가되었습니다.
  • 설정

    • 빌드 타입별 BASE_URL 환경설정이 추가되고, 디버그/릴리즈 빌드 옵션이 개선되었습니다.
    • GitHub Actions 워크플로우에 빌드 시 필요한 환경변수 설정이 추가되었습니다.

wjdrjs00 added 5 commits July 3, 2025 06:04
- debug, release 빌드 타입에 따라 다른 BASE_URL을 사용하도록 설정
- Retrofit, OkHttp 의존성 추가
@wjdrjs00 wjdrjs00 requested a review from l5x5l July 2, 2025 21:23
@wjdrjs00 wjdrjs00 self-assigned this Jul 2, 2025
@wjdrjs00 wjdrjs00 added ✨ Feature 새로운 기능 구현 🧤 대현 labels Jul 2, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 2, 2025

"""

Walkthrough

네트워크 모듈 구성을 위한 주요 파일 및 설정이 추가되었습니다. BaseResponse 데이터 클래스, 인증용 Interceptor 및 Authenticator가 구현되었고, Dagger Hilt 기반 DI 모듈 및 Qualifier가 도입되었습니다. Gradle 스크립트에는 네트워크 및 직렬화 관련 라이브러리 의존성이 추가되었습니다.

Changes

파일/경로 요약 변경 요약
app/build.gradle.kts, core/network/build.gradle.kts 네트워크 및 직렬화 관련 의존성 추가, 빌드 타입별 BASE_URL 설정, ProGuard 설정 추가
app/src/main/java/com/threegap/bitnagil/di/NetworkModule.kt, app/src/main/java/com/threegap/bitnagil/di/Qualifier.kt Dagger Hilt 네트워크 DI 모듈 및 인증/비인증 구분 Qualifier 추가
core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt, core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt 인증 토큰 Interceptor 및 401 응답시 토큰 갱신 Authenticator 구현
core/network/src/main/java/com/threegap/bitnagil/network/model/BaseResponse.kt 제네릭 BaseResponse 데이터 클래스(@serializable) 추가

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant NetworkModule
    participant OkHttpClient
    participant AuthInterceptor
    participant TokenAuthenticator
    participant DataStore

    App->>NetworkModule: Retrofit/OkHttpClient 의존성 주입 요청
    NetworkModule->>OkHttpClient: 인증/비인증 클라이언트 생성
    OkHttpClient->>AuthInterceptor: 요청시 토큰 헤더 추가
    AuthInterceptor->>DataStore: 액세스 토큰 조회
    OkHttpClient-->>App: 네트워크 요청 실행
    OkHttpClient->>TokenAuthenticator: 401 응답시 토큰 갱신 시도
    TokenAuthenticator->>DataStore: 리프레시 토큰 조회
    TokenAuthenticator-->>OkHttpClient: 토큰 재시도 또는 실패 반환
Loading

Assessment against linked issues

Objective Addressed Explanation
BaseResponse 정의 (#4)
Interceptor, Authenticator 구현 (#4)

Suggested labels

⚙ Init

Suggested reviewers

  • l5x5l

Poem

🐇
토큰을 품고 달리는 토끼,
네트워크 길 따라 빠르게 뛰지!
인증도 갱신도 문제없어,
BaseResponse로 응답을 받아,
새벽까지 코드를 지키는 토끼,
오늘도 빌드 성공에 귀가 쫑긋!
🥕
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e1141c and 35fd177.

📒 Files selected for processing (1)
  • .github/workflows/develop_branch.yml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/develop_branch.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
app/build.gradle.kts (1)

45-45: 릴리스 빌드에서 코드 난독화를 활성화하는 것을 고려해보세요.

보안과 앱 크기 최적화를 위해 릴리스 빌드에서 isMinifyEnabled = true로 설정하는 것을 권장합니다.

-            isMinifyEnabled = false
+            isMinifyEnabled = true
app/src/main/java/com/threegap/bitnagil/di/NetworkModule.kt (1)

54-57: Auth 인터셉터 제공 로직이 불필요합니다

AuthInterceptor를 그대로 반환하는 provider 메서드가 불필요합니다.

- @Provides
- @Singleton
- @Auth
- fun provideAuthInterceptor(authInterceptor: AuthInterceptor): Interceptor = authInterceptor

대신 provideAuthOkHttpClient에서 직접 사용하세요:

fun provideAuthOkHttpClient(
    httpLoggingInterceptor: HttpLoggingInterceptor,
-   authInterceptor: Interceptor,
+   authInterceptor: AuthInterceptor,
): OkHttpClient = OkHttpClient.Builder()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64a06e2 and ef1ff6e.

📒 Files selected for processing (7)
  • app/build.gradle.kts (2 hunks)
  • app/src/main/java/com/threegap/bitnagil/di/NetworkModule.kt (1 hunks)
  • app/src/main/java/com/threegap/bitnagil/di/Qualifier.kt (1 hunks)
  • core/network/build.gradle.kts (1 hunks)
  • core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt (1 hunks)
  • core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt (1 hunks)
  • core/network/src/main/java/com/threegap/bitnagil/network/model/BaseResponse.kt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (15)
core/network/build.gradle.kts (1)

12-18: 의존성 구성이 적절하게 설정되었습니다.

BOM을 사용한 버전 관리와 필요한 네트워크 라이브러리들이 올바르게 추가되었습니다.

app/src/main/java/com/threegap/bitnagil/di/Qualifier.kt (1)

5-11: Dagger Qualifier 정의가 올바르게 구현되었습니다.

인증된 클라이언트와 비인증 클라이언트를 구분하기 위한 qualifier들이 적절하게 정의되었습니다.

core/network/src/main/java/com/threegap/bitnagil/network/model/BaseResponse.kt (1)

6-14: BaseResponse 클래스가 잘 설계되었습니다.

표준화된 API 응답 래퍼로서 제네릭 타입 파라미터와 적절한 직렬화 어노테이션을 사용하여 유연하고 명확한 구조를 제공합니다.

core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt (3)

16-18: 토큰 검증 로직이 적절합니다.

null 또는 빈 토큰에 대한 처리가 올바르게 구현되어 있습니다.


20-22: Authorization 헤더 추가 로직이 올바릅니다.

Bearer 토큰 형식으로 헤더를 추가하는 표준적인 구현입니다.


27-30: 상수 정의가 적절합니다.

헤더명과 토큰 prefix를 상수로 정의하여 유지보수성을 높였습니다.

core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt (4)

12-14: 의존성 주입 설정이 올바르게 구현되었습니다

TokenAuthenticator가 Dagger Hilt @Inject를 사용하여 올바르게 구성되었습니다.


16-18: 인증 실패 및 재시도 로직이 적절합니다

401 응답 코드 검사와 최대 재시도 횟수 제한이 올바르게 구현되어 무한 재시도를 방지합니다.


25-28: 요청 재구성 로직이 올바르게 구현되었습니다

Authorization 헤더를 새로운 토큰으로 업데이트하는 로직이 적절합니다.


30-38: 재시도 횟수 계산 로직이 효율적입니다

priorResponse 체인을 순회하여 재시도 횟수를 계산하는 방식이 올바르게 구현되었습니다.

app/src/main/java/com/threegap/bitnagil/di/NetworkModule.kt (5)

20-27: Base URL과 모듈 설정이 올바르게 구현되었습니다

Dagger Hilt 모듈 구성과 BuildConfig를 통한 Base URL 제공이 적절합니다.


29-36: JSON 직렬화 설정이 적절합니다

알 수 없는 키 무시, pretty print, explicit nulls 제외 설정이 API 통신에 적합합니다.


43-52: 로깅 인터셉터 설정이 적절합니다

디버그 빌드에서만 BODY 레벨 로깅을 활성화하는 설정이 보안과 성능을 고려한 좋은 구현입니다.


68-70: 타임아웃 설정이 적절합니다

연결 10초, 쓰기 30초, 읽기 30초 타임아웃 설정이 모바일 환경에 적합합니다.


1-2: @Auth·@noneAuth import 불필요

@Auth@NoneAuth 어노테이션은 com.threegap.bitnagil.di 패키지 내 Qualifier.kt에 정의되어 있어, 같은 패키지에 속한 NetworkModule.kt에서 별도의 import 없이 바로 사용할 수 있습니다.
따라서 해당 리뷰 코멘트는 잘못된 지적입니다.

Likely an incorrect or invalid review comment.

Copy link
Copy Markdown
Contributor

@l5x5l l5x5l left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! pr 진행하시죠!

@wjdrjs00 wjdrjs00 merged commit 567ddf8 into develop Jul 3, 2025
2 checks passed
@wjdrjs00 wjdrjs00 deleted the feature/#4-network-module-setup branch July 6, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능 구현 🧤 대현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Network Module 세팅 구현

2 participants