Skip to content

Add FPL dashboard with player analytics and transfer insights#49

Open
328345 wants to merge 24 commits intoolbauday:mainfrom
328345:claude/fpl-transfer-dashboard-ltiQ5
Open

Add FPL dashboard with player analytics and transfer insights#49
328345 wants to merge 24 commits intoolbauday:mainfrom
328345:claude/fpl-transfer-dashboard-ltiQ5

Conversation

@328345
Copy link
Copy Markdown

@328345 328345 commented Mar 17, 2026

Summary

This PR introduces a comprehensive Fantasy Premier League (FPL) analytics dashboard built with Streamlit, featuring player rankings, transfer activity analysis, fixture difficulty ratings, and performance trend tracking.

Key Changes

Core Data Loading (dashboard/data_loader.py)

  • Implemented cached data loaders for players, teams, player stats, and gameweek summaries with 30-minute TTL
  • Created get_master_player_df() to join player stats with team and player metadata
  • Added get_upcoming_fixtures() to retrieve upcoming matches with Elo-based difficulty ratings
  • Implemented get_recent_form_data() to load per-gameweek performance history for trend analysis

Dashboard Views

  • Player Rankings (player_rankings.py): Sortable player table with multiple metrics (form, PPG, xG, xA, value, etc.) and search functionality
  • Fixture Difficulty (fixture_difficulty.py): Color-coded fixture grid using Elo ratings to visualize match difficulty across upcoming gameweeks
  • Value Picks (value_picks.py): Position-based value analysis with points-per-million metrics and price vs. points scatter plot
  • Form Trends (form_trends.py): Multi-player performance tracking with gameweek-by-gameweek points and expected stats visualization
  • Player Comparison (player_comparison.py): Side-by-side stats comparison with normalized radar charts for up to 3 players
  • Transfer Activity (transfer_activity.py): Transfer in/out rankings, price changes (gameweek and season), and gameweek highlights

Main Application (dashboard/app.py)

  • Streamlit app with sidebar navigation across 6 analytics pages
  • Global filters for position, team, price range, and minimum minutes played
  • Responsive layout with wide page configuration

Data Synchronization (sync_to_firestore.py)

  • Automated script to sync CSV data to Firestore
  • Discovers latest season folder and processes all gameweek directories
  • Batch uploads with 499-operation chunking to respect Firestore limits
  • Clears existing subcollections before syncing new data

CI/CD (github/workflows/sync.yml)

  • GitHub Actions workflow for automated Firestore synchronization
  • Triggers on push to main branch or manual dispatch
  • Uses Workload Identity Federation for secure GCP authentication

Notable Implementation Details

  • All data loaders use Streamlit's @st.cache_data decorator with 30-minute TTL for performance
  • Elo-based fixture difficulty uses color gradients (dark green for easy → dark red for hard)
  • Radar chart normalization uses min/max scaling across the full dataset (0-100 range)
  • Position names shortened to standard FPL abbreviations (GKP, DEF, MID, FWD)
  • Supports double gameweeks with multiple fixtures per team per gameweek
  • Firestore sync handles null values and uses auto-generated document IDs

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26

328345 and others added 24 commits August 1, 2025 12:27
Build a frontend dashboard with 6 views to help with FPL transfer decisions:
- Player Rankings: sortable/filterable table with key FPL metrics
- Fixture Difficulty: Elo-based color-coded grid of upcoming fixtures
- Value Picks: best points-per-million players by position with scatter plot
- Form Trends: per-gameweek line charts for points/xG/xA
- Player Comparison: side-by-side radar charts for 2-3 players
- Transfer Activity: most transferred in/out, price risers/fallers

Reads directly from existing CSV data files with cached loading.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Generates dashboard.html - a single self-contained file that works in any
browser without running a server. Run with: python3 generate_dashboard.py

Embeds all 822 player records, 158 fixture entries and 10 GWs of per-GW
stats directly into the HTML as JSON. Uses Chart.js via CDN for charts.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Reduces upload size from 100MB+ to ~2MB by excluding data/,
scripts/, and Python files not needed for the static dashboard.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
- Sidebar collapses into a slide-out menu on screens < 768px
- Added mobile header with hamburger toggle button
- Overlay backdrop when sidebar is open
- Responsive adjustments for controls, tables, cards, charts
- Smaller font sizes and tighter padding on small screens

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
…ard in CI

- Add mobile hamburger menu, responsive CSS, and sidebar toggle to
  generate_dashboard.py so regenerated dashboards include mobile support
- Update update_data.yml workflow to run generate_dashboard.py after
  data pull, so dashboard.html stays current with latest FPL data

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
The delete operation wasn't batched like the insert operation,
causing "Transaction too big" errors when subcollections had 500+ docs.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Merge pull request #1 from 328345/claude/fpl-transfer-dashboard-ltiQ5 -  Fix Firestore transaction too big error
The upstream repo uses Supabase for data import, but this fork
doesn't have credentials configured, causing scheduled failures.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Fetches latest data/ from olbauday/FPL-Elo-Insights at 6am and 5pm UTC,
regenerates the dashboard, and commits if there are changes.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Claude/fpl transfer dashboard lti q5  Fix Firestore batch deletes, disable Supabase import, add upstream sync
Previously the sync script processed every gameweek folder on each run,
causing ~50min runtime and excessive Firestore reads/writes. Now it only
syncs the highest-numbered gameweek. Also adds a 10-minute timeout to
the workflow as a safety net.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Merge pull request #3 from 328345/claude/fpl-transfer-dashboard-ltiQ5
All 38 GW folders exist with fixture data, so picking the highest number
synced GW38 (future). Now checks matches.csv for finished=True and syncs
the most recent gameweek that has actually been played.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
Checks the 'matches' subcollection for the latest finished GW before
uploading. If data already exists, exits early to avoid redundant writes
on daily CI runs.

https://claude.ai/code/session_01FiVSPeDMHuDNYTzLuFxC26
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.

2 participants