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.
anthropic.claude-sonnet-4-20250514-v1:0)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
# Backend
cd backend
pip install -r requirements.txt
# Frontend
cd frontend
npm install
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
| 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 |
GET /api/health - Health check with cache & rate limiter statsGET /api/profile/{game_name}/{tag_line} - Fast profile fetch (~5s)POST /api/analysis/{game_name}/{tag_line} - Deep AI analysis (3-6 min)# 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}'
# 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.
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
backend/cache/.env file exists with valid API keyspip install -r requirements.txtpython --version (need 3.8+)npm install in frontend directory.env.local has correct API URLnode --version (need 18+)/api/health endpoint for cache statsbackend/cache/This project is production-quality with:
Perfect for Riot Games API Challenge 2025!
/api/health with cache statisticsMIT License - See LICENSE file for details
Built with β€οΈ for Riot Games API Challenge 2025
Frontend: Next.js 16 + React 19 + TypeScript + Tailwind CSS + Framer Motion- Frontend: Next.js with TypeScript and Tailwind CSS
Backend: FastAPI (Python 3.12)- Backend: FastAPI with Python
AI: AWS Bedrock - Claude Sonnet 4 (anthropic.claude-sonnet-4-20250514-v1:0)- AI Agent: AWS Bedrock (Claude 3 Haiku) with LangChain
Data Source: Riot Games API (Match-V5, Summoner-V4, League-V4)- Data Source: Riot Games API
Region: North America only (for hackathon scope)- Caching: In-memory retry-safe caching system
Node.js (v18+)- Node.js (v18+)
Python 3.12+- Python (v3.8+)
Riot Games API Key (Personal Key sufficient)- Riot Games API Key
AWS Account with Bedrock access to Claude Sonnet 4- AWS Account with Bedrock access
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
β β βββ 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
```bash### Debug Commands
cd tests```bash
python test_profile.py# Check rate limiter stats
curl http://localhost:8000/api/health
python test_structured_analysis.py# Test with specific player
curl -X POST βhttp://localhost:8000/api/year-rewind/YourName/TAGβ
python test_rate_limits.py
```## License
| 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 |
β Implemented
π§ Future Enhancements
Priority areas for improvement:
.env file exists in backend/ directory/api/health for rate limiter statsnum_matches parameterMIT License - See LICENSE file for details.
Built for Riot Games API Challenge 2025