# stepankarapetyan/tuberculosis-x-ray-detection-ai-project architecture

> Architecture diagram of the GitHub repository stepankarapetyan/tuberculosis-x-ray-detection-ai-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project
- Repository: https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project

## Overview

This is a web application for classifying uploaded chest X-rays as Normal or Tuberculosis and, when available, returning a Grad-CAM visualization. The user workflow runs from browser upload through the Flask prediction endpoint, image preparation, model inference, and display of the result. The README also documents a notebook for model training and analysis. The model artifact is named in documentation and server configuration but is not present in the supplied file tree; frontend markup and notebook internals were not sampled, so their connections are limited to documented relationships.

Main entry points: [`server.py`](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py) (Flask server), [`index.html`](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/index.html) (Upload interface), [`script.js`](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/script.js) (Browser interaction), [`Tuberculosis.ipynb`](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/Tuberculosis.ipynb) (Training analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_interface["Upload interface<br/>[index.html]"]
  node_browser["Browser interaction<br/>[script.js]"]
end

subgraph group_inference["Prediction service"]
  node_server["Flask server<br/>[server.py]"]
  node_preprocess["Image preparation<br/>[server.py]"]
  node_classifier["TB classifier<br/>[server.py]"]
  node_gradcam["Grad-CAM overlay<br/>[server.py]"]
  node_model[("Trained model")]
end

subgraph group_training["Model development"]
  node_notebook["Training analysis<br/>[Tuberculosis.ipynb]"]
end

node_user(("User"))

node_user -->|"uploads X-ray"| node_interface
node_interface -->|"provides interface"| node_browser
node_browser -->|"posts image"| node_server
node_server -->|"serves page"| node_interface
node_server -->|"prepares image"| node_preprocess
node_server -->|"runs prediction"| node_classifier
node_classifier -->|"predicts with"| node_model
node_server -->|"generates overlay"| node_gradcam
node_server -->|"returns result"| node_browser
node_notebook -.->|"trains model"| node_model

click node_interface "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/index.html"
click node_browser "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/script.js"
click node_server "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py"
click node_preprocess "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py"
click node_classifier "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py"
click node_gradcam "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py"
click node_notebook "https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/Tuberculosis.ipynb"

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_interface,node_browser,node_user toneBlue
class node_server,node_preprocess,node_classifier,node_gradcam,node_model toneAmber
class node_notebook toneMint
```

## Components

### Web interface

- [Upload interface](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/index.html): `index.html`
- [Browser interaction](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/script.js): `script.js`

### Prediction service

- [Flask server](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py): `server.py`
- [Image preparation](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py): `server.py`
- [TB classifier](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py): `server.py`
- [Grad-CAM overlay](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/server.py): `server.py`
- **Trained model**

### Model development

- [Training analysis](https://github.com/stepankarapetyan/tuberculosis-x-ray-detection-ai-project/blob/main/Tuberculosis.ipynb): `Tuberculosis.ipynb`

### Other components

- **User**

## Connections

- User → Upload interface: uploads X-ray (evidence: `README.md`)
- Upload interface → Browser interaction: provides interface (evidence: `README.md`)
- Browser interaction → Flask server: posts image (evidence: `script.js`)
- Flask server → Upload interface: serves page (evidence: `server.py`)
- Flask server → Image preparation: prepares image (evidence: `server.py`)
- Flask server → TB classifier: runs prediction (evidence: `server.py`)
- TB classifier → Trained model: predicts with (evidence: `server.py`)
- Flask server → Grad-CAM overlay: generates overlay (evidence: `server.py`)
- Flask server → Browser interaction: returns result (evidence: `script.js`)
- Training analysis → Trained model: trains model (evidence: `README.md`)
