# deanpatel2/webscraper-premdata architecture

> Architecture diagram of the GitHub repository deanpatel2/webscraper-premdata, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deanpatel2/webscraper-premdata
- Repository: https://github.com/deanpatel2/webscraper-premdata

## Overview

1. **Repository shape**
   - This is a very small, single-purpose scraping project.
   - The entire implementation appears to live in one Python script, `FotMob_PremScraper.py`, with one sample output file, `PL_matchweek_1.csv`, plus the README.

2. **Primary purpose**
   - The script extracts Premier League match statistics from FotMob’s “by round” match list.
   - It is a data acquisition pipeline, not a full application: input is a FotMob webpage, output is a CSV of match/team statistics.

3. **Core runtime**
   - The scraper is driven by **Selenium**, so the browser is part of the architecture.
   - A local **ChromeDriver** executable is required, and the script depends on a matching Chrome browser setup on the machine running it.

4. **Main data flow**
   - The script starts at FotMob’s Premier League rounds page.
   - It navigates matchweek by matchweek, opens each match, collects statistics from the match pages, and aggregates them into tabular records.
   - Those records are then written out to a CSV file.

5. **Input boundary**
   - The external dependency boundary is FotMob’s public web UI and its page structure.
   - The scraper depends on the current layout/HTML behavior of FotMob pages, so the architecture is tightly coupled to that external site.

6. **Output boundary**
   - The only persisted artifact described is a CSV file.
   - The example CSV suggests a row-per-team or row-per-match-statistics representation containing metrics like xG, xGOT, possession, interceptions, duels, and opposition-half passes.

7. **Configuration model**
   - The script is configured through global variables, specifically `DRIVER_PATH` and `MATCHWEEK`.
   - That means the operational parameters are embedded in the script rather than managed through a config file, CLI, or environment-based settings.

8. **Processing style**
   - This is a sequential scraper: discover matchweek matches, visit each match, extract stats, append results.
   - There is no sign of distributed processing, queueing, database storage, or asynchronous pipeline stages.

9. **Technology boundaries**
   - **Python** is the implementation language.
   - **Selenium** handles browser automation and page interaction.
   - **pandas** is used for tabular assembly and CSV generation.

10. **What is not present**
   - There are no visible service layers, APIs, web servers, or UI components.
   - There is also no evidence of modular packaging, tests, CI/CD, or a database-backed architecture.

11. **Domain scope**
   - The current scope is limited to **Premier League matchweek stats**.
   - The README notes future expansion toward shot maps and additional leagues, but those are not yet part of the implemented architecture.

12. **How to diagram it**
   - The clean architecture view is: **user runs script → Selenium-controlled Chrome navigates FotMob → scraper extracts match stats → pandas structures data → CSV file saved locally**.
   - The two important external boundaries are FotMob on one side and the local ChromeDriver/Chrome environment on the other.

Main entry points: [`FotMob_PremScraper.py`](https://github.com/deanpatel2/webscraper-premdata/blob/main/FotMob_PremScraper.py) (Scraper), [`PL_matchweek_1.csv`](https://github.com/deanpatel2/webscraper-premdata/blob/main/PL_matchweek_1.csv) (CSV export), [`README.md`](https://github.com/deanpatel2/webscraper-premdata/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Repository"]
  node_readme["README<br/>docs<br/>[README.md]"]
end

subgraph group_runtime["Local runtime"]
  node_scraper_script["Scraper<br/>python script"]
  node_config{{"Globals<br/>runtime config"}}
  node_driver[("ChromeDriver<br/>browser driver")]
  node_browser(("Chrome<br/>browser"))
  node_discover["Discover matches<br/>stage"]
  node_extract["Extract stats<br/>stage"]
  node_assemble[("Tabular data<br/>pandas table")]
end

subgraph group_external["External site"]
  node_rounds_page["Rounds page<br/>fotmob entrypoint"]
  node_match_pages["Match pages<br/>fotmob pages"]
end

subgraph group_output["Output"]
  node_export_csv["CSV export<br/>writer<br/>[PL_matchweek_1.csv]"]
end

node_readme -->|"describes"| node_scraper_script
node_config -->|"configures"| node_scraper_script
node_scraper_script -->|"uses"| node_driver
node_driver -->|"starts"| node_browser
node_browser -->|"opens"| node_rounds_page
node_scraper_script -->|"runs"| node_discover
node_discover -->|"visits"| node_match_pages
node_match_pages -->|"exposes"| node_extract
node_extract -->|"loads"| node_assemble
node_assemble -->|"writes"| node_export_csv
node_scraper_script -->|"produces"| node_export_csv

click node_readme "https://github.com/deanpatel2/webscraper-premdata/blob/main/README.md"
click node_scraper_script "https://github.com/deanpatel2/webscraper-premdata/blob/main/FotMob_PremScraper.py"
click node_config "https://github.com/deanpatel2/webscraper-premdata/blob/main/FotMob_PremScraper.py"
click node_export_csv "https://github.com/deanpatel2/webscraper-premdata/blob/main/PL_matchweek_1.csv"

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_readme toneBlue
class node_scraper_script,node_config,node_driver,node_browser,node_discover,node_extract,node_assemble toneAmber
class node_rounds_page,node_match_pages toneMint
class node_export_csv toneRose
```

## Components

### Repository

Source and sample output in the repo

- [README](https://github.com/deanpatel2/webscraper-premdata/blob/main/README.md): docs · Project overview and usage notes · `README.md`

### Local runtime

Python script and browser automation environment

- [Scraper](https://github.com/deanpatel2/webscraper-premdata/blob/main/FotMob_PremScraper.py): python script · Single-script Premier League matchweek scraper · `FotMob_PremScraper.py`
- [Globals](https://github.com/deanpatel2/webscraper-premdata/blob/main/FotMob_PremScraper.py): runtime config · Embedded settings such as DRIVER_PATH and MATCHWEEK · `FotMob_PremScraper.py`
- **ChromeDriver**: browser driver · Local executable required by Selenium
- **Chrome**: browser · Selenium-controlled browser session
- **Discover matches**: stage · Step through matchweeks and collect match links
- **Extract stats**: stage · Read xG, possession, duels, passes and other match metrics
- **Tabular data**: pandas table · Build rows for match/team statistics

### External site

FotMob web UI and page structure

- **Rounds page**: fotmob entrypoint · Premier League by-round match listing
- **Match pages**: fotmob pages · Per-match pages exposing statistics

### Output

Persisted CSV artifact

- [CSV export](https://github.com/deanpatel2/webscraper-premdata/blob/main/PL_matchweek_1.csv): writer · Write the final dataset to a local CSV file · `PL_matchweek_1.csv`

## Connections

- README → Scraper: describes · Documentation points to the single implementation script
- Globals → Scraper: configures · Global variables control driver path and matchweek
- Scraper → ChromeDriver: uses · Script launches Selenium through the local driver
- ChromeDriver → Chrome: starts · Driver controls a Chrome browser session
- Chrome → Rounds page: opens · Browser begins at FotMob's Premier League rounds page
- Scraper → Discover matches: runs · Sequentially discovers matchweeks and match links
- Discover matches → Match pages: visits · Each discovered match is opened in FotMob
- Match pages → Extract stats: exposes · Match pages provide the statistics used by the scraper
- Extract stats → Tabular data: loads · Scraped values are organized into rows and columns
- Tabular data → CSV export: writes · Pandas material is saved as a CSV artifact
- Scraper → CSV export: produces · End result of the pipeline is a local CSV file
