# lokesh89414/eye-disease-detection architecture

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

- Interactive diagram: https://gitdiagram.com/lokesh89414/eye-disease-detection
- Repository: https://github.com/lokesh89414/eye-disease-detection

## Overview

##### Project type and purpose
- This is a static AI-powered web application that runs entirely in the browser.
- Purpose: Let users upload retinal images and get real-time eye disease predictions (Diabetic Retinopathy, Glaucoma, Cataracts) using a CNN model via TensorFlow.js.

##### File structure
Top-level files:
- index.html, prediction.html, about-disease.html – entry points for landing, prediction UI, and info pages
- script.js – client-side logic (loads model, runs inference, generates report)
- style.css – UI styling
- model.json, weights.bin, labels.txt, metadata.json – TensorFlow.js model artifacts and labels
- keras_model.h5, training.ipynb – offline training assets
- requirements.txt – Python dependencies for training (TensorFlow, NumPy, Pillow, OpenCV)
No backend folder—serving happens via a static file server (e.g., python -m http.server).

##### Extract insights from README
- Frontend: HTML5/CSS3/ES6 JavaScript
- AI: TensorFlow.js & Teachable Machine for in-browser inference
- Offline training: Jupyter notebook with Keras, export to TF.js format
- Features: real-time analysis, confidence scores, PDF report export, mobile-responsive UI

a. Main components
1. User Browser (Client)
2. Static Web Host (serves HTML/CSS/JS & model files)
3. TensorFlow.js Inference Engine (runs the CNN in-browser)
4. Model Artifacts Storage (model.json, weights.bin, labels.txt)
5. Offline Training Pipeline
– Data Source (retinal image dataset)
– Preprocessing (OpenCV/Pillow)
– Model Training Environment (Jupyter + Keras)
– Model Conversion (to TF.js)
6. PDF Report Generator (client-side JS or library)

b. Relationships & data flows
- Within Browser: script.js loads model.json via TensorFlow.js → processes uploaded image → outputs predictions → passes results to PDF generator & UI renderer
- Offline Pipeline separate: dataset → preprocessing → Keras training → export to model.json/weights.bin → upload to Static Web Host

c. Architectural patterns & principles
- Client-side ML inference (edge inference)
- Separation of concerns:
- Static content hosting vs
- Offline training pipeline
- Single-page or multi-page static app with modular JS
- Model artifact versioning via metadata.json

d. Key technologies & libraries
- HTML5, CSS3, JavaScript (ES6+)
- TensorFlow.js, Teachable Machine
- Python (TensorFlow/Keras), NumPy, Pillow, OpenCV (offline)
- Data visualization (Plotly/Matplotlib in notebook)
- PDF export library (e.g., jsPDF)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client-side Inference
    subgraph "Client-side Inference"
        direction TB
        Browser["User Browser (Client)"]:::inference
        Script["script.js"]:::inference
        Style["style.css"]:::inference
        PDF["PDF Report Generator"]:::inference
        Browser -->|"loads UI logic"| Script
        Browser -->|"loads styles"| Style
        Script -->|"generates report"| PDF
    end

    %% Static Hosting & Model Artifacts
    subgraph "Static Web Host"
        direction TB
        Host["Static Web Host"]:::host
        subgraph "Model Artifacts Storage"
            direction TB
            ModelJSON["model.json"]:::storage
            Weights["weights.bin"]:::storage
            Labels["labels.txt"]:::storage
            Metadata["metadata.json"]:::storage
        end
        Host -->|"serves pages & assets"| Browser
        Host -->|"serves model artifacts"| Script
    end

    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        direction TB
        DataSource["Retinal Image Dataset"]:::training
        Preprocessing["Preprocessing (OpenCV/Pillow)"]:::training
        TrainingEnv["Model Training Environment"]:::training
        Conversion["Model Conversion (to TF.js)"]:::training
        DataSource --> Preprocessing
        Preprocessing --> TrainingEnv
        TrainingEnv --> Conversion
        Conversion -->|"outputs model.json & weights.bin"| Host
    end

    %% Click Events
    click Browser "https://github.com/lokesh89414/eye-disease-detection/blob/main/index.html"
    click Script "https://github.com/lokesh89414/eye-disease-detection/blob/main/script.js"
    click Style "https://github.com/lokesh89414/eye-disease-detection/blob/main/style.css"
    click ModelJSON "https://github.com/lokesh89414/eye-disease-detection/blob/main/model.json"
    click Weights "https://github.com/lokesh89414/eye-disease-detection/blob/main/weights.bin"
    click Labels "https://github.com/lokesh89414/eye-disease-detection/blob/main/labels.txt"
    click Metadata "https://github.com/lokesh89414/eye-disease-detection/blob/main/metadata.json"
    click Browser "https://github.com/lokesh89414/eye-disease-detection/blob/main/prediction.html"
    click Browser "https://github.com/lokesh89414/eye-disease-detection/blob/main/about-disease.html"
    click TrainingEnv "https://github.com/lokesh89414/eye-disease-detection/blob/main/training.ipynb"
    click TrainingEnv "https://github.com/lokesh89414/eye-disease-detection/blob/main/requirements.txt"
    click TrainingEnv "https://github.com/lokesh89414/eye-disease-detection/blob/main/keras_model.h5"

    %% Styles
    classDef inference fill:#ADD8E6,stroke:#333,color:#000;
    classDef storage fill:#FFA500,stroke:#333,color:#000;
    classDef training fill:#90EE90,stroke:#333,color:#000;
    classDef host fill:#f0f0f0,stroke:#333,color:#000;
```
