# kaifranke/gophhitterapp architecture

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

- Interactive diagram: https://gitdiagram.com/kaifranke/gophhitterapp
- Repository: https://github.com/kaifranke/gophhitterapp

## Overview

##### Project type and purpose
- This is an R‐based interactive data application (likely a Shiny app) called “Gopher Hitter.”
- It ingests TrackMan pitch data (Data10122023.csv), applies three predictive models (StrikeMod, xBAmodel, xwOBAmodel), and presents results via hitterApp.R (the main app script).

##### File structure
- Top‐level files:
- Data10122023.csv – raw data source
- hitterApp.R – contains all UI and server logic (the “frontend” and “backend” of the app)
- StrikeMod, xBAmodel, xwOBAmodel – each folder or script holds one statistical model or module
- README.md – describes project components (and possibly an image asset UMN.png if added)
- No separate “src/” or “lib/” directory: all code lives at top level.

##### README for additional insights
- README enumerates each piece: data file, model modules, main app script, and an optional logo.
- No mention of databases or external APIs; data is local CSV.

a. Main components:
- Data Source (CSV file)
- Modeling Modules (StrikeMod, xBAmodel, xwOBAmodel)
- Application Logic (hitterApp.R – server functions, reactive pipelines)
- User Interface (UI code inside hitterApp.R)
- Optional Asset (UMN.png)
- Hosting Environment (e.g., Shiny Server or RStudio Connect)

b. Relationships and interactions:
1. At startup, hitterApp.R reads Data10122023.csv.
2. Data flows into each model module (StrikeMod, xBAmodel, xwOBAmodel) for feature computation or predictions.
3. Model outputs are returned to the app’s reactive framework.
4. UI renders tables, plots, or summaries using the model results plus any static asset (UMN.png).
5. The hosting environment serves the UI to end users.

c. Architectural patterns / design principles:
- Modular code separation: each model in its own script/folder.
- Single‐page interactive web app (Shiny) with clear UI/Server separation.
- Data‐in → compute → render output reactive loop.

d. Relevant technologies and libraries:
- R / Shiny (ui.R / server.R or single‐file app pattern)
- Statistical modeling packages (e.g., data.table, dplyr, ggplot2, caret)
- Hosting: Shiny Server or RStudio Connect

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Tier
    subgraph "Data Tier"
        direction TB
        Data["Data10122023.csv"]:::data
        README["README.md (Documentation)"]:::doc
    end

    %% Processing Tier
    subgraph "Processing Tier"
        direction TB
        StrikeMod["StrikeMod Module"]:::model
        xBAmodel["xBAmodel Module"]:::model
        xwOBAmodel["xwOBAmodel Module"]:::model
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        App["hitterApp.R (Shiny App Logic)"]:::app
    end

    %% Presentation Tier
    subgraph "Presentation Tier"
        direction TB
        Asset["UMN.png (Optional Asset)"]:::asset
        UI["Browser UI"]:::ui
    end

    %% Deployment Tier
    subgraph "Deployment Tier"
        direction TB
        Host["Shiny Server / RStudio Connect"]:::hosting
    end

    %% Connections
    Data -->|ingests data| StrikeMod
    Data -->|ingests data| xBAmodel
    Data -->|ingests data| xwOBAmodel

    StrikeMod -->|returns predictions| App
    xBAmodel -->|returns predictions| App
    xwOBAmodel -->|returns predictions| App

    App -->|renders UI| UI
    Asset -->|loaded in UI| UI

    Host -->|hosts app logic| App
    Host -->|serves UI to users| UI

    %% Click Events
    click Data "https://github.com/kaifranke/gophhitterapp/blob/main/Data10122023.csv"
    click StrikeMod "https://github.com/kaifranke/gophhitterapp/tree/main/StrikeMod/"
    click xBAmodel "https://github.com/kaifranke/gophhitterapp/tree/main/xBAmodel/"
    click xwOBAmodel "https://github.com/kaifranke/gophhitterapp/tree/main/xwOBAmodel/"
    click App "https://github.com/kaifranke/gophhitterapp/blob/main/hitterApp.R"
    click README "https://github.com/kaifranke/gophhitterapp/blob/main/README.md"

    %% Styles
    classDef data fill:#AED6F1,stroke:#217DBB,color:#000;
    classDef model fill:#ABEBC6,stroke:#239B56,color:#000;
    classDef app fill:#F5B041,stroke:#CA6F1E,color:#000;
    classDef ui fill:#D7BDE2,stroke:#6C3483,color:#000;
    classDef hosting fill:#D5D8DC,stroke:#566573,color:#000;
    classDef doc fill:#FDEBD0,stroke:#BA4A00,color:#000;
    classDef asset fill:#FDEBD0,stroke:#B9770E,color:#000;
```
