RiftRewindProject

Rift Rewind

AI-powered League of Legends year-end review generator for Riot Games API Challenge 2025. Creates personalized Spotify Wrapped-style dashboards with deep AI insights using Claude Sonnet 4.

✨ Features

Core Functionality

UI/UX

Technical Excellence

πŸ—οΈ Architecture

πŸš€ Prerequisites

⚑ Quick Start

1. Environment Setup

Backend - Create backend/.env:

RIOT_API_KEY=your_riot_api_key_here
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=us-east-1

Frontend - Create frontend/.env.local:

NEXT_PUBLIC_API_URL=http://localhost:8000

2. Installation

# Backend
cd backend
pip install -r requirements.txt

# Frontend
cd frontend
npm install

3. Run Application

Terminal 1 - Backend:

cd backend
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Terminal 2 - Frontend:

cd frontend
npm run dev

Access: Open http://localhost:3000

πŸ“Š Performance Metrics

Metric First Analysis Repeat Analysis Improvement
Time 3-6 minutes 30-60 seconds ⚑ 80-90% faster
API Calls ~200 ~10-20 πŸ’° 92% reduction
Cache Hit Rate 0% 95-100% 🎯 Perfect caching

🎨 UI Improvements (Latest)

πŸ”§ API Endpoints

Core Endpoints

Usage Example

# Check health & cache stats
curl http://localhost:8000/api/health

# Get profile
curl "http://localhost:8000/api/profile/Doublelift/NA1"

# Generate analysis
curl -X POST "http://localhost:8000/api/analysis/Doublelift/NA1" \
  -H "Content-Type: application/json" \
  -d '{"num_matches": 100}'

πŸ§ͺ Testing

# Quick health check
curl http://localhost:8000/api/health

# Run improvement tests
cd tests
python test_improvements.py

# Test caching performance
# 1. Analyze a player (first time = slow)
# 2. Analyze same player (second time = fast!)
# 3. Check logs for: "πŸ’Ύ Cache hits: 100/100 (100%)"

See HOW_TO_RUN.md for comprehensive testing guide.

πŸ“ Project Structure

backend/
  app/
    main.py           # API endpoints with type-safe responses
    schemas.py        # Pydantic models
  services/
    cache_manager.py  # JSON-based caching system (NEW)
    config.py         # Environment validation (NEW)
    agent_tools.py    # Match analysis tools
    structured_analysis_service.py  # AI coordinator
  cache/              # Auto-generated cache files
    matches.json
    profiles.json

frontend/
  app/                # Next.js app router
  features/
    dashboard/        # Main dashboard components
      Charts/         # Season trend visualization
      HeroRow/        # Champion spotlights with icons
  lib/
    api-client.ts     # Type-safe backend communication
    types.ts          # TypeScript definitions

🎯 Key Features Explained

JSON-Based Caching

AI Analysis

Champion Icons

Season Chart

πŸ› Troubleshooting

Backend won’t start

Frontend errors

Cache not working

Champion icons not loading

πŸ“š Documentation

πŸ† Hackathon Ready!

This project is production-quality with:

Perfect for Riot Games API Challenge 2025!

🎬 Demo Tips

  1. Show First Analysis: 3-6 minutes, explain AI is analyzing 100 matches
  2. Show Cache Working: Same player takes 30-60 seconds, highlight cache hits
  3. Interactive Features: Hover on champions, click chart annotations
  4. Performance Stats: Show /api/health with cache statistics

πŸ“ License

MIT License - See LICENSE file for details

πŸ™ Acknowledgments


Built with ❀️ for Riot Games API Challenge 2025

Prerequisites## Prerequisites

Quick Start## Setup

1. Environment Setup### 1. Environment Configuration

Backend - Create backend/.env:Create backend/.env:


RIOT_API_KEY=your_riot_api_key_hereRIOT_API_KEY=your_riot_api_key_here

AWS_ACCESS_KEY_ID=your_aws_access_keyAWS_ACCESS_KEY_ID=your_aws_access_key

AWS_SECRET_ACCESS_KEY=your_aws_secret_keyAWS_SECRET_ACCESS_KEY=your_aws_secret_key

AWS_REGION=us-east-1AWS_REGION=us-west-2

Frontend - Create frontend/.env.local:### 2. Installation


NEXT_PUBLIC_API_URL=http://localhost:8000# Install dependencies

```npm install

cd backend && pip install -r requirements.txt

### 2. Installation & Run```



**Option A: Using startup scripts (Windows)**### 3. Run Application

```bash

# Terminal 1 - Backend```bash

start_backend.bat# Backend (Terminal 1)

cd backend

# Terminal 2 - Frontend  python -m uvicorn app.main:app --reload --host 127.0.0.1 --port 8000

start_frontend.bat

```# Frontend (Terminal 2)

npm run dev

**Option B: Manual**```

```bash

# Install backend dependencies## API Endpoints

cd backend

pip install -r requirements.txt### Core Endpoints



# Install frontend dependencies- `GET /api/player/{game_name}/{tag_line}` - Get player PUUID

cd ../frontend- `POST /api/year-rewind/{game_name}/{tag_line}` - Generate AI review

npm install- `GET /api/health` - Health check with rate limiter stats



# Run backend (Terminal 1)### Usage Example

cd backend

python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000```bash

curl -X POST "http://localhost:8000/api/year-rewind/Faker/KR1"

# Run frontend (Terminal 2)```

cd frontend

npm run dev## Testing


### 3. Access Application# Run all tests

python tests/test_agent.py

- **Frontend**: http://localhost:3000

- **Backend API**: http://localhost:8000# Test rate limits

- **API Docs**: http://localhost:8000/docspython tests/test_rate_limits.py



### 4. Test It# Test caching behavior

python tests/test_throttling_behavior.py

Enter a Riot ID on the landing page:```

- Format: `GameName#TAG`

- Example: `i will int#akali` (NA region)## Performance



## API Endpoints| Metric              | Current     | Optimized           |

| ------------------- | ----------- | ------------------- |

### User-Facing Endpoints| Analysis Time       | 3-5 minutes | 1-2 minutes         |

| Retry Overhead      | 0% (cached) | Previously 200-300% |

- `GET /api/profile/{game_name}/{tag_line}` - Fast profile fetch (<5s)| Rate Limit Handling | Intelligent | Previously basic    |

  - Returns: Summoner icon, level, rank, main role

  ## Current Limitations & Improvements

- `POST /api/analysis/{game_name}/{tag_line}` - Deep AI analysis (3-6 min)

  - Returns: Top champions, stat highlights, AI insights, personality### Rate Limits

  - Query param: `num_matches` (default: 100)

- **Riot API**: 20 req/s, 100 req/2min (Personal key)

### System Endpoints- **Bedrock**: ~5-10 req/s (Default limits)



- `GET /api/health` - Health check with rate limiter stats**Improvements**:

- `GET /` - API version info

- Apply for Riot Production API key (500 req/s, 30k req/10min)

## Data Flow- Request Bedrock rate limit increase

- Switch to Claude 3.5 Sonnet for better quality

User Input (Riot ID)### Model Options

↓

Phase 1: Profile Service (fast)- Current: Claude 3 Haiku (fast, higher limits)

- Get PUUID from Riot ID- **Upgrade**: Claude 3.5 Sonnet (better quality, lower limits)

- Fetch summoner data (icon, level)- **Premium**: Claude 3 Opus (highest quality, lowest limits)

- Get ranked stats (tier, division, LP, winrate)

- Determine main role (last 10 matches)### Future Enhancements

↓

Phase 2: Analysis Service (deep)- OP.GG MCP Integration: Real-time meta insights and build recommendations

- Fetch 50-100 match history- **Champion Synergy Analysis**: Team composition suggestions

- Extract comprehensive stats (KDA, CS, vision, damage, gold)- **Trend Analysis**: Performance improvement tracking over time

- Analyze champion pool (games, winrates, playstyles)- **Multi-Region Support**: Support for all Riot regions

- Extract challenge data (lane dominance, vision advantage)

- Calculate timeline patterns (early vs late game)## Project Structure

- Generate AI insights with Claude Sonnet 4

↓```

Frontend DashboardRiftRewindProject/

- Display profile with rankβ”œβ”€β”€ app/                    # Next.js frontend

- Show top 3 champions (accurate stats)β”œβ”€β”€ backend/

- Highlight 3 best statsβ”‚   β”œβ”€β”€ app/main.py        # FastAPI application

- Show AI-generated deep insightβ”‚   β”œβ”€β”€ services/

- Display personality typeβ”‚   β”‚   β”œβ”€β”€ year_rewind_agent.py    # Main AI agent

```β”‚ β”‚ β”œβ”€β”€ agent_tools.py # Analysis tools

β”‚ β”‚ β”œβ”€β”€ riot_api.py # Riot API client

Project Structureβ”‚ β”‚ β”œβ”€β”€ rate_limiter.py # Riot API rate limiting

β”‚ β”‚ └── bedrock_rate_limiter.py # Bedrock rate limiting

```β”‚ └── .env # Environment variables

RiftRewindProject/β”œβ”€β”€ tests/ # Test suite

β”œβ”€β”€ frontend/ # Next.js application└── README.md

β”‚ β”œβ”€β”€ app/ # App router pages```

β”‚ β”œβ”€β”€ components/ # UI components

β”‚ β”œβ”€β”€ features/ # Feature modules## Contributing

β”‚ β”œβ”€β”€ lib/ # Utilities

β”‚ β”‚ β”œβ”€β”€ api-client.ts # Backend API integration1. Model Experimentation: Test different models for quality and speed

β”‚ β”‚ └── usePlayerDataFetch.ts2. OP.GG Integration: Add real-time meta analysis using OP.GG MCP

β”‚ └── .env.local # Frontend config3. Performance Optimization: Figure out a way to reduce analysis time.

β”‚4. UI/UX: Improve frontend design and user experience

β”œβ”€β”€ backend/ # FastAPI application5. Additional Features: Champion recommendations, team analysis, etc.

β”‚ β”œβ”€β”€ app/6. Tool and System Prompts: Work on finding errors and enhancing the prompts for the agent tools and the system prompt that initalises the workflow.

β”‚ β”‚ └── main.py # API endpoints

β”‚ β”œβ”€β”€ services/## Rate Limit Optimization

β”‚ β”‚ β”œβ”€β”€ profile_service.py # Fast profile fetching

β”‚ β”‚ β”œβ”€β”€ structured_analysis_service.py # AI analysisThe system includes intelligent rate limiting for both APIs:

β”‚ β”‚ β”œβ”€β”€ agent_tools.py # Data extraction tools

β”‚ β”‚ β”œβ”€β”€ riot_api.py # Riot API client- Riot API: Respects 20 req/s and 100 req/2min limits

β”‚ β”‚ β”œβ”€β”€ rate_limiter.py # Riot API rate limiting- Bedrock: Handles throttling with exponential backoff

β”‚ β”‚ └── bedrock_rate_limiter.py # Bedrock throttling- Caching: Prevents re-fetching on retries (major performance improvement)

β”‚ └── .env # Backend config

β”‚## Troubleshooting

β”œβ”€β”€ tests/ # Test scripts

β”œβ”€β”€ start_backend.bat # Backend startup script### Issues

└── start_frontend.bat # Frontend startup script

```- Bedrock Throttling: Switch to Claude 3 Haiku or request limit increase

Testing- Long Analysis Time: Expected 3-5 minutes for 50+ matches

```bash### Debug Commands

Test profile service

cd tests```bash

python test_profile.py# Check rate limiter stats

curl http://localhost:8000/api/health

Test structured analysis

python test_structured_analysis.py# Test with specific player

curl -X POST β€œhttp://localhost:8000/api/year-rewind/YourName/TAG”

Test rate limiting```

python test_rate_limits.py

```## License

Performance MetricsMIT License - see LICENSE file for details.

Metric Target Notes
Profile Load <5 seconds Initial data for header
Full Analysis 3-6 minutes 100 matches with AI
Match Fetching ~30s Riot API rate limited
AI Generation ~10-30s Claude Sonnet 4 inference

Current Scope (Hackathon)

βœ… Implemented

🚧 Future Enhancements

Known Limitations

  1. Analysis Time: 3-6 minutes for 100 matches (rate limit constrained)
  2. Region: NA only (easily expandable)
  3. AI Quality: Still being refined based on feedback
  4. Growth Charts: Mock data (needs historical tracking implementation)

Contributing

Priority areas for improvement:

  1. AI Prompt Engineering: Enhance insight quality and variety
  2. Performance: Optimize match fetching and caching
  3. Multi-Region: Add support for other regions
  4. Historical Data: Implement rank/performance timeline tracking
  5. UI Polish: Refine animations and responsive design

Troubleshooting

Backend Won’t Start

Frontend Shows β€œPlayer not found”

Analysis Takes Too Long

License

MIT License - See LICENSE file for details.


Built for Riot Games API Challenge 2025