# joeyagreco/leeger architecture

> Architecture diagram of the GitHub repository joeyagreco/leeger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joeyagreco/leeger
- Repository: https://github.com/joeyagreco/leeger

## Overview

##### Project Type and Purpose
- This project is a Python library designed to load fantasy football league data from various sites (ESPN, Fleaflicker, MyFantasyLeague, Sleeper, Yahoo) and process that data to generate instant stats either in Python objects (like AllTimeStatSheet and YearStatSheet) or into Excel spreadsheets.
- The README and file structure reveal that it supports different league loaders, has modular calculators for stats (both “all time” and “year” based), and includes extensive validation and utility modules.

##### Main Components
a. External Data Sources & League Loader:
- Fantasy football site as an external data provider.
- How the League Loader components (found under leeger/league_loader – e.g., ESPNLeagueLoader, FleaflickerLeagueLoader, etc.) fetch raw league data.
- That these loaders are responsible for converting external data into a standardized League object.

b. Core Domain Model:
- Central to the design is the League object. This object (and related classes under leeger/model/league) encapsulates the league data (teams, owners, matchups, weeks, years, etc.).
- Submodules for filters (e.g., AllTimeFilters, WeekFilters, YearFilters) and abstractions (UniqueId, EqualityCheck) from leeger/model/abstract.

c. Calculators & Stats Processing:
- There are two primary calculator families:
- All-Time Calculators (under leeger/calculator/all_time_calculator) – which process season-over-season or career-long stats.
- Year Calculators (under leeger/calculator/year_calculator) – which focus on stats for a single season.
- Both use the League object as input and generate output objects (like AllTimeStatSheet and YearStatSheet located in leeger/model/stat) used for stats reporting.

d. Validation & Exception Handling:
- Modules in leeger/validate and leeger/exception ensure that league data is correctly formatted and valid.
- These components check for consistency and trigger exceptions (e.g., InvalidLeagueFormatException, LeagueLoaderException).

e. Utility and Configuration:
- Under leeger/util, include ConfigReader, CustomLogger, Excel helper utilities, and navigators (for League, Week, Matchup, Year) that support the overall flow.
- These utilities play a role in reading configurations (from leeger/properties/app.properties) and formatting output (including Excel integration as seen in the example stat directory).

f. External Interfaces:
- Excel integration is an important feature – the utilities for Excel processing and examples in the ‘example/stat’ directory show how league stats are written to spreadsheets.
- There is also integration with the command-line (Makefile, setup.py) and CI/CD pipelines (under .github/workflows) for automated testing, formatting checks, and deployment.

##### Relationships and Data Flow
- The script calls a League Loader module which reaches out to an external fantasy site.
- Once data is loaded, the League object (core domain model) is populated.
- The League object is then fed into the Calculator modules; these process the raw league data and create statistic sheets.
- Validation components intercept the data flow to ensure the League object complies with expected formats.
- Processed results may then feed into Excel utilities to output data into spreadsheets.
- Utility modules (navigators, logging, configuration) are used throughout the process.
- Exception handling components catch any errors during the process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Input"
        EndUser("End User Script"):::utility
    end

    subgraph "League Data Ingestion"
        subgraph "External Data Sources & League Loader"
            ESPN("ESPN League Loader"):::blue
            Fleaflicker("Fleaflicker League Loader"):::blue
            MFL("MyFantasyLeague League Loader"):::blue
            Sleeper("Sleeper League Loader"):::blue
            Yahoo("Yahoo League Loader"):::blue
        end
    end

    EndUser --> ESPN
    EndUser --> Fleaflicker
    EndUser --> MFL
    EndUser --> Sleeper
    EndUser --> Yahoo

    subgraph "Core Domain Model"
        LeagueObj("League Object & Model"):::green
        Abstraction("Abstracts (UniqueId,Equality)"):::green
    end

    ESPN --> LeagueObj
    Fleaflicker --> LeagueObj
    MFL --> LeagueObj
    Sleeper --> LeagueObj
    Yahoo --> LeagueObj
    LeagueObj --> Abstraction

    subgraph "Calculators & Stats Processing"
        AllTimeCalc("All-Time Calculators"):::orange
        YearCalc("Year Calculators"):::orange
    end

    LeagueObj --> AllTimeCalc
    LeagueObj --> YearCalc

    subgraph "Stat Sheets"
        AllTimeSheet("AllTimeStatSheet"):::orange
        YearSheet("YearStatSheet"):::orange
    end

    AllTimeCalc --> AllTimeSheet
    YearCalc --> YearSheet

    subgraph "Validation & Exception Handling"
        Validation("Validation Modules"):::red
        Exception("Exception Handling"):::red
    end

    LeagueObj -.-> Validation
    AllTimeCalc -.-> Validation
    YearCalc -.-> Validation
    LeagueObj -.-> Exception
    AllTimeCalc -.-> Exception
    YearCalc -.-> Exception

    subgraph "Utilities & Configuration"
        Utility("Utility Modules"):::gray
        Config("Configuration"):::gray
    end

    LeagueObj --> Utility
    AllTimeCalc --> Utility
    YearCalc --> Utility
    Utility --> Config

    subgraph "External Interfaces"
        ExcelUtil("Excel Integration Utilities"):::gray
        CLI("Command-line & CI/CD"):::gray
        ExcelExample("Excel Example"):::gray
    end

    AllTimeSheet --> ExcelUtil
    YearSheet --> ExcelUtil
    Utility --> CLI
    ExcelUtil --> ExcelExample

    CI("CI/CD Workflows"):::gray
    ExcelExample --> CI

    %% Click Events
    click ESPN "https://github.com/joeyagreco/leeger/blob/main/leeger/league_loader/ESPNLeagueLoader.py"
    click Fleaflicker "https://github.com/joeyagreco/leeger/blob/main/leeger/league_loader/FleaflickerLeagueLoader.py"
    click MFL "https://github.com/joeyagreco/leeger/blob/main/leeger/league_loader/MyFantasyLeagueLeagueLoader.py"
    click Sleeper "https://github.com/joeyagreco/leeger/blob/main/leeger/league_loader/SleeperLeagueLoader.py"
    click Yahoo "https://github.com/joeyagreco/leeger/blob/main/leeger/league_loader/YahooLeagueLoader.py"

    click LeagueObj "https://github.com/joeyagreco/leeger/blob/main/leeger/model/league/League.py"
    click Abstraction "https://github.com/joeyagreco/leeger/tree/main/leeger/model/abstract"

    click AllTimeCalc "https://github.com/joeyagreco/leeger/blob/main/leeger/calculator/all_time_calculator/AWALAllTimeCalculator.py"
    click AllTimeSheet "https://github.com/joeyagreco/leeger/blob/main/leeger/model/stat/AllTimeStatSheet.py"
    click YearCalc "https://github.com/joeyagreco/leeger/blob/main/leeger/calculator/year_calculator/AWALYearCalculator.py"
    click YearSheet "https://github.com/joeyagreco/leeger/blob/main/leeger/model/stat/YearStatSheet.py"

    click Validation "https://github.com/joeyagreco/leeger/blob/main/leeger/validate/leagueValidation.py"
    click Exception "https://github.com/joeyagreco/leeger/blob/main/leeger/exception/InvalidLeagueFormatException.py"

    click Utility "https://github.com/joeyagreco/leeger/blob/main/leeger/util/ConfigReader.py"
    click Config "https://github.com/joeyagreco/leeger/blob/main/leeger/properties/app.properties"

    click ExcelUtil "https://github.com/joeyagreco/leeger/blob/main/leeger/util/excel.py"
    click CLI "https://github.com/joeyagreco/leeger/tree/main/Makefile"
    click ExcelExample "https://github.com/joeyagreco/leeger/blob/main/example/stat/statsToExcelExample.py"
    click CI "https://github.com/joeyagreco/leeger/tree/main/.github/workflows"
    click CLI "https://github.com/joeyagreco/leeger/blob/main/setup.py"

    %% Styling Classes
    classDef blue fill:#a7c7e7,stroke:#000,stroke-width:1px;
    classDef green fill:#a8e6cf,stroke:#000,stroke-width:1px;
    classDef orange fill:#ffd3b6,stroke:#000,stroke-width:1px;
    classDef red fill:#ffaaa5,stroke:#000,stroke-width:1px;
    classDef gray fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef utility fill:#fdfd96,stroke:#000,stroke-width:1px;
```
