Skip to content

Feature/ai predictions#9

Merged
umsungjun merged 7 commits into
mainfrom
feature/ai-predictions
Mar 25, 2026
Merged

Feature/ai predictions#9
umsungjun merged 7 commits into
mainfrom
feature/ai-predictions

Conversation

@umsungjun
Copy link
Copy Markdown
Owner

@umsungjun umsungjun commented Mar 25, 2026

Summary by CodeRabbit

  • 새로운 기능
    • Gemini AI 기반 다음 상대 예측 기능 추가
    • 상대 선수의 승률 및 경기 전술 분석 제공
    • 다음 상대 예측 페이지 및 상세 비교 분석 화면 추가
    • 메인 네비게이션에 예측 메뉴 추가

- Gemini AI SDK 의존성 추가 (@google/generative-ai)
- Gemini API 클라이언트 구현 (src/lib/gemini.ts)
- 예측 데이터 타입 정의 (src/types/prediction.ts)
- opponent_predictions 테이블 스키마 추가
- 환경 변수 문서화 (GEMINI_API_KEY)
- FightMatrix 랭킹 크롤러 (src/lib/crawl/fightmatrix-crawler.ts)
- UFC 선수 이미지 스크레이퍼 (src/lib/crawl/ufc-image-scraper.ts)
- Gemini 기반 예측 생성기 (src/lib/crawl/prediction-generator.ts)
- 수동 예측 생성 스크립트 (scripts/generate-predictions.ts)
- 초기 캐시 데이터 (cached-predictions.json)
- 예측 상세 페이지 (/[locale]/predictions)
- PredictionPreview 홈 미리보기 컴포넌트
- FighterComparison 선수 비교 컴포넌트
- PredictionDetail 상세 분석 카드
- WinProbabilityBar 승률 시각화
- 다국어 번역 추가 (ko.json, en.json)
- 선수 플레이스홀더 이미지 추가
- 메인 페이지에 PredictionPreview 섹션 추가
- 헤더 내비게이션에 AI 예측 메뉴 추가
- Cron에 예측 생성 작업 추가 (매일 자동 갱신)
- ISR 캐시 무효화 경로 추가 (/predictions)
- description에 '고석현 다음상대' 키워드 추가
- keywords에 '고석현 다음상대', 'AI 고석현 다음 상대 예측' 추가
- Open Graph, Twitter 카드 메타태그 추가
- README 주요 기능/기술 스택/프로젝트 구조 업데이트
- description에 '고석현 다음상대' 키워드 추가
- keywords에 '고석현 다음상대', 'AI 고석현 다음 상대 예측' 추가
- Open Graph, Twitter 카드 메타태그 추가
- README 주요 기능/기술 스택/프로젝트 구조 업데이트
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lets-ko Ready Ready Preview, Comment Mar 25, 2026 0:31am

@umsungjun umsungjun merged commit 85c4e35 into main Mar 25, 2026
1 of 3 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eead63f7-2aa9-435d-b777-2fd3fe2bee14

📥 Commits

Reviewing files that changed from the base of the PR and between b9eff1d and 903e5f3.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • public/images/fighter-placeholder.png is excluded by !**/*.png
📒 Files selected for processing (21)
  • .env.local.example
  • README.md
  • package.json
  • scripts/generate-predictions.ts
  • scripts/setup-db.ts
  • src/app/[locale]/page.tsx
  • src/app/[locale]/predictions/page.tsx
  • src/app/api/cron/crawl/route.ts
  • src/components/fighter/PredictionPreview.tsx
  • src/components/layout/Header.tsx
  • src/components/predictions/FighterComparison.tsx
  • src/components/predictions/PredictionDetail.tsx
  • src/components/predictions/WinProbabilityBar.tsx
  • src/data/cached-predictions.json
  • src/lib/crawl/fightmatrix-crawler.ts
  • src/lib/crawl/prediction-generator.ts
  • src/lib/crawl/ufc-image-scraper.ts
  • src/lib/gemini.ts
  • src/messages/en.json
  • src/messages/ko.json
  • src/types/prediction.ts

📝 Walkthrough

Walkthrough

Google Gemini API를 활용한 다음 상대 예측 기능이 추가됩니다. FightMatrix 순위권 선수들을 크롤링하고 AI 분석을 통해 최상의 대전 상대를 선정하며, 예측 결과를 데이터베이스와 캐시에 저장하고 새로운 예측 페이지와 홈페이지 위젯에서 표시합니다.

Changes

Cohort / File(s) Summary
환경 설정
.env.local.example, package.json
Gemini API 키 환경 변수 항목 추가 및 @google/generative-ai 의존성(^0.24.1) 설치
문서
README.md
AI 다음 상대 예측 기능, Gemini API 기술 스택, 새 라우트 및 컴포넌트 디렉토리, opponent_predictions Supabase 테이블 문서화 추가
데이터베이스
scripts/setup-db.ts
opponent_predictions 테이블(id, data JSONB, crawled_at) 및 시간순 인덱스 생성
예측 생성 인프라
scripts/generate-predictions.ts, src/lib/crawl/prediction-generator.ts, src/lib/crawl/fightmatrix-crawler.ts, src/lib/crawl/ufc-image-scraper.ts, src/lib/gemini.ts
FightMatrix 후보 크롤링, UFC 프로필 이미지 스크래핑, Gemini로 상대 선정 및 상세 분석(승률, 경기 분석), 예측 JSON 캐싱
예측 데이터
src/data/cached-predictions.json
생성된 예측 데이터 캐시(상대 목록, 승률, 분석 텍스트)
페이지 라우트
src/app/[locale]/page.tsx, src/app/[locale]/predictions/page.tsx
홈페이지에 예측 미리보기 추가, 새 상세 예측 페이지(/predictions) 및 ISR 캐싱 구성
UI 컴포넌트
src/components/fighter/PredictionPreview.tsx, src/components/predictions/PredictionDetail.tsx, src/components/predictions/FighterComparison.tsx, src/components/predictions/WinProbabilityBar.tsx
홈페이지 예측 미리보기, 예측 상세 페이지, 선수 비교 카드, 승률 바 컴포넌트; 스크롤 애니메이션, 국제화, 조건부 렌더링 포함
네비게이션
src/components/layout/Header.tsx
헤더 네비게이션에 /predictions 라우트 링크 추가
API 통합
src/app/api/cron/crawl/route.ts
크롤 크론 엔드포인트에 generatePredictions 호출 추가 및 예측 결과 DB 저장, /predictions 라우트 재검증
타입 정의
src/types/prediction.ts
예측 관련 인터페이스(OpponentPrediction, PredictionData, SelectedOpponent, OpponentAnalysis, FightMatrixCandidate) 정의
국제화
src/messages/en.json, src/messages/ko.json
예측 기능 UI 문자열(제목, 순위, 승률, 분석, 면책 조항) 및 네비게이션 라벨 추가

Sequence Diagram

sequenceDiagram
    participant Cron as Cron Job
    participant PredGen as Prediction<br/>Generator
    participant FM as FightMatrix<br/>Crawler
    participant Gemini as Gemini<br/>API
    participant UFC as UFC<br/>Image Scraper
    participant DB as Supabase<br/>DB
    participant Cache as Cached<br/>JSON

    Cron->>PredGen: generatePredictions()
    PredGen->>DB: fetch latest fighter_stats
    alt Stats available
        DB-->>PredGen: stats data
    else Stats unavailable
        PredGen->>Cache: load cached-stats.json
        Cache-->>PredGen: stats data
    end

    PredGen->>FM: crawlFightMatrixCandidates(rank)
    FM->>FM: fetch & parse FightMatrix pages
    FM-->>PredGen: candidate list

    PredGen->>Gemini: selectOpponents(stats, candidates)
    Gemini-->>PredGen: top 3 opponent selections

    loop For each selected opponent
        PredGen->>UFC: scrapeUfcFighterImage(name)
        UFC->>UFC: fetch UFC athlete page
        UFC-->>PredGen: image URL
        
        PredGen->>Gemini: analyzeOpponent(stats, opp)
        Gemini-->>PredGen: win probability + analysis
    end

    PredGen->>DB: insert into opponent_predictions
    PredGen->>Cache: write cached-predictions.json
    Cron->>DB: revalidate /predictions routes
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐰 새로운 상대를 찾아내는 마법,
지미니 AI와 함께 춤을 춘다네!
순위권에서 최고의 도전자를 고르고,
승률 계산에 전투 분석까지—
이제 다음 경기는 언제나 준비됐다네! 🥊✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/ai-predictions

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.

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