# boldandbrad/fffetch architecture

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

- Interactive diagram: https://gitdiagram.com/boldandbrad/fffetch
- Repository: https://github.com/boldandbrad/fffetch

## Overview

##### Main Components
- Main Application/Entry Point:
– fffetch.go is the orchestrator—it initializes the process and controls the overall workflow.
- Data Fetching Module:
– The internal/pfr package contains files (data.go and html.go) responsible for web scraping and processing HTML data from Pro Football Reference.
- Data Analysis/Calculation Module:
– The internal/calc package (advStats.go and ffStats.go) performs various calculations and statistical analyses on the fetched data.
- Utility Module:
– The internal/util package provides shared helper functions (io.go and structs.go) likely used by both the data fetching and data analyzing modules.

##### Interactions and Data Flow
- The Main Application calls functions in the pfr module to start data fetching.
- Data fetched (raw HTML and parsed data structures) is then passed on to the calc module for advanced statistical analysis.
- Utility functions are used at various stages for tasks such as file I/O or data structure management.

##### Architectural Patterns and Design Principles
- Modular design: The project organizes functionality into distinct internal packages (calc, pfr, util), which helps in isolating concerns.
- A layered approach: fffetch.go acts on the top layer, coordinating lower-level modules.
- That Web Scraping techniques are used, which may hint at dependency on external data sources and an inherent asynchronous or rate-limited access pattern (as mentioned in the README).

##### Relevant Technologies and Frameworks
- Go Programming Language (as reflected in go.mod/go.sum and the overall codebase).
- Web Scraping: Techniques implemented in the pfr module.
- Data Analysis: Statistical calculations found in the calc module.
- Dependency management: Go modules (as indicated by go.mod), ensuring reproducibility of builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Application Layer
    A1("Main Application (fffetch.go)"):::internal

    %% Data Fetching Subsystem
    B1("Web Scraper (internal/pfr)"):::internal

    %% Data Analysis Subsystem
    C1("Statistics Calculator (internal/calc)"):::internal

    %% Utility Module
    D1("Utility Functions (internal/util)"):::internal

    %% External System
    E1(("Pro Football Reference")):::external

    %% Data Flow Connections
    A1 -->|"FetchRawNFLData"| B1
    B1 -->|"ReturnParsedData"| A1
    A1 -->|"DataForAnalysis"| C1
    B1 -->|"UsesUtilities"| D1
    C1 -->|"UsesUtilities"| D1
    B1 -->|"HTTP_Request/WebScraping"| E1

    %% Click Events
    click A1 "https://github.com/boldandbrad/fffetch/blob/main/fffetch.go"
    click B1 "https://github.com/boldandbrad/fffetch/tree/main/internal/pfr"
    click C1 "https://github.com/boldandbrad/fffetch/tree/main/internal/calc"
    click D1 "https://github.com/boldandbrad/fffetch/tree/main/internal/util"

    %% Styles
    classDef internal fill:#C4E7B0,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#FDE598,stroke:#333,stroke-width:2px,color:#000,stroke-dasharray: 5 5;
    
    %% Legend (as comments)
    %% internal: Internal components | external: External system
```
