# asur12zurvan/home-eyecare architecture

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

- Interactive diagram: https://gitdiagram.com/asur12zurvan/home-eyecare
- Repository: https://github.com/asur12zurvan/home-eyecare

## Overview

##### Project type and purpose
- This is a full-stack web application built with Django (Python).
- It hosts an eye-test/vision-readability ML model (in `Integ/MLmodel/model.py` and `model.py`), serves HTML pages, accepts user input, runs inference, and returns results.

##### File structure
Top-level
- Jupyter notebooks: `EYE-TEST.ipynb` (exploratory work)
- `Machine.py`, `model.py`, `tempCodeRunnerFile.py`: standalone scripts or ML prototypes
- CSV files: raw data for training/inference
- `Integ/`: Django project root
Inside `Integ/`
- `manage.py`: Django CLI entry point
- `db.sqlite3`: SQLite database storing user sessions or results
- `requirements.txt`: Python dependencies
- `static/` & `staticfiles/`: CSS, JS, CSV assets served to clients
- `templates/`: Django HTML templates (index, about, result pages)
- `Integ/`: Django settings, URLs, WSGI/ASGI application
- `MLmodel/`: Django app containing models.py (ORM), views.py (controllers), urls.py (routing), and an ML wrapper in `model.py`.

##### README insights
- Currently generic; no architecture details. We infer architecture from file structure and Django conventions.

a. Main components
- Client Browser (Web UI)
- Django Web Server
– URL Router (`Integ/urls.py`, `MLmodel/urls.py`)
– Views/Controllers (`MLmodel/views.py`)
– Templates Engine (`templates/*.html`)
- Static Asset Server (`static/`, `staticfiles/`)
- Database (SQLite: `db.sqlite3`)
- ML Inference Layer
– ML model loader (`MLmodel/model.py` or root `model.py`)
– Data preprocessing (CSV files, Pandas)
b. Relationships & interactions
1. User submits a request (e.g., diopter value) via HTML form → HTTP POST to Django URL.
2. URL Router dispatches to appropriate view function in `MLmodel/views.py`.
3. View loads/preprocesses input, calls ML Inference Layer to compute results.
4. Optionally logs input/result to SQLite via Django ORM (`MLmodel/models.py`).
5. View renders a template (`diopter_result.html`) with prediction and returns HTML response.
6. Client displays results; static assets (CSS/JS) are served either by Django or a CDN.
c. Architectural patterns & principles
- Django’s Model-View-Template (MVT) pattern
- Single monolithic service (no microservices)
- Separation of concerns:
- Models handle DB schema
- Views contain controller logic & ML calls
- Templates render UI
- Static folder for assets
- Lightweight, file-based persistence (SQLite) for prototyping
d. Key technologies/frameworks/libraries
- Python 3.x, Django
- SQLite3 (default Django DB)
- Pandas/NumPy (data loading from CSVs)
- scikit-learn or custom ML code (in `model.py`)
- HTML/CSS for front-end templates

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Client Browser"
        direction TB
        Browser(["Browser"]):::client
    end

    subgraph "Frontend Assets"
        direction TB
        Templates["HTML Templates"]:::template
        StaticAssets["Static Assets (CSS/JS)"]:::static
    end

    %% Backend Layer
    subgraph "Django Application"
        direction TB
        subgraph "Entry Points"
            direction TB
            WSGI["WSGI Entry Point"]:::core
            ASGI["ASGI Entry Point"]:::core
            click WSGI "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/Integ/wsgi.py"
            click ASGI "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/Integ/asgi.py"
        end

        subgraph "Settings & Routing"
            direction TB
            Settings["Project Settings"]:::core
            ProjectURLs["Project URL Router"]:::core
            MLAppURLs["MLmodel App URL Router"]:::core
            click Settings "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/Integ/settings.py"
            click ProjectURLs "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/Integ/urls.py"
            click MLAppURLs "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/MLmodel/urls.py"
        end

        subgraph "Controller & Logic"
            direction TB
            Views["View/Controller Logic"]:::core
            click Views "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/MLmodel/views.py"
        end

        subgraph "Data Layer"
            direction TB
            ORM["Django ORM Models"]:::core
            DB[(SQLite Database)]:::db
            click ORM "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/MLmodel/models.py"
            click DB "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/db.sqlite3"
        end

        subgraph "ML Inference Layer"
            direction TB
            MLModel["ML Inference Module"]:::ml
            click MLModel "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/MLmodel/model.py"
            CSVApp["CSV Data (App)"]:::data
            click CSVApp "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/MLmodel/diopter_data_combined2.csv"
            CSVStatic["CSV Data (Static)"]:::data
            click CSVStatic "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/static/diopter_data_combined.csv"
        end
    end

    %% Prototype Scripts
    subgraph "Prototypes"
        direction TB
        RootModel["Standalone ML Prototype"]:::ml
        Prototyping["Prototyping Script"]:::ml
        click RootModel "https://github.com/asur12zurvan/home-eyecare/blob/main/model.py"
        click Prototyping "https://github.com/asur12zurvan/home-eyecare/blob/main/Machine.py"
    end

    %% Staticfiles
    StaticFiles["Collected Static Files"]:::static
    click StaticFiles "https://github.com/asur12zurvan/home-eyecare/tree/main/Integ/staticfiles/"

    %% Django CLI
    CLI["Django Management CLI"]:::core
    click CLI "https://github.com/asur12zurvan/home-eyecare/blob/main/Integ/manage.py"

    %% Browser to Backend interactions
    Browser -->|"HTTP GET/POST"| WSGI
    Browser -->|"HTTP GET/POST"| ASGI
    WSGI --> ProjectURLs
    ASGI --> ProjectURLs
    ProjectURLs --> MLAppURLs
    MLAppURLs --> Views
    Views --> ORM
    ORM --> DB
    Views --> MLModel
    MLModel --> CSVApp
    MLModel --> CSVStatic
    Views --> Templates
    Browser --> Templates
    Browser --> StaticAssets
    Browser --> StaticFiles

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef template fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef static fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef db fill:#98FB98,stroke:#333,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
```
