# joeydd032995-pixel/v0-mlb-betting-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/joeydd032995-pixel/v0-mlb-betting-analytics
- Repository: https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics

## Overview

This is an MLB NRFI/YRFI prediction product: it assembles game and matchup inputs, estimates first-inning probabilities with a calibrated statistical ensemble, and presents picks and betting context to users. The principal workflow also records predictions for result tracking and performance analysis. Separate branches support historical data reconstruction, model diagnostics, and account betting tools. The README documents the model stages; source-index references and excerpts establish the cited application, storage, and sync connections. Unshown integrations and routes are omitted rather than inferred.

Main entry points: [`lib/nrfi-engine.ts`](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/nrfi-engine.ts) (Prediction engine), [`app/api/historical-sync/route.ts`](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/api/historical-sync/route.ts) (Historical sync), [`app/page.tsx`](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/page.tsx) (Daily slate), [`lib/prisma.ts`](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/prisma.ts) (Application database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Prediction experience"]
  node_home["Daily slate<br/>[page.tsx]"]
  node_pickcard["Pick cards"]
  node_ensembleview["Model diagnostics<br/>[page.tsx]"]
end

subgraph group_data["Game data"]
  node_live["Live game data<br/>[live-data.ts]"]
  node_mlb["MLB statistics<br/>[mlb-stats.ts]"]
  node_weather["Weather inputs<br/>[weather.ts]"]
  node_odds["Odds analysis<br/>[odds.ts]"]
end

subgraph group_model["Prediction engine"]
  node_engine["Prediction engine<br/>[nrfi-engine.ts]"]
  node_models["Statistical models<br/>[nrfi-models.ts]"]
  node_features["Feature construction<br/>[feature-vector.ts]"]
  node_deep["Deep NRFI model<br/>[deepnrfi-model.ts]"]
  node_calibration["Probability calibration<br/>[calibration.ts]"]
  node_simulation["Monte Carlo<br/>[monte-carlo.ts]"]
end

subgraph group_tracking["Tracking and analysis"]
  node_store["Prediction tracking"]
  node_actions["Account actions<br/>[actions.ts]"]
  node_database[("Application database<br/>[prisma.ts]")]
  node_performance["Performance metrics<br/>[route.ts]"]
end

subgraph group_historical["Historical reconstruction"]
  node_sync["Historical sync<br/>[route.ts]"]
  node_asof["Point-in-time slate<br/>[asof-slate.ts]"]
end

node_bettor(("Bettor"))

node_bettor -->|"views slate"| node_home
node_home -->|"loads predictions"| node_live
node_live -.->|"supplies games"| node_engine
node_engine -->|"computes ensemble"| node_models
node_engine -->|"builds features"| node_features
node_engine -->|"predicts optionally"| node_deep
node_engine -->|"calibrates probabilities"| node_calibration
node_engine -->|"uses simulation"| node_simulation
node_engine -->|"uses weather"| node_weather
node_home -->|"renders picks"| node_pickcard
node_home -->|"tracks predictions"| node_store
node_bettor -->|"opens diagnostics"| node_ensembleview
node_ensembleview -->|"loads game data"| node_live
node_ensembleview -->|"computes predictions"| node_engine
node_store -.->|"persists predictions"| node_database
node_actions -->|"reads and writes"| node_database
node_performance -->|"reads outcomes"| node_database
node_performance -.->|"uses prediction records"| node_store
node_sync -->|"fetches game results"| node_mlb
node_sync -->|"fetches historical weather"| node_weather
node_sync -->|"builds historical slate"| node_asof
node_sync -.->|"recomputes predictions"| node_engine
node_sync -.->|"stores results"| node_database
node_engine -->|"prices betting value"| node_odds
node_mlb -.->|"provides matchup statistics"| node_engine

click node_home "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/page.tsx"
click node_pickcard "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/components/game-prediction-card.tsx"
click node_ensembleview "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/ensemble/page.tsx"
click node_live "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/live-data.ts"
click node_mlb "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/mlb-stats.ts"
click node_weather "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/weather.ts"
click node_odds "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/odds.ts"
click node_engine "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/nrfi-engine.ts"
click node_models "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/nrfi-models.ts"
click node_features "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/features/feature-vector.ts"
click node_deep "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/deepnrfi-model.ts"
click node_calibration "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/calibration.ts"
click node_simulation "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/monte-carlo.ts"
click node_store "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/prediction-store.ts"
click node_actions "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/actions.ts"
click node_database "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/prisma.ts"
click node_performance "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/api/performance/route.ts"
click node_sync "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/api/historical-sync/route.ts"
click node_asof "https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/server/asof-slate.ts"

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_home,node_pickcard,node_ensembleview toneBlue
class node_live,node_mlb,node_weather,node_odds toneAmber
class node_engine,node_models,node_features,node_deep,node_calibration,node_simulation toneMint
class node_store,node_actions,node_database,node_performance toneRose
class node_sync,node_asof,node_bettor toneIndigo
```

## Components

### Prediction experience

- [Daily slate](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/page.tsx): `app/page.tsx`
- [Pick cards](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/components/game-prediction-card.tsx): `components/game-prediction-card.tsx`
- [Model diagnostics](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/ensemble/page.tsx): `app/ensemble/page.tsx`

### Game data

- [Live game data](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/live-data.ts): `lib/api/live-data.ts`
- [MLB statistics](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/mlb-stats.ts): `lib/api/mlb-stats.ts`
- [Weather inputs](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/weather.ts): `lib/weather.ts`
- [Odds analysis](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/api/odds.ts): `lib/api/odds.ts`

### Prediction engine

- [Prediction engine](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/nrfi-engine.ts): `lib/nrfi-engine.ts`
- [Statistical models](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/nrfi-models.ts): `lib/nrfi-models.ts`
- [Feature construction](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/features/feature-vector.ts): `lib/features/feature-vector.ts`
- [Deep NRFI model](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/deepnrfi-model.ts): `lib/deepnrfi-model.ts`
- [Probability calibration](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/calibration.ts): `lib/calibration.ts`
- [Monte Carlo](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/monte-carlo.ts): `lib/monte-carlo.ts`

### Tracking and analysis

- [Prediction tracking](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/prediction-store.ts): `lib/prediction-store.ts`
- [Account actions](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/actions.ts): `app/actions.ts`
- [Application database](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/prisma.ts): `lib/prisma.ts`
- [Performance metrics](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/api/performance/route.ts): `app/api/performance/route.ts`

### Historical reconstruction

- [Historical sync](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/app/api/historical-sync/route.ts): `app/api/historical-sync/route.ts`
- [Point-in-time slate](https://github.com/joeydd032995-pixel/v0-mlb-betting-analytics/blob/main/lib/server/asof-slate.ts): `lib/server/asof-slate.ts`

### Other components

- **Bettor**

## Connections

- Bettor → Daily slate: views slate (evidence: `app/page.tsx`)
- Daily slate → Live game data: loads predictions (evidence: `app/page.tsx`)
- Live game data → Prediction engine: supplies games
- Prediction engine → Statistical models: computes ensemble (evidence: `lib/nrfi-engine.ts`)
- Prediction engine → Feature construction: builds features (evidence: `lib/nrfi-engine.ts`)
- Prediction engine → Deep NRFI model: predicts optionally (evidence: `lib/nrfi-engine.ts`)
- Prediction engine → Probability calibration: calibrates probabilities (evidence: `lib/nrfi-engine.ts`)
- Prediction engine → Monte Carlo: uses simulation (evidence: `lib/nrfi-engine.ts`)
- Prediction engine → Weather inputs: uses weather (evidence: `lib/nrfi-engine.ts`)
- Daily slate → Pick cards: renders picks (evidence: `app/page.tsx`)
- Daily slate → Prediction tracking: tracks predictions (evidence: `app/page.tsx`)
- Bettor → Model diagnostics: opens diagnostics (evidence: `app/ensemble/page.tsx`)
- Model diagnostics → Live game data: loads game data (evidence: `app/ensemble/page.tsx`)
- Model diagnostics → Prediction engine: computes predictions (evidence: `app/ensemble/page.tsx`)
- Prediction tracking → Application database: persists predictions
- Account actions → Application database: reads and writes (evidence: `app/actions.ts`)
- Performance metrics → Application database: reads outcomes (evidence: `app/api/performance/route.ts`)
- Performance metrics → Prediction tracking: uses prediction records
- Historical sync → MLB statistics: fetches game results (evidence: `app/api/historical-sync/route.ts`)
- Historical sync → Weather inputs: fetches historical weather (evidence: `app/api/historical-sync/route.ts`)
- Historical sync → Point-in-time slate: builds historical slate (evidence: `app/api/historical-sync/route.ts`)
- Historical sync → Prediction engine: recomputes predictions (evidence: `app/api/historical-sync/route.ts`)
- Historical sync → Application database: stores results (evidence: `app/api/historical-sync/route.ts`)
- Prediction engine → Odds analysis: prices betting value (evidence: `README.md`)
- MLB statistics → Prediction engine: provides matchup statistics
