# charanhu/skin_cancer_detection_mnist architecture

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

- Interactive diagram: https://gitdiagram.com/charanhu/skin_cancer_detection_mnist
- Repository: https://github.com/charanhu/skin_cancer_detection_mnist

## Overview

##### Main Components
- Client/User Interface – Represented by the HTML templates (home.html and results.html). The user interacts with the web page through a browser.
- Web Application Backend – The Flask app (app.py) serves as the controller that accepts user uploads, processes requests, and returns responses. The wsgi.py file indicates readiness for deployment (e.g., via Gunicorn on platforms like Heroku or Azure).
- CNN Model Module – The skin_cancer_detection.py file contains the CNN model definition while best_model.h5 holds the pretrained weights. This module is responsible for prediction logic.
- Training & Experimentation – Although not part of the deployed service, the notebooks (Skin_Cancer_Detection.ipynb and its copy) illustrate model training and experimentation.
- Supporting Components – Configuration files such as requirements.txt (identifying dependencies), LICENSE, Procfile to indicate deployment-specific information, and potentially deployment services (Heroku/Azure) described in the README.

##### Relationships and Interactions
- The client (browser) sends an image upload via the web form.
- The Flask backend (app.py) receives the image, delegates the image processing and classification task to the CNN model defined in skin_cancer_detection.py.
- The CNN module loads the best_model.h5 weights to perform prediction on the uploaded image.
- After processing, the result is fed back to the Flask app, which renders the appropriate HTML template (results page) to display the output.
- In a live deployment scenario, the wsgi.py (with Gunicorn as mentioned in requirements) interfaces with the production server to handle incoming requests.

##### Architectural Patterns and Design Principles
- MVC/MVT-like Separation – Although simplified, the separation of concerns is clear: the view (templates) displays the information, the controller (Flask app) routes and processes user requests, and the model (CNN module + weights) does the heavy lifting.
- Modularity and Reusability – The training aspect (notebooks) is decoupled from the production inference (Flask app using pre-trained model), making it easier to update models without disrupting the service.
- Scalability for Deployment – The inclusion of configuration files (Procfile, wsgi.py) and the use of Gunicorn indicate an architecture that can scale on platforms like Heroku or Azure.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F1["User (Browser)"]:::frontend
        F2["Home Template (home.html)"]:::frontend
        F3["Results Template (reults.html)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1["Flask App (app.py)"]:::backend
        B2["WSGI Interface (wsgi.py)"]:::backend
    end

    %% Model Layer
    subgraph "Model Layer"
        M1["CNN Model (skin_cancer_detection.py)"]:::model
        M2["Pretrained Weights (best_model.h5)"]:::model
    end

    %% Training Environment
    subgraph "Training Environment"
        T1["Notebook (Skin_Cancer_Detection.ipynb)"]:::training
        T2["Notebook (Skin_Cancer_Detection copy.ipynb)"]:::training
    end

    %% Supporting Components
    subgraph "Supporting Components"
        S1["LICENSE"]:::support
        S2["Procfile"]:::support
        S3["README.md"]:::support
        S4["requirements.txt"]:::support
    end

    %% Deployment Environment
    subgraph "Deployment"
        D1["External Deployment (Heroku/Azure)"]:::external
    end

    %% Connections
    F1 -->|"ImageUpload"| B1
    B1 -->|"ForwardRequest"| B2
    B1 -->|"PredictionRequest"| M1
    M1 -->|"LoadWeights"| M2
    M1 -->|"PredictionOutput"| B1
    B1 -->|"RenderResults"| F3
    B2 -->|"DeployInterface"| D1

    %% Click Events
    click F2 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/templates/home.html"
    click F3 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/templates/reults.html"
    click B1 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/app.py"
    click B2 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/wsgi.py"
    click M1 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/skin_cancer_detection.py"
    click M2 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/best_model.h5"
    click T1 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/Skin_Cancer_Detection.ipynb"
    click T2 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/Skin_Cancer_Detection copy.ipynb"
    click S1 "https://github.com/charanhu/skin_cancer_detection_mnist/tree/main/LICENSE"
    click S2 "https://github.com/charanhu/skin_cancer_detection_mnist/tree/main/Procfile"
    click S3 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/README.md"
    click S4 "https://github.com/charanhu/skin_cancer_detection_mnist/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef model fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef training fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef support fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
