# karshin12/fpl-insights-hq architecture

> Architecture diagram of the GitHub repository karshin12/fpl-insights-hq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/karshin12/fpl-insights-hq
- Repository: https://github.com/karshin12/fpl-insights-hq

## Overview

FPL Insights HQ is a Flask-backed Fantasy Premier League squad builder and analytics app. Managers browse and filter player statistics, assemble and manage a 15-player squad, and request an optimized lineup with a bench and captain. The backend prepares player data from FPL Core Insights and runs the recommendation optimizer; the browser presents both results in the interactive pitch interface. The README documents further UI capabilities not fully visible in the sampled JavaScript. The available excerpts support the main API and data-loading links, but not every internal UI interaction.

Main entry points: [`templates/index.html`](https://github.com/karshin12/fpl-insights-hq/blob/main/templates/index.html) (Builder page), [`data_engine.py`](https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py) (Player data preparation), [`static/js/pitch.js`](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js) (Squad management), [`app.py`](https://github.com/karshin12/fpl-insights-hq/blob/main/app.py) (Flask routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_page["Builder page<br/>[index.html]"]
  node_browser["Squad interface<br/>[pitch.js]"]
  node_styling["Pitch styling<br/>[style.css]"]
  node_player_browse["Player browsing<br/>[pitch.js]"]
  node_squad_manage["Squad management<br/>[pitch.js]"]
  node_pitch_render["Pitch and stats<br/>[pitch.js]"]
  node_recommendation_view["Recommendation view<br/>[pitch.js]"]
end

subgraph group_backend["Application backend"]
  node_flask["Flask routes<br/>[app.py]"]
  node_player_api["Player data API<br/>[app.py]"]
  node_recommendation_api["Recommendation API<br/>[app.py]"]
end

subgraph group_analytics["Player data and analytics"]
  node_data_prep["Player data preparation<br/>[data_engine.py]"]
  node_optimizer["Squad optimizer<br/>[data_engine.py]"]
  node_fixture_lookup["Fixture lookup<br/>[data_engine.py]"]
end

subgraph group_external["External data"]
  node_fpl_data[("FPL Core Insights")]
end

node_manager(("FPL manager"))

node_manager -->|"opens"| node_page
node_page -->|"requests page"| node_flask
node_flask -->|"renders"| node_page
node_player_browse -->|"fetches players"| node_player_api
node_player_api -->|"calls"| node_data_prep
node_data_prep -->|"loads tables"| node_fpl_data
node_squad_manage -->|"updates display"| node_pitch_render
node_pitch_render -->|"renders"| node_browser
node_recommendation_view -->|"fetches recommendation"| node_recommendation_api
node_recommendation_api -->|"calls"| node_optimizer
node_optimizer -->|"gets player data"| node_data_prep
node_manager -->|"builds squad"| node_squad_manage
node_manager -->|"requests recommendations"| node_recommendation_view

click node_page "https://github.com/karshin12/fpl-insights-hq/blob/main/templates/index.html"
click node_browser "https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js"
click node_styling "https://github.com/karshin12/fpl-insights-hq/blob/main/static/css/style.css"
click node_player_browse "https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js"
click node_squad_manage "https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js"
click node_pitch_render "https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js"
click node_recommendation_view "https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js"
click node_flask "https://github.com/karshin12/fpl-insights-hq/blob/main/app.py"
click node_player_api "https://github.com/karshin12/fpl-insights-hq/blob/main/app.py"
click node_recommendation_api "https://github.com/karshin12/fpl-insights-hq/blob/main/app.py"
click node_data_prep "https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py"
click node_optimizer "https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py"
click node_fixture_lookup "https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_browser,node_styling,node_player_browse,node_squad_manage,node_pitch_render,node_recommendation_view toneBlue
class node_flask,node_player_api,node_recommendation_api toneAmber
class node_data_prep,node_optimizer,node_fixture_lookup toneMint
class node_fpl_data toneRose
class node_manager toneIndigo
```

## Components

### Web interface

- [Builder page](https://github.com/karshin12/fpl-insights-hq/blob/main/templates/index.html): `templates/index.html`
- [Squad interface](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js): `static/js/pitch.js`
- [Pitch styling](https://github.com/karshin12/fpl-insights-hq/blob/main/static/css/style.css): `static/css/style.css`
- [Player browsing](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js): `static/js/pitch.js`
- [Squad management](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js): `static/js/pitch.js`
- [Pitch and stats](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js): `static/js/pitch.js`
- [Recommendation view](https://github.com/karshin12/fpl-insights-hq/blob/main/static/js/pitch.js): `static/js/pitch.js`

### Application backend

- [Flask routes](https://github.com/karshin12/fpl-insights-hq/blob/main/app.py): `app.py`
- [Player data API](https://github.com/karshin12/fpl-insights-hq/blob/main/app.py): `app.py`
- [Recommendation API](https://github.com/karshin12/fpl-insights-hq/blob/main/app.py): `app.py`

### Player data and analytics

- [Player data preparation](https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py): `data_engine.py`
- [Squad optimizer](https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py): `data_engine.py`
- [Fixture lookup](https://github.com/karshin12/fpl-insights-hq/blob/main/data_engine.py): `data_engine.py`

### External data

- **FPL Core Insights**

### Other components

- **FPL manager**

## Connections

- FPL manager → Builder page: opens (evidence: `README.md`)
- Builder page → Flask routes: requests page (evidence: `app.py`)
- Flask routes → Builder page: renders (evidence: `app.py`)
- Player browsing → Player data API: fetches players (evidence: `static/js/pitch.js`)
- Player data API → Player data preparation: calls (evidence: `app.py`)
- Player data preparation → FPL Core Insights: loads tables (evidence: `data_engine.py`)
- Squad management → Pitch and stats: updates display (evidence: `static/js/pitch.js`)
- Pitch and stats → Squad interface: renders (evidence: `static/js/pitch.js`)
- Recommendation view → Recommendation API: fetches recommendation (evidence: `static/js/pitch.js`)
- Recommendation API → Squad optimizer: calls (evidence: `app.py`)
- Squad optimizer → Player data preparation: gets player data (evidence: `data_engine.py`)
- FPL manager → Squad management: builds squad (evidence: `README.md`)
- FPL manager → Recommendation view: requests recommendations (evidence: `README.md`)
