# googlecloudplatform/mlops-with-vertex-ai architecture

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

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/mlops-with-vertex-ai
- Repository: https://github.com/googlecloudplatform/mlops-with-vertex-ai

## Overview

1. **Repository purpose**
   - This is an end-to-end MLOps sample for Vertex AI on Google Cloud.
   - It covers the full lifecycle: data exploration, feature processing, model training, pipeline orchestration, CI/CD, deployment, prediction serving, and monitoring.

2. **Primary user-facing entrypoints**
   - The main workflow is documented through the numbered Jupyter notebooks (`01-...` to `08-...`).
   - Those notebooks act as the operational “chapters” of the system and are the clearest high-level architecture guide for how the pieces fit together.

3. **Data source and dataset management**
   - The source dataset is Chicago Taxi Trips in BigQuery.
   - The repository treats BigQuery as the raw analytical data source, then creates a Vertex AI Dataset resource and a raw schema (`src/raw_schema/schema.pbtxt`) for validation.
   - This is the first boundary: public warehouse data is transformed into ML-ready managed dataset artifacts.

4. **Preprocessing and feature engineering**
   - `src/preprocessing` contains the ETL and transformation logic used before training.
   - `etl.py` and `transformations.py` separate data extraction/cleanup from feature transforms.
   - `src/common/features.py` and `src/common/datasource_utils.py` hold shared feature definitions and datasource helpers, which keeps feature logic consistent between notebooks, local tests, and pipeline execution.

5. **Model training package**
   - `src/model_training` encapsulates the custom Keras model and training workflow.
   - Important responsibilities are split across:
     - `model.py` for model definition,
     - `data.py` for input data handling,
     - `trainer.py` and `runner.py` for training orchestration,
     - `exporter.py` for saving/exporting the trained model,
     - `task.py` and `defaults.py` for command-line/task configuration.
   - This package is the training “engine” used both interactively and inside pipeline steps.

6. **TFX pipeline layer**
   - `src/tfx_pipelines` formalizes the training workflow as a TFX pipeline.
   - `training_pipeline.py` and `prediction_pipeline.py` define separate pipeline flows for training and batch prediction.
   - `components.py` and `config.py` centralize pipeline component wiring and runtime configuration.
   - The pipeline uses TFX components to read from BigQuery, validate data, run Dataflow-based transforms, train a custom model, evaluate it, and push a blessed model.

7. **Pipeline data flow**
   - The training path is: BigQuery ingest → schema/statistics validation → Dataflow transform → Vertex AI training → model evaluation → model push/export → Vertex AI model upload.
   - The `README` also calls out custom Python components for hyperparameter generation and Vertex model upload, indicating that the pipeline mixes standard TFX components with repo-specific glue code.
   - This is the key orchestration boundary: data/feature work is separated from execution scheduling and deployment.

8. **Continuous training trigger**
   - `src/pipeline_triggering/main.py` implements a Cloud Function used to start training when a Pub/Sub message arrives.
   - The trigger is external to the pipeline itself: Pub/Sub provides the event, Cloud Function translates it into a pipeline run.
   - This gives the system a decoupled continuous-training mechanism rather than relying on manual notebook execution.

9. **Deployment automation**
   - The `build/` directory contains Cloud Build definitions for CI/CD.
   - `build/pipeline-deployment.yaml` covers pipeline validation, local e2e testing, container build, pipeline compilation, and upload to Cloud Storage.
   - `build/model-deployment.yaml` covers model interface tests and deployment of the trained model to a Vertex AI endpoint.
   - This split shows two release artifacts: the pipeline definition and the serving model.

10. **Serving architecture**
   - The trained model is served through Vertex AI endpoints for online prediction.
   - The repo also supports batch prediction using the uploaded Vertex AI model and Vertex Pipelines.
   - Serving is therefore dual-mode: synchronous endpoint inference and offline/batch inference.

11. **Monitoring and feedback loop**
   - `08-model-monitoring.ipynb` configures Vertex AI Model Monitoring for skew and drift detection.
   - Monitoring jobs watch deployed models under an endpoint, produce artifacts, and support pause/delete lifecycle management.
   - This closes the operational loop by providing the signal that can feed future retraining.

12. **Infrastructure and environment provisioning**
   - `provision/terraform` defines the cloud foundation: GCS buckets, notebook instance, service accounts, and enabled services.
   - This is the repo’s environment bootstrap layer and is separate from ML logic, which helps distinguish platform setup from model lifecycle code.

13. **Testing and validation boundaries**
   - `src/tests` contains unit/integration-style tests for datasource utilities, ETL, model behavior, pipeline deployment, and model deployment.
   - These tests support the CI/CD flows in `build/` and are important for architecture because they validate both training logic and deployment assumptions.

14. **Overall architecture view**
   - The repo is structured around a cloud-native ML lifecycle:
     - notebooks for interactive exploration,
     - Python packages for preprocessing, training, and pipelines,
     - Terraform for cloud provisioning,
     - Cloud Build for release automation,
     - Pub/Sub + Cloud Functions for triggering,
     - Vertex AI for training, registry, serving, and monitoring.
   - The main diagram should center on BigQuery data flowing into TFX training pipelines, with trained models flowing into Vertex AI deployment and monitoring, and a separate event path triggering retraining.

Main entry points: [`src/tfx_pipelines/training_pipeline.py`](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/training_pipeline.py) (Train pipeline), [`build/pipeline-deployment.yaml`](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/pipeline-deployment.yaml) (Pipeline CI/CD), [`src/model_training/trainer.py`](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/model_training/trainer.py) (Training flow), [`build/model-deployment.yaml`](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/model-deployment.yaml) (Model CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_notebooks["Notebooks"]
  node_nb_01["Dataset mgmt<br/>notebook chapter"]
  node_nb_02["Experimentation<br/>notebook chapter"]
  node_nb_03["Train formalize<br/>notebook chapter"]
  node_nb_04["Pipeline deploy<br/>notebook chapter"]
  node_nb_05["Continuous train<br/>notebook chapter"]
  node_nb_06["Model deploy<br/>notebook chapter"]
  node_nb_07["Prediction serving<br/>notebook chapter"]
  node_nb_08["Monitoring<br/>notebook chapter"]
end

subgraph group_src["Source Code"]
  node_schema["Raw schema<br/>validation schema<br/>[schema.pbtxt]"]
  node_common["Shared logic<br/>shared utilities<br/>[features.py]"]
  node_preprocess["Preprocessing<br/>etl package<br/>[etl.py]"]
  node_train_model["Model core<br/>training model<br/>[model.py]"]
  node_train_exec["Training flow<br/>trainer orchestration<br/>[trainer.py]"]
  node_tfx_train["Train pipeline<br/>tfx pipeline"]
  node_tfx_pred["Batch pipeline<br/>tfx pipeline"]
  node_tfx_comp["Pipeline wiring<br/>tfx components<br/>[components.py]"]
end

subgraph group_delivery["Delivery"]
  node_trigger["Trigger function<br/>cloud function<br/>[main.py]"]
  node_ci_pipeline["Pipeline CI/CD<br/>cloud build spec"]
  node_ci_model["Model CI/CD<br/>cloud build spec"]
  node_tests["Tests<br/>validation suite<br/>[model_tests.py]"]
end

subgraph group_platform["Platform"]
  node_infra["Terraform<br/>provisioning stack<br/>[main.tf]"]
end

node_nb_01 -->|"define schema"| node_schema
node_nb_01 -->|"prepare data"| node_common
node_nb_02 -->|"explore transforms"| node_preprocess
node_nb_03 -->|"formalize model"| node_train_model
node_common -->|"shared features"| node_preprocess
node_common -->|"shared input"| node_train_exec
node_preprocess -->|"train data"| node_train_exec
node_train_model -->|"run model"| node_train_exec
node_train_exec -->|"integrate"| node_tfx_comp
node_tfx_comp -->|"assemble"| node_tfx_train
node_tfx_comp -->|"assemble"| node_tfx_pred
node_tfx_train -->|"compile/deploy"| node_ci_pipeline
node_ci_pipeline -->|"run on cloud"| node_infra
node_ci_pipeline -->|"validate"| node_tests
node_ci_model -->|"validate"| node_tests
node_trigger -->|"start run"| node_tfx_train
node_nb_05 -->|"set trigger"| node_trigger
node_nb_06 -->|"deploy model"| node_ci_model
node_tfx_train -->|"blessed model"| node_ci_model
node_tfx_pred -->|"serve batch"| node_nb_07
node_nb_08 -->|"monitor endpoint"| node_ci_model
node_nb_04 -->|"release pipeline"| node_ci_pipeline

click node_nb_01 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/01-dataset-management.ipynb"
click node_nb_02 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/02-experimentation.ipynb"
click node_nb_03 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/03-training-formalization.ipynb"
click node_nb_04 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/04-pipeline-deployment.ipynb"
click node_nb_05 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/05-continuous-training.ipynb"
click node_nb_06 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/06-model-deployment.ipynb"
click node_nb_07 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/07-prediction-serving.ipynb"
click node_nb_08 "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/08-model-monitoring.ipynb"
click node_schema "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/raw_schema/schema.pbtxt"
click node_common "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/common/features.py"
click node_preprocess "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/preprocessing/etl.py"
click node_train_model "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/model_training/model.py"
click node_train_exec "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/model_training/trainer.py"
click node_tfx_train "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/training_pipeline.py"
click node_tfx_pred "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/prediction_pipeline.py"
click node_tfx_comp "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/components.py"
click node_trigger "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/pipeline_triggering/main.py"
click node_ci_pipeline "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/pipeline-deployment.yaml"
click node_ci_model "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/model-deployment.yaml"
click node_tests "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tests/model_tests.py"
click node_infra "https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/provision/terraform/main.tf"

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_nb_01,node_nb_02,node_nb_03,node_nb_04,node_nb_05,node_nb_06,node_nb_07,node_nb_08 toneBlue
class node_schema,node_common,node_preprocess,node_train_model,node_train_exec,node_tfx_train,node_tfx_pred,node_tfx_comp toneAmber
class node_trigger,node_ci_pipeline,node_ci_model,node_tests toneMint
class node_infra toneRose
```

## Components

### Notebooks

Interactive lifecycle chapters

- [Dataset mgmt](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/01-dataset-management.ipynb): notebook chapter · Data exploration and dataset setup · `01-dataset-management.ipynb`
- [Experimentation](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/02-experimentation.ipynb): notebook chapter · Interactive feature and model exploration · `02-experimentation.ipynb`
- [Train formalize](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/03-training-formalization.ipynb): notebook chapter · Moves experiments into reproducible training · `03-training-formalization.ipynb`
- [Pipeline deploy](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/04-pipeline-deployment.ipynb): notebook chapter · Pipeline validation and deployment workflow · `04-pipeline-deployment.ipynb`
- [Continuous train](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/05-continuous-training.ipynb): notebook chapter · Event-driven retraining setup · `05-continuous-training.ipynb`
- [Model deploy](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/06-model-deployment.ipynb): notebook chapter · Serving deployment workflow · `06-model-deployment.ipynb`
- [Prediction serving](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/07-prediction-serving.ipynb): notebook chapter · Online and batch inference usage · `07-prediction-serving.ipynb`
- [Monitoring](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/08-model-monitoring.ipynb): notebook chapter · Drift and skew monitoring setup · `08-model-monitoring.ipynb`

### Source Code

Core ML and pipeline packages

- [Raw schema](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/raw_schema/schema.pbtxt): validation schema · Schema for raw BigQuery data validation · `src/raw_schema/schema.pbtxt`
- [Shared logic](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/common/features.py): shared utilities · Feature definitions and datasource helpers · `src/common/features.py`
- [Preprocessing](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/preprocessing/etl.py): etl package · Extraction, cleanup, and feature transforms · `src/preprocessing/etl.py`
- [Model core](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/model_training/model.py): training model · Custom Keras model definition · `src/model_training/model.py`
- [Training flow](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/model_training/trainer.py): trainer orchestration · Training run, task wiring, and export · `src/model_training/trainer.py`
- [Train pipeline](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/training_pipeline.py): tfx pipeline · End-to-end training pipeline definition · `src/tfx_pipelines/training_pipeline.py`
- [Batch pipeline](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/prediction_pipeline.py): tfx pipeline · Batch prediction pipeline definition · `src/tfx_pipelines/prediction_pipeline.py`
- [Pipeline wiring](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tfx_pipelines/components.py): tfx components · Component assembly and runtime config · `src/tfx_pipelines/components.py`

### Delivery

CI/CD, triggering, and serving

- [Trigger function](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/pipeline_triggering/main.py): cloud function · Pub/Sub-driven pipeline trigger · `src/pipeline_triggering/main.py`
- [Pipeline CI/CD](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/pipeline-deployment.yaml): cloud build spec · Validate, test, compile, and upload pipeline · `build/pipeline-deployment.yaml`
- [Model CI/CD](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/build/model-deployment.yaml): cloud build spec · Test and deploy the serving model · `build/model-deployment.yaml`
- [Tests](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/src/tests/model_tests.py): validation suite · Unit and deployment checks for training and serving · `src/tests/model_tests.py`

### Platform

Cloud foundation and provisioning

- [Terraform](https://github.com/googlecloudplatform/mlops-with-vertex-ai/blob/main/provision/terraform/main.tf): provisioning stack · Buckets, notebooks, service accounts, and services · `provision/terraform/main.tf`

## Connections

- Dataset mgmt → Raw schema: define schema · Raw data validation boundary
- Dataset mgmt → Shared logic: prepare data · Dataset access and feature helpers
- Experimentation → Preprocessing: explore transforms · Interactive preprocessing and feature engineering
- Train formalize → Model core: formalize model · Moves notebook experiments into code
- Shared logic → Preprocessing: shared features · Consistent feature logic across flows
- Shared logic → Training flow: shared input · Datasource and feature utilities for training
- Preprocessing → Training flow: train data · Prepared examples feed training
- Model core → Training flow: run model · Model definition used by trainer
- Training flow → Pipeline wiring: integrate · Training logic is embedded in pipeline components
- Pipeline wiring → Train pipeline: assemble · Component wiring for the training pipeline
- Pipeline wiring → Batch pipeline: assemble · Component wiring for the batch prediction pipeline
- Train pipeline → Pipeline CI/CD: compile/deploy · Pipeline artifact is validated and uploaded
- Pipeline CI/CD → Terraform: run on cloud · Uses provisioned project resources and storage
- Pipeline CI/CD → Tests: validate · Pipeline deployment checks are enforced
- Model CI/CD → Tests: validate · Model interface and deployment checks
- Trigger function → Train pipeline: start run · Pub/Sub event triggers training pipeline
- Continuous train → Trigger function: set trigger · Continuous training setup in notebook
- Model deploy → Model CI/CD: deploy model · Serving release workflow
- Train pipeline → Model CI/CD: blessed model · Trained model flows to serving deployment
- Batch pipeline → Prediction serving: serve batch · Batch prediction workflow is exercised interactively
- Monitoring → Model CI/CD: monitor endpoint · Monitoring is configured against deployed serving
- Pipeline deploy → Pipeline CI/CD: release pipeline · Notebook documents pipeline deployment
