# prem-buraga/diabetic-retinopathy architecture

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

- Interactive diagram: https://gitdiagram.com/prem-buraga/diabetic-retinopathy
- Repository: https://github.com/prem-buraga/diabetic-retinopathy

## Overview

##### Main Components
- Frontend Application: Represented by app.py and the two HTML templates (index.html and result.html) which facilitate image uploads and display results.
- Deep Learning Model: Include the trained model file (Model.h5) and testing script (Model_Test.py) which encapsulate the core image classification logic.
- Data Processing & Analysis: Depicted by the exploratory notebook (dv_project.ipynb) which is used for EDA and data preprocessing steps.

##### Relationships and Interactions
- The Frontend interacts with the Backend: When a user uploads a retinal image via the Flask web interface, app.py routes the image to the backend.
- The Flask app then loads the deep learning model (Model.h5) and performs inference using the logic that is tested in Model_Test.py.
- Results from the model inference are then passed back to the frontend to be displayed in result.html.
- The exploratory analysis and preprocessing (from dv_project.ipynb) inform the model training, and although they may not be part of the live system, they are essential for understanding model development and performance.
- The dataset acts as an input for both training (not detailed in the deployment) and for potential updates to the model.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Distinct layers for the user interface (templates and Flask routes) and the model inference logic (deep learning model and associated scripts).
- Modularity: Identify the discrete modules—frontend web server, model inference, data preprocessing—that interact through well-defined interfaces (e.g., the HTTP request/response cycle for the web app).
- Reusability and Extensibility: By isolating model testing (Model_Test.py) and EDA (dv_project.ipynb), the system can be extended or updated independently without affecting the deployed web app.

- Python/Flask: For the web server and frontend application (app.py).
- Deep Learning Framework (e.g., TensorFlow/Keras): Implied by the Model.h5 file and the custom DCNN/AlexNet architectures.
- HTML Templates: For rendering the user interface.
- Jupyter Notebook: For EDA and exploring the dataset (dv_project.ipynb).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Node
    USER["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        INDEX["Index Template (index.html)"]:::frontend
        FWS["Flask Web Server (app.py)"]:::frontend
        RESULT["Result Template (result.html)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        subgraph "Deep Learning Model"
            ML["Model File (Model.h5)"]:::backend
            MT["Test Script (Model_Test.py)"]:::backend
        end
        EDA["EDA Notebook (dv_project.ipynb)"]:::notebook
    end

    %% External Data Source
    DATA["Kaggle Dataset"]:::external

    %% Connections - Frontend Flow
    USER -->|"Access"| INDEX
    INDEX -->|"Submits_image"| FWS
    FWS -->|"Calls_inference"| ML
    ML -->|"Returns_prediction"| FWS
    FWS -->|"Renders_using"| RESULT

    %% Connections - Backend and Data Processing
    MT -->|"Verifies_model"| ML
    EDA -->|"Informs_training"| ML
    DATA -->|"Provides_raw_data"| EDA

    %% Click Events
    click FWS "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/app.py"
    click INDEX "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/templates/index.html"
    click RESULT "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/templates/result.html"
    click ML "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/Model.h5"
    click MT "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/Model_Test.py"
    click EDA "https://github.com/prem-buraga/diabetic-retinopathy/blob/main/dv_project.ipynb"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef notebook fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5CBA7,stroke:#943126,stroke-width:2px;
```
