# ankitgundewar/mlops-cookbook architecture

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

- Interactive diagram: https://gitdiagram.com/ankitgundewar/mlops-cookbook
- Repository: https://github.com/ankitgundewar/mlops-cookbook

## Overview

This repository is a baseball-player height-prediction example for containerized ML and AWS deployment. Its main workflow accepts a player's weight through a CLI or Flask endpoint, runs a trained model and input/target scaling, and returns height in inches and human-readable form. A separate utility CLI retrains the model from CSV data or queries the Flask endpoint; an AWS SAM recipe exposes a Lambda handler using a parallel model library. The graph follows shown calls and documented capabilities; the recipe’s deployment wiring is not inferred from its configuration files.

Main entry points: [`mlib.py`](https://github.com/ankitgundewar/mlops-cookbook/blob/main/mlib.py) (Model operations), [`recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py`](https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py) (Lambda model library), [`app.py`](https://github.com/ankitgundewar/mlops-cookbook/blob/main/app.py) (Flask API), [`utilscli.py`](https://github.com/ankitgundewar/mlops-cookbook/blob/main/utilscli.py) (Utility CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Prediction interfaces"]
  node_predict_cli["Prediction CLI<br/>[cli.py]"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_utility_cli["Utility CLI<br/>[utilscli.py]"]
end

subgraph group_ml["ML runtime"]
  node_prediction["Prediction pipeline<br/>[mlib.py]"]
  node_model_ops["Model operations<br/>[mlib.py]"]
end

subgraph group_assets["Model assets"]
  node_training_data["Training data<br/>[htwtmlb.csv]"]
  node_model_file[("Trained model<br/>[model.joblib]")]
end

subgraph group_aws["AWS recipe"]
  node_lambda_handler["Lambda handler<br/>[app.py]"]
  node_lambda_library["Lambda model library<br/>[mlib.py]"]
  node_lambda_data["Lambda training data<br/>[htwtmlb.csv]"]
  node_lambda_model[("Lambda model<br/>[model.joblib]")]
end

node_user(("User"))
node_http_service["Prediction service"]

node_user -->|"requests prediction"| node_predict_cli
node_user -->|"submits weight"| node_flask_api
node_predict_cli -->|"calls predict"| node_prediction
node_flask_api -->|"calls predict"| node_prediction
node_utility_cli -->|"retraining call"| node_model_ops
node_utility_cli -->|"posts prediction"| node_http_service
node_http_service -->|"routes request"| node_flask_api
node_prediction -->|"loads and scales"| node_model_ops
node_model_ops -->|"reads data"| node_training_data
node_model_ops -->|"loads or saves"| node_model_file
node_user -->|"invokes prediction"| node_lambda_handler
node_lambda_handler -->|"calls predict"| node_lambda_library
node_lambda_library -->|"reads data"| node_lambda_data
node_lambda_library -->|"loads or saves"| node_lambda_model

click node_predict_cli "https://github.com/ankitgundewar/mlops-cookbook/blob/main/cli.py"
click node_flask_api "https://github.com/ankitgundewar/mlops-cookbook/blob/main/app.py"
click node_utility_cli "https://github.com/ankitgundewar/mlops-cookbook/blob/main/utilscli.py"
click node_prediction "https://github.com/ankitgundewar/mlops-cookbook/blob/main/mlib.py"
click node_model_ops "https://github.com/ankitgundewar/mlops-cookbook/blob/main/mlib.py"
click node_training_data "https://github.com/ankitgundewar/mlops-cookbook/blob/main/htwtmlb.csv"
click node_model_file "https://github.com/ankitgundewar/mlops-cookbook/blob/main/model.joblib"
click node_lambda_handler "https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/app.py"
click node_lambda_library "https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py"
click node_lambda_data "https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/htwtmlb.csv"
click node_lambda_model "https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/model.joblib"

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_predict_cli,node_flask_api,node_utility_cli,node_user toneBlue
class node_prediction,node_model_ops toneAmber
class node_training_data,node_model_file toneMint
class node_lambda_handler,node_lambda_library,node_lambda_data,node_lambda_model toneRose
class node_http_service toneIndigo
```

## Components

### Prediction interfaces

- [Prediction CLI](https://github.com/ankitgundewar/mlops-cookbook/blob/main/cli.py): `cli.py`
- [Flask API](https://github.com/ankitgundewar/mlops-cookbook/blob/main/app.py): `app.py`
- [Utility CLI](https://github.com/ankitgundewar/mlops-cookbook/blob/main/utilscli.py): `utilscli.py`

### ML runtime

- [Prediction pipeline](https://github.com/ankitgundewar/mlops-cookbook/blob/main/mlib.py): `mlib.py`
- [Model operations](https://github.com/ankitgundewar/mlops-cookbook/blob/main/mlib.py): `mlib.py`

### Model assets

- [Training data](https://github.com/ankitgundewar/mlops-cookbook/blob/main/htwtmlb.csv): `htwtmlb.csv`
- [Trained model](https://github.com/ankitgundewar/mlops-cookbook/blob/main/model.joblib): `model.joblib`

### AWS recipe

- [Lambda handler](https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/app.py): `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/app.py`
- [Lambda model library](https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py): `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py`
- [Lambda training data](https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/htwtmlb.csv): `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/htwtmlb.csv`
- [Lambda model](https://github.com/ankitgundewar/mlops-cookbook/blob/main/recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/model.joblib): `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/model.joblib`

### Other components

- **User**
- **Prediction service**

## Connections

- User → Prediction CLI: requests prediction (evidence: `README.md`)
- User → Flask API: submits weight (evidence: `README.md`)
- Prediction CLI → Prediction pipeline: calls predict (evidence: `cli.py`)
- Flask API → Prediction pipeline: calls predict (evidence: `app.py`)
- Utility CLI → Model operations: retraining call (evidence: `utilscli.py`)
- Utility CLI → Prediction service: posts prediction (evidence: `utilscli.py`)
- Prediction service → Flask API: routes request (evidence: `README.md`)
- Prediction pipeline → Model operations: loads and scales (evidence: `mlib.py`)
- Model operations → Training data: reads data (evidence: `mlib.py`)
- Model operations → Trained model: loads or saves (evidence: `mlib.py`)
- User → Lambda handler: invokes prediction (evidence: `README.md`)
- Lambda handler → Lambda model library: calls predict (evidence: `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/app.py`)
- Lambda model library → Lambda training data: reads data (evidence: `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py`)
- Lambda model library → Lambda model: loads or saves (evidence: `recipes/aws-lambda-sam/sam-ml-predict/ml_hello_world/mlib.py`)
