# vinayakmane47/nasa-turbofan-ml-project-aiops architecture

> Architecture diagram of the GitHub repository vinayakmane47/nasa-turbofan-ml-project-aiops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinayakmane47/nasa-turbofan-ml-project-aiops
- Repository: https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops

## Overview

##### Project Type and Purpose
- Full-stack MLOps application.
- Purpose: Ingest turbofan engine data, validate and transform it, train multiple ML models, select the best, persist it, and expose prediction and monitoring via a Flask web UI.

##### Main Architectural Layers and Components
A. Presentation Layer (Flask Web Front-end)
- app.py: Flask routes/controllers
- templates/*.html: Jinja2 views (index, train, predict, logs, experiment history)
- Static assets (if any)

B. Application/MLOps Layer
- Turbofan.pipeline.Pipeline: Orchestrates ingestion → validation → transformation → training → evaluation → model pusher
- Turbofan.component.*:
- data_ingestion.py
- data_validation.py
- data_transformation.py
- model_trainer.py
- model_evaluation.py
- model_pusher.py
- Turbofan.entity: Configuration and artifact definitions (config_entity, artifact_entity, experiment, model_factory, Turbofan_predictor)
- Turbofan.config.configuration: Loads YAML configs (config/schema.yaml, config/model.yaml, config/config.yaml)
- Turbofan.util.util: Shared utility functions
- Turbofan.logger: Central logging

C. Data Layer
- Raw/Processed Data: Proccessed_data/*.csv
- Artifacts (auto-generated during pipeline runs): feature stores, train/test datasets
- saved_models/<timestamp>/model.pkl: Persisted best model

D. Infrastructure/DevOps
- Dockerfile / .dockerignore: Containerization
- .github/workflows/main.yaml: CI/CD (test, build, deploy)
- setup.py / requirements.txt: Packaging and dependencies
- Heroku (production hosting)

##### Data and Control Flow
1. User (browser) → HTTP request → Flask app (app.py).
2. For “Train” action, Flask invokes Turbofan.pipeline.Pipeline.run_pipeline().
3. Pipeline stages execute in order:
a. Data Ingestion: Read CSVs → raw artifact directory
b. Data Validation: Schema checks (schema.yaml)
c. Data Transformation: Feature engineering → feature store
d. Model Trainer: Fit multiple models, use model_factory for instantiation
e. Model Evaluation: Compare metrics (r2_score_train/test)
f. Model Pusher: Save best model to saved_models/<timestamp>
4. Pipeline writes logs and experiment metadata (experiments.csv or DB)
5. For “Predict” action, Flask loads Turbofan_predictor (entity) which loads saved model, processes user input, returns RUL
6. Flask renders templates showing results or experiment history

##### Architectural Patterns and Principles
- Layered (Presentation / Application / Data).
- Modular MLOps pipeline: each component has single responsibility.
- Configuration-driven design: behavior controlled via YAML files.
- Entity-driven: clear separation of data structures (entities) vs. logic (components).
- Log-and-monitor: Central logger, experiment history UI.

##### Technologies and Frameworks
- Python 3.7+, Flask (app.py)
- Jinja2 templates
- Pandas, NumPy, scikit-learn (ML tasks)
- YAML (configuration)
- Docker, GitHub Actions (CI/CD)
- Heroku (hosting)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser"]:::presentation
        FlaskApp["Flask App (app.py)"]:::presentation
        Templates["Jinja2 Templates"]:::presentation
    end

    %% MLOps Pipeline Layer
    subgraph "MLOps Pipeline" 
        PipelineOrchestrator["Pipeline Orchestrator\n(Turbofan.pipeline)"]:::pipeline
        DataIngest["Data Ingestion"]:::pipeline
        DataValidation["Data Validation"]:::pipeline
        DataTransform["Data Transformation"]:::pipeline
        ModelTrainer["Model Trainer"]:::pipeline
        ModelEvaluation["Model Evaluation"]:::pipeline
        ModelPusher["Model Pusher"]:::pipeline
        ConfigLoader["Configuration Loader"]:::pipeline
        Entities["Entity Definitions"]:::pipeline
        Util["Utility Functions"]:::pipeline
        Logger["Central Logger"]:::pipeline
    end

    %% Data Storage Layer
    subgraph "Data Storage"
        ProcessedData["Processed Data (.csv)"]:::storage
        PersistedModels["Persisted Models (model.pkl)"]:::storage
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        Docker["Dockerfile / .dockerignore"]:::infra
        CI_CD["GitHub Actions\n(.github/workflows)"]:::infra
        Packaging["setup.py / requirements.txt"]:::infra
        Hosting["Heroku Hosting"]:::infra
    end

    %% Data and Control Flow
    Browser -->|"HTTP Request"| FlaskApp
    FlaskApp -->|"Train / Predict"| PipelineOrchestrator
    PipelineOrchestrator --> DataIngest
    DataIngest -->|"raw CSVs"| ProcessedData
    DataIngest --> DataValidation
    DataValidation --> DataTransform
    DataTransform --> ModelTrainer
    ModelTrainer --> ModelEvaluation
    ModelEvaluation --> ModelPusher
    ModelPusher --> PersistedModels

    %% Pipeline Dependencies
    PipelineOrchestrator --> ConfigLoader
    PipelineOrchestrator --> Entities
    PipelineOrchestrator --> Util
    PipelineOrchestrator --> Logger

    %% Prediction Flow
    FlaskApp -->|"Load Model"| Entities
    Entities --> PersistedModels
    Entities --> ProcessedData

    %% Infrastructure Connections
    FlaskApp --> Docker
    CI_CD --> Docker
    Docker --> Hosting
    Packaging --> Docker

    %% Click Events
    click FlaskApp "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/app.py"
    click Templates "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/tree/main/templates/"
    click PipelineOrchestrator "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/pipeline/pipeline.py"
    click DataIngest "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/data_ingestion.py"
    click DataValidation "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/data_validation.py"
    click DataTransform "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/data_transformation.py"
    click ModelTrainer "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/model_trainer.py"
    click ModelEvaluation "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/model_evaluation.py"
    click ModelPusher "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/component/model_pusher.py"
    click ConfigLoader "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/config/configuration.py"
    click Entities "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/entity/config_entity.py"
    click Util "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/util/util.py"
    click Logger "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/Turbofan/logger/__init__.py"
    click ProcessedData "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/tree/main/Proccessed_data/"
    click PersistedModels "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/tree/main/saved_models/"
    click Docker "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/tree/main/Dockerfile"
    click CI_CD "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/.github/workflows/main.yaml"
    click Packaging "https://github.com/vinayakmane47/nasa-turbofan-ml-project-aiops/blob/main/setup.py"

    %% Styles
    classDef presentation fill:#cfe2f3,stroke:#000,stroke-width:1px
    classDef pipeline fill:#d9ead3,stroke:#000,stroke-width:1px
    classDef storage fill:#d9d9d9,stroke:#000,stroke-width:1px
    classDef infra fill:#fce5cd,stroke:#000,stroke-width:1px
```
