Skip to content

예측 탭의 데이터 바인딩을 구현합니다. - #11

Merged
snughnu merged 14 commits into
devfrom
feat/AI-View-Data-Binding
Jul 14, 2026
Merged

예측 탭의 데이터 바인딩을 구현합니다.#11
snughnu merged 14 commits into
devfrom
feat/AI-View-Data-Binding

Conversation

@snughnu

@snughnu snughnu commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Situation

AI 탭의 핵심 기능(예측 차트, 카테고리 차트, 인사이트, 모델 상태 카드)을 구현했으나,
데이터 흐름이 정리되지 않고 Domain 엔티티가 Presentation 레이어에 혼재해 있었음.
또한 뷰에 비즈니스 로직이 섞여 있어 계층 분리가 필요했음.

Task

  • AI 탭의 ViewModel → UseCase → Repository 데이터 흐름 완성
  • Domain 엔티티를 Presentation 레이어에서 분리
  • 뷰에 있던 로직을 ViewModel로 이동
  • 테스트 코드 추가

Action

설계 및 구조

  • AIRepositoryProtocol, AIUseCaseProtocol, AIUseCase 구현
  • MockAIRepository에 인사이트 데이터 등록
  • AIViewModelasync let을 활용한 병렬 데이터 로딩 구현

Domain 엔티티 정리

  • AIInsightItem, CategoryPredictionDataPoint를 Presentation → Domain 레이어로 이동
  • PredictionDataPointCumulativePrediction으로 rename (누적 데이터임을 명확히)
  • 중복으로 존재하던 AIModelItem 제거, AIModelMetadata로 통일

ViewModel 로직 이동

  • 누적 변환 로직을 AIPredictionCardViewAIViewModel.makeCumulativePrediction으로 이동
  • 카테고리 정렬/집계 로직을 AICategoryPredictionCardViewAIViewModel.makeCategoryData로 이동
  • hasPrediction, sortedInsights를 뷰 → ViewModel computed property로 이동
  • 오늘 이후 날짜의 실제 소비 데이터를 차트에서 제외

UI

  • AIStatusCardView에 모델 없을 때 nil state UI 대응 및 토스트 추가
  • 카테고리 카드뷰 전체보기 버튼 조건 수정 (5개 초과일 때만 노출)

테스트

  • AIUseCaseTests 추가 (SpyAIRepository 기반)
  • AIViewModelTests 추가 (StubAIUseCase, StubExpenseUseCaseForAI 기반)
    • 누적 계산 검증, 오늘 날짜 actual nil 방지, 카테고리 정렬, 인사이트 순서/중복 제거

Result

  • ViewModel → UseCase → Repository 흐름이 완성되어 Mock → 실제 데이터 교체 시 Repository만 변경하면 됨
  • Domain 엔티티가 Data/Domain 레이어에만 존재하도록 정리됨
  • 뷰는 렌더링만 담당하고 로직은 ViewModel에 집중됨
  • 핵심 비즈니스 로직에 대한 테스트 커버리지 확보

@snughnu snughnu self-assigned this Jul 14, 2026
@snughnu snughnu added the feat 기능을 구현/수정합니다. label Jul 14, 2026
@snughnu
snughnu merged commit 6d843d6 into dev Jul 14, 2026
1 check passed
@snughnu
snughnu deleted the feat/AI-View-Data-Binding branch July 14, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 기능을 구현/수정합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant