# vedantkadam/lung_cancer_streamlit architecture

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

- Interactive diagram: https://gitdiagram.com/vedantkadam/lung_cancer_streamlit
- Repository: https://github.com/vedantkadam/lung_cancer_streamlit

## Overview

##### Project Overview
- This is a machine learning and computer vision application aimed at detecting lung cancer from medical images (X-rays, CT scans).
- The project uses Python and leverages frameworks such as Streamlit for the user interface, along with TensorFlow/Keras for deep learning (notably CNNs).

##### Main Components
a. User Interface & Application Layer:
- The entry point is app.py which runs the Streamlit application.

b. Machine Learning / Model Components:
- Two separate directories indicate model artifacts: "cnn model" (with labels.txt, lungcancer_model_cnn.h5) and "models" (with final_model.sav and keras_model.h5).
- These represent the trained model files (possibly for different experiments/approaches) that are loaded by the backend for prediction.
- That these are likely used by the application via TensorFlow/Keras or other Python libraries.

c. Data & Dataset Management:
- "datasets" contains CSV files for training and testing data, which suggests the models have been trained and validated on structured datasets.
- "ctscan_images" (with train/test splits and further folder categorization e.g., normal vs. large.cell.carcinoma) shows how the image data is organized.

d. Experimentation & Development Notebooks:
- The "pynb files" directory contains Jupyter notebooks used for developing and testing different algorithms (like the CNN and SVM models).
- This component can be shown as a “Development/Experimentation” environment that influenced the finalized model selections.

e. Supporting Files & Documentation:
- Files like requirements.txt and README explain the dependencies and instructions.
- While not part of the runtime, these support the maintainability and reproducibility (deployment) of the system.

##### Relationships and Interactions
- That the models (whether CNN from “cnn model” or other final models in “models”) rely on pre-processed data (images, CSV dataset entries) and were developed in an iterative process (referencing “pynb files”).
- Flow:
- User Input (via Streamlit) → Image Preprocessing (if any in app.py) → Model Prediction (CNN/Keras models) → Output/Visualization (back into the UI).
- Additionally, include references for dataset management, where the datasets fed into training form the backbone of model accuracy.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clear segmentation between the presentation layer (Streamlit UI), the business logic/model inference layer (loading and running models), and data handling (organized datasets and image directories).
- Modularity: The presence of different directories for model artifacts, datasets, and notebooks indicates a modular setup where model training, testing, and deployment are relatively decoupled.
- Experimentation Lifecycle: Notebooks (pynb files) contain the iterative experiments which eventually influence the production models in “models” and “cnn model” directories.

##### Final Reminders
- Use clear, readable labels for every component.
- Aim for a high level of detail that distinguishes experimental components (notebooks) from production usage (app.py and deployed models).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level UI
    UI["Streamlit UI (app.py)"]:::ui

    %% ML Models Subgraph
    subgraph "ML Models"
      direction TB
      CNN["CNN Model Artifacts (cnn model)"]:::ml
      OML["Other ML Model Artifacts (models)"]:::ml
    end

    %% Data Sources Subgraph
    subgraph "Data Sources"
      direction TB
      IMG["Image Data Repository (ctscan_images)"]:::data
      CSV["Dataset CSV Files (datasets)"]:::data
    end

    %% Development/Experimentation Node
    DEV["Development Notebooks (pynb files)"]:::dev

    %% Supporting Documentation Subgraph
    subgraph "Supporting Documentation"
      direction TB
      DOC1["README.md"]:::doc
      DOC2["requirements.txt"]:::doc
    end

    %% Connections from UI to ML Models (Prediction Request)
    UI -->|"image_input"| CNN
    UI -->|"image_input"| OML

    %% ML Models return prediction to UI
    CNN -->|"prediction_result"| UI
    OML -->|"prediction_result"| UI

    %% Data Sources provide training and support data to ML Models
    IMG -->|"training_data"| CNN
    IMG -->|"training_data"| OML
    CSV -->|"training_data"| CNN
    CSV -->|"training_data"| OML

    %% Development Notebooks influence ML Model development
    DEV -->|"experimentation"| CNN
    DEV -->|"experimentation"| OML

    %% Supporting Documentation aids UI and general project understanding
    DOC1 -->|"documentation"| UI
    DOC2 -->|"dependencies"| UI

    %% Click Events
    click UI "https://github.com/vedantkadam/lung_cancer_streamlit/blob/main/app.py"
    click CNN "https://github.com/vedantkadam/lung_cancer_streamlit/tree/main/cnn model"
    click OML "https://github.com/vedantkadam/lung_cancer_streamlit/tree/main/models"
    click IMG "https://github.com/vedantkadam/lung_cancer_streamlit/tree/main/ctscan_images"
    click CSV "https://github.com/vedantkadam/lung_cancer_streamlit/tree/main/datasets"
    click DEV "https://github.com/vedantkadam/lung_cancer_streamlit/tree/main/pynb files"
    click DOC1 "https://github.com/vedantkadam/lung_cancer_streamlit/blob/main/README.md"
    click DOC2 "https://github.com/vedantkadam/lung_cancer_streamlit/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#a2d5f2,stroke:#333,stroke-width:2px;
    classDef ml fill:#baffc9,stroke:#333,stroke-width:2px;
    classDef data fill:#ffecb3,stroke:#333,stroke-width:2px;
    classDef dev fill:#ffccd5,stroke:#333,stroke-width:2px;
    classDef doc fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
