# tak-praveen/mushrooms-classification architecture

> Architecture diagram of the GitHub repository tak-praveen/mushrooms-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tak-praveen/mushrooms-classification
- Repository: https://github.com/tak-praveen/mushrooms-classification

## Overview

##### Project type and purpose
- This is a full-stack Machine-Learning web application (“Mushroom Classification”) built with Flask.
- It provides a user interface for submitting mushroom feature values, runs a scikit-learn pipeline (data ingestion, transformation, model inference), and returns “Edible” or “Poisonous.”
- It also contains training pipelines and Jupyter notebooks for EDA and model development.

##### File structure
Top-level directories and files:
- app.py – Flask entry-point (routes, request handling, invoking prediction).
- templates/ – HTML files (home.html, index.html).
- src/components/ – modular pipeline building blocks:
– data_ingestion.py
– data_transformation.py
– model_trainer.py
- src/pipeline/ – end-to-end pipeline orchestrators:
– train_pipeline.py
– predict_pipeline.py
- artifacts/ – persisted CSV data, trained model (.pkl) and preprocessor (.pkl).
- notebook/ – Jupyter notebooks for EDA & offline model training.
- setup.py, requirements.txt, runtime.txt – project packaging and deployment config.

##### Key insights from README
- UML-style preview shows a web form and result page.
- Describes custom ML pipeline, Flask web interface, and target deployment (Render/Heroku).
- Emphasizes extensibility and lightweight packaging.

##### Main components
A. User Interface
- Browser / Client – renders HTML form, sends HTTP POST with feature values.
- templates/home.html & templates/index.html
B. Web Server Layer
- Flask App (app.py)
- WSGI Server (e.g., Gunicorn)
C. ML Prediction Pipeline
- PredictPipeline (src/pipeline/predict_pipeline.py)
- Components:
– DataIngestion module loads raw inputs into DataFrame
– DataTransformation module applies preprocessor.pkl
– ModelTrainer module loads model.pkl for inference
D. Data / Artifact Store
- artifacts/ directory storing:
– raw dataset CSVs (train.csv, test.csv, data.csv)
– serialized preprocessor (preprocessor.pkl)
– serialized model (model.pkl)
E. Training Pipeline (offline component)
- TrainPipeline (src/pipeline/train_pipeline.py) orchestrates:
– src/components/data_ingestion → data_transformation → model_trainer
– saves new model and preprocessor back into artifacts/
F. Development Environment
- Jupyter Notebooks (not part of production DAG but useful for design)
- Virtual environment (new_env/)
G. External Deployment Platform
- Render or Heroku (receives Docker/WSGI deployment artifacts)

##### Relationships and interactions
- User → HTTP Request → Flask App
- Flask App → PredictPipeline → DataIngestion → DataTransformation → Model Inference → Response
- PredictPipeline reads preprocessor.pkl & model.pkl from artifacts/
- Training flow (offline): TrainPipeline reads CSVs → updates artifacts/
- Git repository & CI/CD (implied by setup.py, requirements.txt) → Deployment on Render/Heroku

##### Architectural patterns and design principles
- MVC-like separation:
– View: HTML templates
– Controller: Flask routes (app.py)
– Model: scikit-learn pipeline objects (preprocessor & classifier)
- Pipeline pattern for data processing and model training/inference
- Modular code organization (src/components vs. src/pipeline vs. src/utils)
- Single responsibility: each component handles one stage (ingestion, transformation, training, prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Production (Prediction Flow)
    subgraph "Production (Prediction Flow)"
        direction TB
        Browser["Browser / Client"]:::frontend
        HomeTemplate["home.html"]:::frontend
        IndexTemplate["index.html"]:::frontend
        WSGI["WSGI Server (Gunicorn)"]:::backend
        FlaskApp["Flask App (app.py)"]:::backend
        PredictPipeline["PredictPipeline\n(src/pipeline/predict_pipeline.py)"]:::ml
        DataIngestion["DataIngestion\n(src/components/data_ingestion.py)"]:::ml
        DataTransformation["DataTransformation\n(src/components/data_transformation.py)"]:::ml
        ModelTrainer["ModelTrainer\n(src/components/model_trainer.py)"]:::ml
        CSVFiles["Raw CSVs\n(data.csv, train.csv, test.csv)"]:::storage
        Preprocessor["preprocessor.pkl"]:::storage
        ModelPkl["model.pkl"]:::storage

        Browser -->|GET| HomeTemplate
        Browser -->|GET| IndexTemplate
        Browser -->|HTTP POST| WSGI
        WSGI -->|forward request| FlaskApp
        FlaskApp -->|"invoke"| PredictPipeline
        PredictPipeline --> DataIngestion
        DataIngestion --> DataTransformation
        DataTransformation --> ModelTrainer
        ModelTrainer -->|loads model| ModelPkl
        ModelTrainer -->|loads preprocessor| Preprocessor
        ModelTrainer -->|returns result| FlaskApp
        FlaskApp -->|HTTP response| Browser
    end

    %% Development (Training & EDA)
    subgraph "Development (Training & EDA)"
        direction TB
        TrainPipeline["TrainPipeline\n(src/pipeline/train_pipeline.py)"]:::ml
        DataIngestion2["DataIngestion\n(src/components/data_ingestion.py)"]:::ml
        DataTransformation2["DataTransformation\n(src/components/data_transformation.py)"]:::ml
        ModelTrainer2["ModelTrainer\n(src/components/model_trainer.py)"]:::ml
        CSVFiles2["Raw CSVs\n(data.csv, train.csv, test.csv)"]:::storage
        Preprocessor2["preprocessor.pkl"]:::storage
        ModelPkl2["model.pkl"]:::storage
        EDA["1. EDA MUSHROOMS CLASSIFICATION.ipynb"]:::dev
        TrainingNB["2. MODEL TRAINING.ipynb"]:::dev
        VirtualEnv["new_env/"]:::dev
        SetupPy["setup.py"]:::dev
        ReqTxt["requirements.txt"]:::dev
        RuntimeTxt["runtime.txt"]:::dev
        Utils["src/utils.py"]:::util
        Exception["src/exception.py"]:::util
        Logger["src/logger.py"]:::util
        Deployment["Render / Heroku"]:::dev

        TrainPipeline -->|reads| CSVFiles2
        TrainPipeline --> DataIngestion2
        DataIngestion2 --> DataTransformation2
        DataTransformation2 --> ModelTrainer2
        ModelTrainer2 -->|saves| Preprocessor2
        ModelTrainer2 -->|saves| ModelPkl2
        EDA -->|explores| CSVFiles2
        TrainingNB -->|runs| TrainPipeline
        VirtualEnv -->|env for| EDA
        VirtualEnv -->|env for| TrainingNB
        SetupPy -->|defines| VirtualEnv
        ReqTxt -->|defines| VirtualEnv
        RuntimeTxt -->|defines| VirtualEnv
        Utils -->|supports| TrainPipeline
        Exception -->|supports| FlaskApp
        Logger -->|supports| TrainPipeline
        Logger -->|supports| FlaskApp
        Deployment -->|deploys| FlaskApp
        Deployment -->|deploys| WSGI
    end

    %% Click Events
    click HomeTemplate "https://github.com/tak-praveen/mushrooms-classification/blob/main/templates/home.html"
    click IndexTemplate "https://github.com/tak-praveen/mushrooms-classification/blob/main/templates/index.html"
    click FlaskApp "https://github.com/tak-praveen/mushrooms-classification/blob/main/app.py"
    click PredictPipeline "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/pipeline/predict_pipeline.py"
    click DataIngestion "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/components/data_ingestion.py"
    click DataTransformation "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/components/data_transformation.py"
    click ModelTrainer "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/components/model_trainer.py"
    click TrainPipeline "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/pipeline/train_pipeline.py"
    click EDA "https://github.com/tak-praveen/mushrooms-classification/blob/main/notebook/1. EDA MUSHROOMS CLASSIFICATION.ipynb"
    click TrainingNB "https://github.com/tak-praveen/mushrooms-classification/blob/main/notebook/2. MODEL TRAINING.ipynb"
    click VirtualEnv "https://github.com/tak-praveen/mushrooms-classification/tree/main/new_env/"
    click SetupPy "https://github.com/tak-praveen/mushrooms-classification/blob/main/setup.py"
    click ReqTxt "https://github.com/tak-praveen/mushrooms-classification/blob/main/requirements.txt"
    click RuntimeTxt "https://github.com/tak-praveen/mushrooms-classification/blob/main/runtime.txt"
    click Utils "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/utils.py"
    click Exception "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/exception.py"
    click Logger "https://github.com/tak-praveen/mushrooms-classification/blob/main/src/logger.py"
    click CSVFiles "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/data.csv"
    click Preprocessor "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/preprocessor.pkl"
    click ModelPkl "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/model.pkl"
    click CSVFiles2 "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/data.csv"
    click Preprocessor2 "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/preprocessor.pkl"
    click ModelPkl2 "https://github.com/tak-praveen/mushrooms-classification/blob/main/artifacts/model.pkl"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef ml fill:#FFF3E0,stroke:#E65100,color:#E65100
    classDef storage fill:#FFFDE7,stroke:#F9A825,color:#F9A825
    classDef dev fill:#ECEFF1,stroke:#37474F,color:#37474F
    classDef util fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
```
