# mdzaheerjk/chest-disease-identification architecture

> Architecture diagram of the GitHub repository mdzaheerjk/chest-disease-identification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mdzaheerjk/chest-disease-identification
- Repository: https://github.com/mdzaheerjk/chest-disease-identification

## Overview

Chest-Disease-Identification is a CNN-based CT-scan classifier with a web interface and an offline training/evaluation lifecycle. Users submit an image through the web app, which invokes the prediction pipeline and returns a Normal or Adenocarcinoma Cancer label. Training is initiated through the app or main entry point and is organized into ingestion, model preparation, training, and evaluation stages. Source excerpts show ingestion, training, evaluation, configuration, and prediction details; preparation-stage internals and some stage wiring are represented only where supported by the tree or documented workflow.

Main entry points: [`main.py`](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/main.py) (Training entry point), [`src/cnnClassifier/components/model_evaluation_mlflow.py`](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/model_evaluation_mlflow.py) (Model evaluation), [`app.py`](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/app.py) (Flask routes), [`src/cnnClassifier/pipeline/prediction.py`](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/prediction.py) (Prediction pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_page["Web page<br/>[index.html]"]
end

subgraph group_inference["Inference"]
  node_prediction["Prediction pipeline<br/>[prediction.py]"]
  node_trainedmodel["Trained model<br/>[model.h5]"]
  node_fallbackmodel["Fallback model<br/>[model.h5]"]
  node_label["Class label"]
end

subgraph group_training["Training lifecycle"]
  node_main["Training entry point<br/>[main.py]"]
  node_ingeststage["Data ingestion stage"]
  node_ingest["Download and extract<br/>[data_ingestion.py]"]
  node_dataset["Extracted CT scans"]
  node_preparestage["Base model stage"]
  node_basecomponent["Base model preparation"]
  node_basemodel["Prepared base model"]
  node_trainstage["Training stage"]
  node_trainer["Model trainer<br/>[model_trainer.py]"]
  node_evalstage["Evaluation stage"]
  node_evaluator["Model evaluation"]
  node_scores["Evaluation scores<br/>[scores.json]"]
end

subgraph group_support["Configuration and tracking"]
  node_configmanager["Configuration manager<br/>[configuration.py]"]
  node_configfiles["YAML configuration<br/>[config.yaml]"]
  node_params["Model parameters<br/>[params.yaml]"]
  node_mlflow["MLflow tracking"]
end

node_user(("User"))
node_datasource(("Dataset source"))

node_user -->|"submits scan"| node_webapp
node_webapp -->|"renders"| node_page
node_webapp -->|"calls"| node_prediction
node_prediction -->|"loads first"| node_trainedmodel
node_prediction -->|"loads if missing"| node_fallbackmodel
node_prediction -->|"returns class"| node_label
node_user -.->|"requests training"| node_webapp
node_webapp -.->|"runs"| node_main
node_main -->|"calls"| node_ingeststage
node_main -->|"calls"| node_preparestage
node_main -->|"calls"| node_trainstage
node_main -->|"calls"| node_evalstage
node_ingeststage -->|"gets settings"| node_configmanager
node_ingeststage -->|"calls"| node_ingest
node_ingest -->|"downloads from"| node_datasource
node_ingest -->|"extracts to"| node_dataset
node_preparestage --> node_basecomponent
node_trainstage --> node_trainer
node_trainer -->|"reads scans"| node_dataset
node_trainer -->|"loads"| node_basemodel
node_trainer -->|"saves"| node_trainedmodel
node_evalstage --> node_evaluator
node_evaluator -->|"loads"| node_trainedmodel
node_evaluator -->|"evaluates scans"| node_dataset
node_evaluator -->|"writes"| node_scores
node_evaluator -.->|"logs run"| node_mlflow
node_configmanager -->|"reads"| node_configfiles
node_configmanager -->|"reads"| node_params

click node_webapp "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/app.py"
click node_page "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/templates/index.html"
click node_prediction "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/prediction.py"
click node_trainedmodel "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/artifacts/training/model.h5"
click node_fallbackmodel "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/model/model.h5"
click node_main "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/main.py"
click node_ingeststage "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_01_data_ingestion.py"
click node_ingest "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/data_ingestion.py"
click node_dataset "https://github.com/mdzaheerjk/chest-disease-identification/tree/main/artifacts/data_ingestion/Chest-CT-Scan-data"
click node_preparestage "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_02_prepare_base_model.py"
click node_basecomponent "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/prepare_base_model.py"
click node_basemodel "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/artifacts/prepare_base_model/base_model_updated.h5"
click node_trainstage "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_03_model_trainer.py"
click node_trainer "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/model_trainer.py"
click node_evalstage "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_04_model_evaluation.py"
click node_evaluator "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/model_evaluation_mlflow.py"
click node_scores "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/scores.json"
click node_configmanager "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/config/configuration.py"
click node_configfiles "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/config/config.yaml"
click node_params "https://github.com/mdzaheerjk/chest-disease-identification/blob/main/params.yaml"

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_webapp,node_page,node_user toneBlue
class node_prediction,node_trainedmodel,node_fallbackmodel,node_label toneAmber
class node_main,node_ingeststage,node_ingest,node_dataset,node_preparestage,node_basecomponent,node_basemodel,node_trainstage,node_trainer,node_evalstage,node_evaluator,node_scores toneMint
class node_configmanager,node_configfiles,node_params,node_mlflow toneRose
class node_datasource toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/app.py): `app.py`
- [Web page](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/templates/index.html): `templates/index.html`

### Inference

- [Prediction pipeline](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/prediction.py): `src/cnnClassifier/pipeline/prediction.py`
- [Trained model](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/artifacts/training/model.h5): `artifacts/training/model.h5`
- [Fallback model](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/model/model.h5): `model/model.h5`
- **Class label**

### Training lifecycle

- [Training entry point](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/main.py): `main.py`
- [Data ingestion stage](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_01_data_ingestion.py): `src/cnnClassifier/pipeline/stage_01_data_ingestion.py`
- [Download and extract](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/data_ingestion.py): `src/cnnClassifier/components/data_ingestion.py`
- [Extracted CT scans](https://github.com/mdzaheerjk/chest-disease-identification/tree/main/artifacts/data_ingestion/Chest-CT-Scan-data): `artifacts/data_ingestion/Chest-CT-Scan-data`
- [Base model stage](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_02_prepare_base_model.py): `src/cnnClassifier/pipeline/stage_02_prepare_base_model.py`
- [Base model preparation](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/prepare_base_model.py): `src/cnnClassifier/components/prepare_base_model.py`
- [Prepared base model](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/artifacts/prepare_base_model/base_model_updated.h5): `artifacts/prepare_base_model/base_model_updated.h5`
- [Training stage](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_03_model_trainer.py): `src/cnnClassifier/pipeline/stage_03_model_trainer.py`
- [Model trainer](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/model_trainer.py): `src/cnnClassifier/components/model_trainer.py`
- [Evaluation stage](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/pipeline/stage_04_model_evaluation.py): `src/cnnClassifier/pipeline/stage_04_model_evaluation.py`
- [Model evaluation](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/components/model_evaluation_mlflow.py): `src/cnnClassifier/components/model_evaluation_mlflow.py`
- [Evaluation scores](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/scores.json): `scores.json`

### Configuration and tracking

- [Configuration manager](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/src/cnnClassifier/config/configuration.py): `src/cnnClassifier/config/configuration.py`
- [YAML configuration](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/config/config.yaml): `config/config.yaml`
- [Model parameters](https://github.com/mdzaheerjk/chest-disease-identification/blob/main/params.yaml): `params.yaml`
- **MLflow tracking**

### Other components

- **User**
- **Dataset source**

## Connections

- User → Flask routes: submits scan
- Flask routes → Web page: renders
- Flask routes → Prediction pipeline: calls
- Prediction pipeline → Trained model: loads first
- Prediction pipeline → Fallback model: loads if missing
- Prediction pipeline → Class label: returns class
- User → Flask routes: requests training
- Flask routes → Training entry point: runs
- Training entry point → Data ingestion stage: calls
- Training entry point → Base model stage: calls
- Training entry point → Training stage: calls
- Training entry point → Evaluation stage: calls
- Data ingestion stage → Configuration manager: gets settings
- Data ingestion stage → Download and extract: calls
- Download and extract → Dataset source: downloads from
- Download and extract → Extracted CT scans: extracts to
- Base model stage → Base model preparation
- Training stage → Model trainer
- Model trainer → Extracted CT scans: reads scans
- Model trainer → Prepared base model: loads
- Model trainer → Trained model: saves
- Evaluation stage → Model evaluation
- Model evaluation → Trained model: loads
- Model evaluation → Extracted CT scans: evaluates scans
- Model evaluation → Evaluation scores: writes
- Model evaluation → MLflow tracking: logs run
- Configuration manager → YAML configuration: reads
- Configuration manager → Model parameters: reads
