# anishawasthi/callup architecture

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

- Interactive diagram: https://gitdiagram.com/anishawasthi/callup
- Repository: https://github.com/anishawasthi/callup
- Video tour (about a minute): https://gitdiagram.com/anishawasthi/callup/video

## Overview

Callup is a baseball research data-preparation project for studying how Triple-A hitter seasons relate to next-season MLB performance. Its principal workflow is to assemble player-season cohorts and labels, ingest and classify pitch-level data, prepare and validate analysis tables, then provide CSVs for feature work and modeling. The repository also documents batted-ball, ballpark, and promotion-summary research. Some preparation-script call paths are only partially excerpted, so uncertain internal links are omitted or marked unverified.

Main entry points: [`scripts/prepare_analysis.py`](https://github.com/anishawasthi/callup/blob/main/scripts/prepare_analysis.py) (Analysis preparation), [`callup/statsapi.py`](https://github.com/anishawasthi/callup/blob/main/callup/statsapi.py) (Stats API client), [`callup/ingest.py`](https://github.com/anishawasthi/callup/blob/main/callup/ingest.py) (Pitch ingestion), [`callup/cohort.py`](https://github.com/anishawasthi/callup/blob/main/callup/cohort.py) (Cohort builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cohort["Cohorts and outcomes"]
  node_cohort_report["Cohort report<br/>[cohort_report.py]"]
  node_cohort_builder["Cohort builder<br/>[cohort.py]"]
  node_stats_client["Stats API client<br/>[statsapi.py]"]
  node_contract["Table contract<br/>[contract.py]"]
end

subgraph group_pitches["Pitch data"]
  node_pitch_ingest["Pitch ingestion<br/>[ingest.py]"]
  node_ingest_cli["Ingest command<br/>[ingest_statcast.py]"]
  node_archive_audit["Archive validation"]
end

subgraph group_analysis["Preparation and analysis"]
  node_storage["Storage helpers<br/>[storage.py]"]
  node_storage_prep["Storage preparation<br/>[prepare_storage.py]"]
  node_analysis_prep["Analysis preparation"]
  node_prepared_data["Prepared datasets"]
  node_download["Dataset download"]
end

node_researcher(("Researcher"))
node_mlb_stats["MLB Stats API"]
node_statcast["Baseball Savant"]
node_analyst["Analysis and modeling"]

node_researcher -->|"runs"| node_cohort_report
node_cohort_report -.->|"builds cohorts"| node_cohort_builder
node_cohort_builder -.->|"requests stats"| node_stats_client
node_stats_client -.->|"fetches data"| node_mlb_stats
node_researcher -->|"runs"| node_ingest_cli
node_ingest_cli -->|"dispatches ingest"| node_pitch_ingest
node_pitch_ingest -->|"requests schedule"| node_stats_client
node_pitch_ingest -.->|"downloads pitches"| node_statcast
node_researcher -->|"validates archive"| node_archive_audit
node_researcher -.->|"prepares storage"| node_storage_prep
node_storage_prep -->|"converts and verifies"| node_storage
node_researcher -->|"prepares analysis"| node_analysis_prep
node_analysis_prep -.->|"builds cohort"| node_cohort_builder
node_analysis_prep -.->|"validates table"| node_contract
node_analysis_prep -.->|"requests stats"| node_stats_client
node_analysis_prep -.->|"writes tables"| node_prepared_data
node_researcher -->|"gets dataset"| node_download
node_download -.->|"provides files"| node_prepared_data
node_prepared_data -->|"supports feature work"| node_analyst

click node_cohort_report "https://github.com/anishawasthi/callup/blob/main/scripts/cohort_report.py"
click node_cohort_builder "https://github.com/anishawasthi/callup/blob/main/callup/cohort.py"
click node_stats_client "https://github.com/anishawasthi/callup/blob/main/callup/statsapi.py"
click node_contract "https://github.com/anishawasthi/callup/blob/main/callup/contract.py"
click node_pitch_ingest "https://github.com/anishawasthi/callup/blob/main/callup/ingest.py"
click node_ingest_cli "https://github.com/anishawasthi/callup/blob/main/scripts/ingest_statcast.py"
click node_archive_audit "https://github.com/anishawasthi/callup/blob/main/scripts/validate_archive.py"
click node_storage "https://github.com/anishawasthi/callup/blob/main/callup/storage.py"
click node_storage_prep "https://github.com/anishawasthi/callup/blob/main/scripts/prepare_storage.py"
click node_analysis_prep "https://github.com/anishawasthi/callup/blob/main/scripts/prepare_analysis.py"
click node_prepared_data "https://github.com/anishawasthi/callup/tree/main/data"
click node_download "https://github.com/anishawasthi/callup/blob/main/scripts/download_dataset.py"

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_cohort_report,node_cohort_builder,node_stats_client,node_contract toneBlue
class node_pitch_ingest,node_ingest_cli,node_archive_audit toneAmber
class node_storage,node_storage_prep,node_analysis_prep,node_prepared_data,node_download,node_mlb_stats toneMint
class node_researcher,node_statcast,node_analyst toneIndigo
```

## Components

### Cohorts and outcomes

- [Cohort report](https://github.com/anishawasthi/callup/blob/main/scripts/cohort_report.py): `scripts/cohort_report.py`
- [Cohort builder](https://github.com/anishawasthi/callup/blob/main/callup/cohort.py): `callup/cohort.py`
- [Stats API client](https://github.com/anishawasthi/callup/blob/main/callup/statsapi.py): `callup/statsapi.py`
- [Table contract](https://github.com/anishawasthi/callup/blob/main/callup/contract.py): `callup/contract.py`

### Pitch data

- [Pitch ingestion](https://github.com/anishawasthi/callup/blob/main/callup/ingest.py): `callup/ingest.py`
- [Ingest command](https://github.com/anishawasthi/callup/blob/main/scripts/ingest_statcast.py): `scripts/ingest_statcast.py`
- [Archive validation](https://github.com/anishawasthi/callup/blob/main/scripts/validate_archive.py): `scripts/validate_archive.py`

### Preparation and analysis

- [Storage helpers](https://github.com/anishawasthi/callup/blob/main/callup/storage.py): `callup/storage.py`
- [Storage preparation](https://github.com/anishawasthi/callup/blob/main/scripts/prepare_storage.py): `scripts/prepare_storage.py`
- [Analysis preparation](https://github.com/anishawasthi/callup/blob/main/scripts/prepare_analysis.py): `scripts/prepare_analysis.py`
- [Prepared datasets](https://github.com/anishawasthi/callup/tree/main/data): `data`
- [Dataset download](https://github.com/anishawasthi/callup/blob/main/scripts/download_dataset.py): `scripts/download_dataset.py`

### Other components

- **Researcher**
- **MLB Stats API**
- **Baseball Savant**
- **Analysis and modeling**

## Connections

- Researcher → Cohort report: runs (evidence: `README.md`)
- Cohort report → Cohort builder: builds cohorts (evidence: `scripts/cohort_report.py`)
- Cohort builder → Stats API client: requests stats (evidence: `callup/cohort.py`)
- Stats API client → MLB Stats API: fetches data
- Researcher → Ingest command: runs (evidence: `scripts/ingest_statcast.py`)
- Ingest command → Pitch ingestion: dispatches ingest (evidence: `scripts/ingest_statcast.py`)
- Pitch ingestion → Stats API client: requests schedule (evidence: `callup/ingest.py`)
- Pitch ingestion → Baseball Savant: downloads pitches
- Researcher → Archive validation: validates archive (evidence: `README.md`)
- Researcher → Storage preparation: prepares storage
- Storage preparation → Storage helpers: converts and verifies (evidence: `scripts/prepare_storage.py`)
- Researcher → Analysis preparation: prepares analysis (evidence: `README.md`)
- Analysis preparation → Cohort builder: builds cohort (evidence: `scripts/prepare_analysis.py`)
- Analysis preparation → Table contract: validates table (evidence: `scripts/prepare_analysis.py`)
- Analysis preparation → Stats API client: requests stats (evidence: `scripts/prepare_analysis.py`)
- Analysis preparation → Prepared datasets: writes tables
- Researcher → Dataset download: gets dataset (evidence: `README.md`)
- Dataset download → Prepared datasets: provides files
- Prepared datasets → Analysis and modeling: supports feature work (evidence: `README.md`)
