# jaideep27/cancer_prediction-mlops- architecture

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

- Interactive diagram: https://gitdiagram.com/jaideep27/cancer_prediction-mlops-
- Repository: https://github.com/jaideep27/cancer_prediction-mlops-

## Overview

1. **Purpose and deployment shape**
   - This is a production ML platform for breast-cancer diagnosis, not a generic app.
   - The repository is organized around three runtime paths: offline training/evaluation, online inference via API, and operational monitoring/deployment.

2. **Core runtime boundary: `src/`**
   - `src/` contains the actual application code, split into clear layers:
     - `data/` for ingestion and preprocessing
     - `features/` for feature engineering
     - `models/` for training, evaluation, prediction, and registry logic
     - `pipelines/` for orchestration of end-to-end workflows
     - `api/` for serving predictions
     - `monitoring/` for drift and performance checks
     - `utils/` for shared config, logging, and helpers

3. **Data flow from raw dataset to model-ready inputs**
   - The source dataset is stored in `data/raw/breast-cancer.csv`.
   - Training begins with load/validate/preprocess/split logic in `src/data/`, then feature construction in `src/features/`.
   - This creates the model inputs consumed by the model implementations in `src/models/`.

4. **Modeling subsystem**
   - There are four model families: logistic regression, gradient boosting, neural network, and a hybrid ensemble.
   - `src/models/base_model.py` suggests a common interface or abstraction, while `train.py`, `evaluate.py`, and `predict.py` separate lifecycle concerns.
   - `src/models/registry.py` manages model versioning and selection; the persisted artifacts under `models/` are versioned by model name and release number.

5. **Persisted model artifacts**
   - The `models/` directory is not source code; it is the packaged model registry/artifact store.
   - Each model type has a `1.0/` version folder containing `metadata.json` and `metrics.json`, and `models/registry.json` appears to be the top-level index of available versions.
   - This is the key boundary between training time and serving time.

6. **Pipelines as orchestration layer**
   - `src/pipelines/training_pipeline.py` ties together data preparation, model training, evaluation, and artifact saving.
   - `src/pipelines/inference_pipeline.py` encapsulates loading a chosen model/version and executing prediction.
   - `src/pipelines/evaluation_pipeline.py` provides a standalone evaluation path, likely used by scripts and CI/model-training automation.

7. **Serving layer**
   - `src/api/app.py` is the FastAPI entrypoint for online inference.
   - `schemas.py` defines request/response contracts, which is important for diagramming the API boundary.
   - `middleware.py` handles request/response cross-cutting concerns such as logging, timing, or error handling.
   - The API reads from the model registry/artifact store rather than retraining in-process.

8. **Observability and monitoring**
   - `src/monitoring/performance.py` and `src/monitoring/data_drift.py` provide application-level monitoring beyond infrastructure metrics.
   - The README indicates drift detection is statistical and based on KS-testing, so there is a clear distinction between ML health monitoring and service metrics.
   - Prometheus and Grafana are the external observability stack for metrics collection and visualization.

9. **Operational scripts**
   - `scripts/train_model.py`, `scripts/evaluate_model.py`, `scripts/batch_predict.py`, and `scripts/run_eda.py` are operator-facing entry points.
   - These scripts likely invoke the same pipeline/model layers used by the API, which keeps batch and online logic aligned.
   - For an architecture diagram, these belong outside the service runtime as command-line workflow entry points.

10. **Configuration boundary**
   - All major behavior is parameterized through YAML in `configs/`: data, model, training, deployment, and logging.
   - `src/utils/config.py` likely centralizes loading/validation of those settings.
   - This makes environment-specific behavior configurable without changing code.

11. **Infrastructure and deployment**
   - Docker is used for containerization (`docker/Dockerfile`, `docker/docker-compose.yml`) to run the API plus MLflow/Prometheus/Grafana locally or in a single-host stack.
   - Kubernetes manifests under `infrastructure/kubernetes/` define production deployment objects such as namespace, configmaps, persistent volumes, API deployment, MLflow, Prometheus, Grafana, and ingress.
   - The presence of helper scripts like `deploy.sh`, `status.sh`, and `update.sh` suggests a managed operational workflow around these manifests.

12. **CI/CD and automation**
   - GitHub Actions workflows split the lifecycle into CI, CD, and scheduled model training.
   - CI runs validation and test gates; CD handles image build/deployment; model_training runs retraining on a schedule.
   - This repository therefore has both software delivery automation and ML retraining automation.

13. **Testing and quality gates**
   - Unit tests cover preprocessing and model logic; integration tests cover the API contract.
   - `pytest.ini`, `requirements-dev.txt`, and the CI workflows indicate that test execution and code-quality checks are first-class boundaries in the delivery process.
   - For diagrams, testing sits alongside the pipelines as a quality-control layer rather than inside the runtime path.

14. **External dependencies that materially affect architecture**
   - FastAPI is the serving framework.
   - MLflow is the experiment-tracking and model-registry-related component mentioned in the README and infrastructure.
   - Prometheus/Grafana form the monitoring stack.
   - Docker and Kubernetes are the packaging and orchestration layers that determine how the system is deployed in local and production environments.

Main entry points: [`src/api/app.py`](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/app.py) (API app), [`src/models/train.py`](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/train.py) (Train & eval), [`src/pipelines/training_pipeline.py`](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/training_pipeline.py) (Training pipe), [`src/pipelines/inference_pipeline.py`](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/inference_pipeline.py) (Inference pipe)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_raw_data["Raw data<br/>dataset<br/>[breast-cancer.csv]"]
  node_data_layer["Data layer<br/>ingest/prepare"]
  node_feature_layer["Features<br/>feature engineering"]
  node_base_model["Base model<br/>model interface<br/>[base_model.py]"]
  node_model_families["Model families<br/>learners"]
  node_model_registry["Registry<br/>artifact index<br/>[registry.py]"]
  node_train_eval["Train & eval<br/>lifecycle<br/>[train.py]"]
  node_model_store[("Model store<br/>artifact store")]
  node_api_app["API app<br/>serving api<br/>[app.py]"]
  node_api_contract["API schema<br/>request/response<br/>[schemas.py]"]
  node_api_middleware["Middleware<br/>cross-cutting<br/>[middleware.py]"]
  node_monitoring_checks["Monitoring<br/>ml health"]
end

subgraph group_ops["Operations"]
  node_training_pipeline["Training pipe<br/>orchestration"]
  node_evaluation_pipeline["Eval pipe<br/>orchestration"]
  node_inference_pipeline["Inference pipe<br/>orchestration"]
  node_config_layer["Config<br/>yaml settings<br/>[config.py]"]
  node_operator_scripts["Scripts<br/>cli entrypoints"]
  node_tests["Tests<br/>quality gates"]
end

subgraph group_infra["Infra"]
  node_docker_stack["Docker stack<br/>containerization"]
  node_k8s_deploy["K8s deploy<br/>deployment manifests"]
  node_observability["Observability<br/>metrics stack<br/>[prometheus.yml]"]
end

node_raw_data -->|"ingested by"| node_data_layer
node_data_layer -->|"features"| node_feature_layer
node_feature_layer -->|"inputs"| node_train_eval
node_base_model -->|"implements"| node_model_families
node_model_families -->|"trained by"| node_train_eval
node_train_eval -->|"registers"| node_model_registry
node_model_registry -->|"persists to"| node_model_store
node_training_pipeline -->|"orchestrates"| node_data_layer
node_training_pipeline -->|"orchestrates"| node_train_eval
node_training_pipeline -->|"writes"| node_model_store
node_evaluation_pipeline -->|"uses"| node_train_eval
node_inference_pipeline -->|"loads"| node_model_registry
node_inference_pipeline -->|"reads"| node_model_store
node_api_app -->|"validates"| node_api_contract
node_api_app -->|"wraps"| node_api_middleware
node_api_app -->|"serves"| node_inference_pipeline
node_monitoring_checks -->|"compares"| node_model_store
node_config_layer -->|"configures"| node_training_pipeline
node_config_layer -->|"configures"| node_api_app
node_operator_scripts -->|"invokes"| node_training_pipeline
node_operator_scripts -->|"invokes"| node_evaluation_pipeline
node_operator_scripts -->|"invokes"| node_inference_pipeline
node_tests -->|"covers"| node_data_layer
node_tests -->|"covers"| node_train_eval
node_tests -->|"covers"| node_api_app
node_docker_stack -->|"packages"| node_api_app
node_docker_stack -->|"includes"| node_observability
node_k8s_deploy -->|"deploys"| node_api_app
node_k8s_deploy -->|"deploys"| node_observability
node_observability -->|"feeds"| node_monitoring_checks

click node_raw_data "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/data/raw/breast-cancer.csv"
click node_data_layer "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/data"
click node_feature_layer "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/features"
click node_base_model "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/base_model.py"
click node_model_families "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/models"
click node_model_registry "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/registry.py"
click node_train_eval "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/train.py"
click node_model_store "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/models"
click node_training_pipeline "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/training_pipeline.py"
click node_evaluation_pipeline "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/evaluation_pipeline.py"
click node_inference_pipeline "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/inference_pipeline.py"
click node_api_app "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/app.py"
click node_api_contract "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/schemas.py"
click node_api_middleware "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/middleware.py"
click node_monitoring_checks "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/monitoring"
click node_config_layer "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/utils/config.py"
click node_operator_scripts "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/scripts"
click node_tests "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/tests"
click node_docker_stack "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/docker"
click node_k8s_deploy "https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/infrastructure/kubernetes"
click node_observability "https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/monitoring/prometheus/prometheus.yml"

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_raw_data,node_data_layer,node_feature_layer,node_base_model,node_model_families,node_model_registry,node_train_eval,node_model_store,node_api_app,node_api_contract,node_api_middleware,node_monitoring_checks toneBlue
class node_training_pipeline,node_evaluation_pipeline,node_inference_pipeline,node_config_layer,node_operator_scripts,node_tests toneAmber
class node_docker_stack,node_k8s_deploy,node_observability toneMint
```

## Components

### Runtime

Core application code paths for data, models, API, and monitoring.

- [Raw data](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/data/raw/breast-cancer.csv): dataset · Source breast-cancer CSV used by ingestion and training. · `data/raw/breast-cancer.csv`
- [Data layer](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/data): ingest/prepare · Loads, validates, preprocesses, and splits training data. · `src/data`
- [Features](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/features): feature engineering · Transforms cleaned data into model-ready features. · `src/features`
- [Base model](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/base_model.py): model interface · Shared abstraction for model families and lifecycle methods. · `src/models/base_model.py`
- [Model families](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/models): learners · Logistic regression, gradient boosting, neural network, and hybrid ensemble implementations. · `src/models`
- [Registry](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/registry.py): artifact index · Version selection and persistence logic for trained models. · `src/models/registry.py`
- [Train & eval](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/models/train.py): lifecycle · Training, evaluation, and prediction routines for model execution. · `src/models/train.py`
- [Model store](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/models): artifact store · Versioned model artifacts, metadata, metrics, and registry index. · `models`
- [API app](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/app.py): serving api · FastAPI entrypoint for online inference. · `src/api/app.py`
- [API schema](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/schemas.py): request/response · Request and response contracts for prediction endpoints. · `src/api/schemas.py`
- [Middleware](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/api/middleware.py): cross-cutting · Logging, timing, and error handling around API requests. · `src/api/middleware.py`
- [Monitoring](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/src/monitoring): ml health · Performance and data-drift checks for deployed models. · `src/monitoring`

### Operations

Pipelines, scripts, tests, and configuration that control delivery and execution.

- [Training pipe](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/training_pipeline.py): orchestration · End-to-end training workflow from data prep to artifact saving. · `src/pipelines/training_pipeline.py`
- [Eval pipe](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/evaluation_pipeline.py): orchestration · Standalone evaluation workflow for model quality checks. · `src/pipelines/evaluation_pipeline.py`
- [Inference pipe](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/pipelines/inference_pipeline.py): orchestration · Loads a selected model version and runs predictions. · `src/pipelines/inference_pipeline.py`
- [Config](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/src/utils/config.py): yaml settings · Central configuration loading for data, model, training, deployment, and logging. · `src/utils/config.py`
- [Scripts](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/scripts): cli entrypoints · Command-line entrypoints for training, evaluation, batch prediction, and EDA. · `scripts`
- [Tests](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/tests): quality gates · Unit and integration tests covering preprocessing, models, and API contract. · `tests`

### Infra

Container, registry, observability, and Kubernetes deployment boundary.

- [Docker stack](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/docker): containerization · Container build and local compose stack for the service and support components. · `docker`
- [K8s deploy](https://github.com/jaideep27/cancer_prediction-mlops-/tree/main/infrastructure/kubernetes): deployment manifests · Kubernetes resources for API, MLflow, Prometheus, Grafana, storage, and ingress. · `infrastructure/kubernetes`
- [Observability](https://github.com/jaideep27/cancer_prediction-mlops-/blob/main/monitoring/prometheus/prometheus.yml): metrics stack · Prometheus configuration and Grafana-oriented monitoring surface. · `monitoring/prometheus/prometheus.yml`

## Connections

- Raw data → Data layer: ingested by · Raw dataset is validated and preprocessed before feature building.
- Data layer → Features: features · Cleaned and split data feeds feature construction.
- Features → Train & eval: inputs · Feature sets are consumed by training and evaluation routines.
- Base model → Model families: implements · Concrete learners share the common model interface.
- Model families → Train & eval: trained by · Model families are trained, evaluated, and used for prediction.
- Train & eval → Registry: registers · Training outputs are registered and versioned.
- Registry → Model store: persists to · Registry metadata maps to stored artifacts and versions.
- Training pipe → Data layer: orchestrates · Training pipeline coordinates data preparation.
- Training pipe → Train & eval: orchestrates · Training pipeline drives model lifecycle execution.
- Training pipe → Model store: writes · Trained artifacts and metadata are saved to the model store.
- Eval pipe → Train & eval: uses · Evaluation pipeline reuses model evaluation logic.
- Inference pipe → Registry: loads · Inference pipeline selects an approved model version.
- Inference pipe → Model store: reads · Inference pipeline loads persisted artifacts.
- API app → API schema: validates · API endpoints use typed request and response schemas.
- API app → Middleware: wraps · Middleware handles cross-cutting request concerns.
- API app → Inference pipe: serves · API delegates prediction execution to the inference pipeline.
- Monitoring → Model store: compares · Monitoring compares live behavior against stored model expectations.
- Config → Training pipe: configures · Training behavior is driven by external YAML settings.
- Config → API app: configures · Serving behavior and deployment settings are parameterized.
- Scripts → Training pipe: invokes · CLI scripts trigger the same training workflow as automation.
- Scripts → Eval pipe: invokes · CLI scripts trigger standalone evaluation.
- Scripts → Inference pipe: invokes · Batch prediction reuses inference logic.
- Tests → Data layer: covers · Unit tests validate preprocessing behavior.
- Tests → Train & eval: covers · Unit tests validate model logic.
- Tests → API app: covers · Integration tests exercise the API contract.
- Docker stack → API app: packages · Container stack runs the serving application and support services.
- Docker stack → Observability: includes · Local deployment includes metrics collection and visualization.
- K8s deploy → API app: deploys · Kubernetes manifests deploy the API service.
- K8s deploy → Observability: deploys · Kubernetes manifests deploy monitoring components.
- Observability → Monitoring: feeds · Platform metrics complement ML health monitoring.
