# yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans architecture

> Architecture diagram of the GitHub repository yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans
- Repository: https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans

## Overview

This is a Flask web app for Alzheimer’s screening from MRI images, backed by a VAE and latent classifier. Users register or log in, upload an image, pass file and brain-image checks, receive a prediction if confidence is sufficient, and see the result; prediction records are saved to MongoDB. A separate training workflow fits the VAE and classifier. The README gives only a high-level product description; relationships below are based on the shown source excerpts, not unsampled templates or styles.

Main entry points: [`app.py`](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py) (Web routes), [`train.py`](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/train.py) (Training workflow), [`config.py`](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/config.py) (Database access), [`model.py`](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/model.py) (VAE encoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflow"]
  node_web_routes["Web routes<br/>[app.py]"]
  node_auth_views["Auth view<br/>[auth.html]"]
  node_dashboard_view["Dashboard<br/>[dashboard.html]"]
  node_result_view["Result view<br/>[result.html]"]
  node_file_config["Upload config<br/>[config.py]"]
end

subgraph group_screening["MRI screening"]
  node_ood_gate["Image OOD gate<br/>[app.py]"]
  node_resnet["Pretrained ResNet"]
  node_vae["VAE encoder<br/>[model.py]"]
  node_classifier["Latent classifier<br/>[model.py]"]
  node_class_labels["Class labels<br/>[app.py]"]
end

subgraph group_data["Persistence"]
  node_database_api["Database access<br/>[config.py]"]
  node_mongo[("MongoDB")]
  node_account_records[("User records")]
  node_prediction_records[("Prediction records")]
end

subgraph group_training["Model training"]
  node_training["Training workflow<br/>[train.py]"]
  node_train_data["ImageFolder data"]
end

node_user(("User"))

node_user -->|"submits requests"| node_web_routes
node_web_routes -->|"renders"| node_auth_views
node_web_routes -->|"renders"| node_dashboard_view
node_web_routes -->|"renders"| node_result_view
node_web_routes -->|"checks uploads"| node_file_config
node_web_routes -->|"validates image"| node_ood_gate
node_ood_gate -->|"scores image"| node_resnet
node_web_routes -->|"encodes MRI"| node_vae
node_web_routes -->|"classifies latent"| node_classifier
node_web_routes -->|"uses labels"| node_class_labels
node_web_routes -->|"gets database"| node_database_api
node_database_api -->|"connects"| node_mongo
node_web_routes -->|"reads and writes"| node_account_records
node_web_routes -->|"writes prediction"| node_prediction_records
node_training -->|"loads images"| node_train_data
node_training -->|"trains encoder"| node_vae
node_training -->|"trains classifier"| node_classifier

click node_web_routes "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py"
click node_auth_views "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/auth.html"
click node_dashboard_view "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/dashboard.html"
click node_result_view "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/result.html"
click node_file_config "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/config.py"
click node_ood_gate "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py"
click node_vae "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/model.py"
click node_classifier "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/model.py"
click node_class_labels "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py"
click node_database_api "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/config.py"
click node_training "https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/train.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_routes,node_auth_views,node_dashboard_view,node_result_view,node_file_config,node_user toneBlue
class node_ood_gate,node_resnet,node_vae,node_classifier,node_class_labels toneAmber
class node_database_api,node_mongo,node_account_records,node_prediction_records toneMint
class node_training,node_train_data toneRose
```

## Components

### Web workflow

- [Web routes](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py): `app.py`
- [Auth view](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/auth.html): `templates/auth.html`
- [Dashboard](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Result view](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/templates/result.html): `templates/result.html`
- [Upload config](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/config.py): `config.py`

### MRI screening

- [Image OOD gate](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py): `app.py`
- **Pretrained ResNet**
- [VAE encoder](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/model.py): `model.py`
- [Latent classifier](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/model.py): `model.py`
- [Class labels](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/app.py): `app.py`

### Persistence

- [Database access](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/config.py): `config.py`
- **MongoDB**
- **User records**
- **Prediction records**

### Model training

- [Training workflow](https://github.com/yamuna-pinjala/early-detection-of-alzheimer-s-disease-using-variational-autoencoders-on-mri-scans/blob/main/train.py): `train.py`
- **ImageFolder data**

### Other components

- **User**

## Connections

- User → Web routes: submits requests (evidence: `app.py`)
- Web routes → Auth view: renders (evidence: `app.py`)
- Web routes → Dashboard: renders (evidence: `app.py`)
- Web routes → Result view: renders (evidence: `app.py`)
- Web routes → Upload config: checks uploads (evidence: `app.py`)
- Web routes → Image OOD gate: validates image (evidence: `app.py`)
- Image OOD gate → Pretrained ResNet: scores image (evidence: `app.py`)
- Web routes → VAE encoder: encodes MRI (evidence: `app.py`)
- Web routes → Latent classifier: classifies latent (evidence: `app.py`)
- Web routes → Class labels: uses labels (evidence: `app.py`)
- Web routes → Database access: gets database (evidence: `app.py`)
- Database access → MongoDB: connects (evidence: `config.py`)
- Web routes → User records: reads and writes (evidence: `app.py`)
- Web routes → Prediction records: writes prediction (evidence: `app.py`)
- Training workflow → ImageFolder data: loads images (evidence: `train.py`)
- Training workflow → VAE encoder: trains encoder (evidence: `train.py`)
- Training workflow → Latent classifier: trains classifier (evidence: `train.py`)
