# yaml-language-server: $schema=../references/diagram.schema.json
title: ML platform on AWS
subtitle: Amazon SageMaker AI and AWS Step Functions train and serve models; drift alarms retrain them
direction: down
layout: { merge: false, spacing: compact }

legend:
  solid: Pipeline flow
  dashed: Retraining loop
  dotted: Monitoring data

groups:
  cloud: { type: aws:cloud }
  region: { type: aws:region, label: us-east-1, in: cloud }
  pipeline: { type: aws:step-functions, label: Training pipeline, in: region }

nodes:
  raw: { icon: aws:s3, label: Raw data lake, note: Amazon Simple Storage Service, in: region }
  features: { icon: aws:sagemaker-ai, label: Feature pipeline, note: SageMaker AI Processing, in: region }
  store: { icon: aws:sagemaker-ai, label: Feature Store, note: Offline store, in: region }
  train: { icon: aws:sagemaker-ai-train, label: Train, note: SageMaker AI training job, in: pipeline }
  evaluate: { icon: aws:lambda, label: Evaluate, note: Compare to baseline, in: pipeline }
  registry: { icon: aws:sagemaker-ai-model, label: Model Registry, note: Approved versions, in: region }
  batch: { icon: aws:sagemaker-ai, label: Batch transform, note: Nightly scoring, in: region }
  scores: { icon: aws:s3, label: Predictions, note: S3 bucket, in: region }
  endpoint: { icon: aws:sagemaker-ai, label: Real-time endpoint, note: Online serving, in: region }
  monitor: { icon: aws:cloudwatch-alarm, label: Drift alarm, note: Model Monitor and CloudWatch, in: region }
  retrain: { icon: aws:eventbridge, label: Retraining rule, note: Amazon EventBridge, in: region }

edges:
  - raw -> features -> store
  - store -> train -> evaluate -> registry
  - registry -> batch, endpoint
  - batch -> scores
  - endpoint ..> monitor: captured traffic
  # The retraining loop points back at the pipeline; written in layout order with the
  # arrowheads at the start so it sits under the serving branch instead of past it.
  - { from: pipeline, to: retrain, arrow: start, line: dashed, label: StartExecution }
  - { from: retrain, to: monitor, arrow: start, line: dashed }
