# saaksshi18/pneumoscan architecture

> Architecture diagram of the GitHub repository saaksshi18/pneumoscan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saaksshi18/pneumoscan
- Repository: https://github.com/saaksshi18/pneumoscan

## Overview

PneumoScan AI is a chest-X-ray pneumonia screening demo with a static web interface, serverless prediction and health endpoints, and a locally generated TensorFlow model. The primary workflow is image submission, model inference, Grad-CAM visualization and a structured screening response. Model training is a separate preparation workflow that produces the model artifact used at runtime. The README documents the frontend and API routes; the frontend source was not sampled, so its specific request behavior is not verified. The graph uses the prediction function for its inline processing stages rather than implying separate modules.

Main entry points: [`api/predict.py`](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py) (Model inference), [`public/index.html`](https://github.com/saaksshi18/pneumoscan/blob/main/public/index.html) (Static interface), [`model/pneumonia_model.h5`](https://github.com/saaksshi18/pneumoscan/blob/main/model/pneumonia_model.h5) (Pneumonia model), [`model_train.py`](https://github.com/saaksshi18/pneumoscan/blob/main/model_train.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend["Static interface<br/>[index.html]"]
end

subgraph group_api["Serverless API"]
  node_predict_api["Prediction endpoint<br/>[predict.py]"]
  node_health_api["Health endpoint<br/>[health.py]"]
  node_upload["Image upload parsing<br/>[predict.py]"]
end

subgraph group_ml["Model and explanations"]
  node_inference["Model inference<br/>[predict.py]"]
  node_model_load["Model loading<br/>[predict.py]"]
  node_model_asset[("Pneumonia model<br/>[pneumonia_model.h5]")]
  node_gradcam["Grad-CAM heatmap<br/>[predict.py]"]
  node_regions["Region identification<br/>[predict.py]"]
  node_explanation["Screening guidance<br/>[predict.py]"]
end

subgraph group_training["Model preparation"]
  node_train["Model training<br/>[model_train.py]"]
  node_dataset[("Chest X-ray dataset")]
end

node_user(("User"))

node_user -->|"opens"| node_frontend
node_user -->|"submits image"| node_predict_api
node_frontend -.->|"calls API"| node_predict_api
node_predict_api -->|"parses upload"| node_upload
node_predict_api -->|"requests prediction"| node_inference
node_inference -->|"loads model"| node_model_load
node_model_load -->|"reads weights"| node_model_asset
node_inference -->|"generates heatmap"| node_gradcam
node_inference -->|"identifies regions"| node_regions
node_inference -->|"builds guidance"| node_explanation
node_predict_api -.->|"returns result"| node_frontend
node_health_api -->|"checks existence"| node_model_asset
node_dataset -->|"trains on"| node_train
node_train -->|"saves model"| node_model_asset

click node_frontend "https://github.com/saaksshi18/pneumoscan/blob/main/public/index.html"
click node_predict_api "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_health_api "https://github.com/saaksshi18/pneumoscan/blob/main/api/health.py"
click node_upload "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_inference "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_model_load "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_model_asset "https://github.com/saaksshi18/pneumoscan/blob/main/model/pneumonia_model.h5"
click node_gradcam "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_regions "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_explanation "https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py"
click node_train "https://github.com/saaksshi18/pneumoscan/blob/main/model_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_frontend,node_user toneBlue
class node_predict_api,node_health_api,node_upload toneAmber
class node_inference,node_model_load,node_model_asset,node_gradcam,node_regions,node_explanation toneMint
class node_train,node_dataset toneRose
```

## Components

### Web interface

- [Static interface](https://github.com/saaksshi18/pneumoscan/blob/main/public/index.html): `public/index.html`

### Serverless API

- [Prediction endpoint](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`
- [Health endpoint](https://github.com/saaksshi18/pneumoscan/blob/main/api/health.py): `api/health.py`
- [Image upload parsing](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`

### Model and explanations

- [Model inference](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`
- [Model loading](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`
- [Pneumonia model](https://github.com/saaksshi18/pneumoscan/blob/main/model/pneumonia_model.h5): `model/pneumonia_model.h5`
- [Grad-CAM heatmap](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`
- [Region identification](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`
- [Screening guidance](https://github.com/saaksshi18/pneumoscan/blob/main/api/predict.py): `api/predict.py`

### Model preparation

- [Model training](https://github.com/saaksshi18/pneumoscan/blob/main/model_train.py): `model_train.py`
- **Chest X-ray dataset**

### Other components

- **User**

## Connections

- User → Static interface: opens (evidence: `README.md`)
- User → Prediction endpoint: submits image (evidence: `README.md`)
- Static interface → Prediction endpoint: calls API
- Prediction endpoint → Image upload parsing: parses upload (evidence: `api/predict.py`)
- Prediction endpoint → Model inference: requests prediction (evidence: `api/predict.py`)
- Model inference → Model loading: loads model (evidence: `api/predict.py`)
- Model loading → Pneumonia model: reads weights (evidence: `README.md`)
- Model inference → Grad-CAM heatmap: generates heatmap (evidence: `api/predict.py`)
- Model inference → Region identification: identifies regions (evidence: `api/predict.py`)
- Model inference → Screening guidance: builds guidance (evidence: `api/predict.py`)
- Prediction endpoint → Static interface: returns result
- Health endpoint → Pneumonia model: checks existence (evidence: `api/health.py`)
- Chest X-ray dataset → Model training: trains on (evidence: `model_train.py`)
- Model training → Pneumonia model: saves model (evidence: `model_train.py`)
