How jaideep27/cancer_prediction-mlops- works
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: app.py API app · train.py Train & eval · training_pipeline.py Training pipe · inference_pipeline.py Inference pipe
Components 21
Runtime
Core application code paths for data, models, API, and monitoring.
- Raw data · Source breast-cancer CSV used by ingestion and training.
data/raw/breast-cancer.csv - Data layer · Loads, validates, preprocesses, and splits training data.
src/data - Features · Transforms cleaned data into model-ready features.
src/features - Base model · Shared abstraction for model families and lifecycle methods.
src/models/base_model.py - Model families · Logistic regression, gradient boosting, neural network, and hybrid ensemble implementations.
src/models - Registry · Version selection and persistence logic for trained models.
src/models/registry.py - Train & eval · Training, evaluation, and prediction routines for model execution.
src/models/train.py - Model store · Versioned model artifacts, metadata, metrics, and registry index.
models - API app · FastAPI entrypoint for online inference.
src/api/app.py - API schema · Request and response contracts for prediction endpoints.
src/api/schemas.py - Middleware · Logging, timing, and error handling around API requests.
src/api/middleware.py - Monitoring · Performance and data-drift checks for deployed models.
src/monitoring
Operations
Pipelines, scripts, tests, and configuration that control delivery and execution.
- Training pipe · End-to-end training workflow from data prep to artifact saving.
src/pipelines/training_pipeline.py - Eval pipe · Standalone evaluation workflow for model quality checks.
src/pipelines/evaluation_pipeline.py - Inference pipe · Loads a selected model version and runs predictions.
src/pipelines/inference_pipeline.py - Config · Central configuration loading for data, model, training, deployment, and logging.
src/utils/config.py - Scripts · Command-line entrypoints for training, evaluation, batch prediction, and EDA.
scripts - Tests · Unit and integration tests covering preprocessing, models, and API contract.
tests
Infra
Container, registry, observability, and Kubernetes deployment boundary.
- Docker stack · Container build and local compose stack for the service and support components.
docker - K8s deploy · Kubernetes resources for API, MLflow, Prometheus, Grafana, storage, and ingress.
infrastructure/kubernetes - Observability · Prometheus configuration and Grafana-oriented monitoring surface.
monitoring/prometheus/prometheus.yml
Connections 30
- 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.