# pankajrawat9075/fantasy-sports-prediction architecture

> Architecture diagram of the GitHub repository pankajrawat9075/fantasy-sports-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pankajrawat9075/fantasy-sports-prediction
- Repository: https://github.com/pankajrawat9075/fantasy-sports-prediction

## Overview

##### Project type and purpose
- This is a standalone Python‐based data pipeline and analytics tool (“Player Prediction Predictor”) that:
- Ingests ball‐by‐ball and match metadata (YAML files from Cricsheet)
- Extracts and aggregates per‐match and career statistics for batsmen and bowlers
- Runs predictive functions to forecast runs or wickets for a given player or match
- It is not a web service; it’s an “open‐source analytical pipeline” with a CLI entrypoint (run.py).

##### File structure
- Top-level files
- run.py: CLI or orchestration entry point
- requirements.txt: Python dependencies
- team maker.py, team.csv: small utility for team composition
- Raw data folder
- odis/… .yaml: one file per match (2005–2019)
- Data acquisition scripts (scripts/*.py)
- batsman_data_acquisition.py, bowler_data_acquisition.py
- player_performance.py
- Processed data folder
- player_details/*.xlsx: aggregated Excel spreadsheets
- GitHub CI config in .github/workflows/python-package-conda.yml

##### README for additional insights
- Describes two main functions:
1. Per‐player performance prediction
2. Per‐team match outcome and best XI selection
- Explains features extracted at two levels:
- Overall career stats
- Per‐match stats
- Confirms data source, period, and the kind of statistics produced

a. Main components:
1. Raw Data Store: “odis/” folder of YAML files
2. ETL Layer (Data Acquisition Scripts):
– batsman_data_acquisition.py
– bowler_data_acquisition.py
– player_performance.py
3. Processed Data Store: “player_details/” Excel files & “team.csv”
4. Prediction Engine (Business Logic): run.py + any internal modules/functions
5. External Libraries & Runtime:
– PyYAML for parsing
– Pandas for tabular processing
– NumPy, Scikit-learn (if used for modeling)
6. User Interface: CLI arguments, console output, generated CSV/XLSX results

b. Relationships & data flows:

c. Architectural patterns & principles:
– Layered pipeline (extract → transform → load → predict)
– Separation of concerns:
- Data ingestion vs. data storage vs. prediction logic
– Modular scripts allowing easy extension (e.g., add new feature extractors)

d. Key technologies:
– Python 3.x
– PyYAML, Pandas, NumPy
– Excel I/O (openpyxl or xlrd via Pandas)
– (Optionally) scikit-learn or similar for model training/inference

##### Detail
- Team maker utility and run.py orchestrator as separate entrypoint nodes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Storage Layer
    RawStore["Raw YAML Data Store\n(odis/)"]:::storage
    click RawStore "https://github.com/pankajrawat9075/fantasy-sports-prediction/tree/main/odis/"

    subgraph "ETL Layer"
        direction TB
        BatScript["Batsman Data Acquisition\n(scripts/batsman_data_acquisition.py)"]:::process
        click BatScript "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/scripts/batsman_data_acquisition.py"
        BowlScript["Bowler Data Acquisition\n(scripts/bowler_data_acquisition.py)"]:::process
        click BowlScript "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/scripts/bowler_data_acquisition.py"
        PerfScript["Player Performance Aggregation\n(scripts/player_performance.py)"]:::process
        click PerfScript "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/scripts/player_performance.py"
    end

    subgraph "Processed Data Store"
        direction TB
        MatchBat["Match Batsman Details\n(player_details/match_batsman_details.xlsx)"]:::storage
        click MatchBat "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/player_details/match_batsman_details.xlsx"
        MatchBowl["Match Bowler Details\n(player_details/match_bowler_details.xlsx)"]:::storage
        click MatchBowl "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/player_details/match_bowler_details.xlsx"
        OverallBat["Overall Batsman Details\n(player_details/overall_batsman_details.xlsx)"]:::storage
        click OverallBat "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/player_details/overall_batsman_details.xlsx"
        OverallBowl["Overall Bowler Details\n(player_details/overall_bowler_details.xlsx)"]:::storage
        click OverallBowl "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/player_details/overall_bowler_details.xlsx"
        TeamCSV["Team Composition Data\n(team.csv)"]:::storage
        click TeamCSV "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/team.csv"
    end

    subgraph "Configuration"
        direction TB
        Requirements["Dependencies Configuration\n(requirements.txt)"]:::config
        click Requirements "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/requirements.txt"
        CIConfig["CI Configuration\n(.github/workflows/python-package-conda.yml)"]:::config
        click CIConfig "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/.github/workflows/python-package-conda.yml"
    end

    TeamMaker["Team Composition Utility\n(team maker.py)"]:::process
    click TeamMaker "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/team maker.py"

    PredictionEngine["Prediction Engine\n(run.py)"]:::engine
    click PredictionEngine "https://github.com/pankajrawat9075/fantasy-sports-prediction/blob/main/run.py"

    CLI["User Interface\n(CLI/Console)"]:::ui

    subgraph "Libraries & Runtime"
        direction TB
        PyYAML["PyYAML"]:::lib
        Pandas["Pandas"]:::lib
        NumPy["NumPy"]:::lib
        Sklearn["Scikit-learn"]:::lib
    end

    %% Data Flows
    RawStore -->|"parse & transform"| BatScript
    RawStore -->|"parse & transform"| BowlScript
    RawStore -->|"parse & transform"| PerfScript

    BatScript -->|"aggregate & write"| MatchBat
    BowlScript -->|"aggregate & write"| MatchBowl
    PerfScript -->|"aggregate & write"| OverallBat
    PerfScript -->|"aggregate & write"| OverallBowl

    MatchBat -->|"load processed data"| PredictionEngine
    MatchBowl -->|"load processed data"| PredictionEngine
    OverallBat -->|"load processed data"| PredictionEngine
    OverallBowl -->|"load processed data"| PredictionEngine
    TeamCSV -->|"load team data"| PredictionEngine
    TeamMaker -->|"generate team"| PredictionEngine

    PredictionEngine -->|"predict & output"| CLI

    %% Dependencies to Prediction Engine
    PredictionEngine --> PyYAML
    PredictionEngine --> Pandas
    PredictionEngine --> NumPy
    PredictionEngine --> Sklearn

    %% Config relationships
    PredictionEngine --> Requirements
    CIConfig --> PredictionEngine

    %% Styles
    classDef storage fill:#bbdefb,stroke:#0d47a1,stroke-width:2px,shape:cylinder
    classDef process fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,shape:rect
    classDef engine fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px,shape:hexagon
    classDef ui fill:#eeeeee,stroke:#424242,stroke-width:2px,shape:ellipse
    classDef config fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px,shape:parallelogram
    classDef lib fill:#fff9c4,stroke:#f9a825,stroke-width:2px,shape:rect
```
