# neliken/pulmonogy_app architecture

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

- Interactive diagram: https://gitdiagram.com/neliken/pulmonogy_app
- Repository: https://github.com/neliken/pulmonogy_app

## Overview

This Flask pulmonology cabinet supports patient registration and maintenance, chest X-ray upload with five-class prediction, and a symptom-based lung cancer risk assessment. The route handlers in main.py own these workflows, persist patient and result data in SQLite, and render the corresponding templates. The model artifacts are present in the tree, but the X-ray checkpoint named by main.py is not; relationships are limited to those explicit in the sampled source. Templates are represented as UI components where their paths are shown in the tree.

Main entry points: [`main.py`](https://github.com/neliken/pulmonogy_app/blob/main/main.py) (Flask routes), [`static/uploads`](https://github.com/neliken/pulmonogy_app/tree/main/static/uploads) (Uploaded X-rays), [`trained_pipeline.pkl`](https://github.com/neliken/pulmonogy_app/blob/main/trained_pipeline.pkl) (Cancer classifier), [`templates/add_patient.html`](https://github.com/neliken/pulmonogy_app/blob/main/templates/add_patient.html) (Patient views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient records"]
  node_web["Flask routes<br/>[main.py]"]
  node_patient_model["Patient model<br/>[main.py]"]
  node_patient_db[("Patient database<br/>[main.py]")]
end

subgraph group_diagnostics["Diagnostics"]
  node_xray_image[("Uploaded X-rays")]
  node_xray_pipeline["X-ray inference<br/>[main.py]"]
  node_xray_model["X-ray model"]
  node_cancer_pipeline["Cancer risk inference<br/>[main.py]"]
  node_cancer_model["Cancer classifier"]
end

subgraph group_presentation["Web views"]
  node_patient_forms["Patient views<br/>[add_patient.html]"]
  node_patient_list["Patient list view<br/>[patient_list.html]"]
  node_patient_detail["Patient detail view"]
  node_home["Home view<br/>[home.html]"]
  node_xray_form["X-ray upload view<br/>[upload_xray.html]"]
  node_xray_result["X-ray result view"]
  node_cancer_form["Cancer assessment view"]
end

node_user(("Cabinet user"))

node_user -->|"uses"| node_web
node_web -->|"renders"| node_home
node_web -->|"renders"| node_patient_forms
node_web -->|"renders"| node_patient_list
node_web -->|"renders"| node_patient_detail
node_web -->|"queries and updates"| node_patient_model
node_patient_model -->|"persists"| node_patient_db
node_web -->|"renders"| node_xray_form
node_web -->|"saves image"| node_xray_image
node_web -->|"preprocesses image"| node_xray_pipeline
node_xray_pipeline -->|"infers classes"| node_xray_model
node_web -->|"stores probabilities"| node_patient_model
node_web -->|"renders result"| node_xray_result
node_web -->|"renders"| node_cancer_form
node_web -->|"builds assessment"| node_cancer_pipeline
node_cancer_pipeline -->|"predicts risk"| node_cancer_model
node_web -->|"stores risk"| node_patient_model

click node_web "https://github.com/neliken/pulmonogy_app/blob/main/main.py"
click node_patient_model "https://github.com/neliken/pulmonogy_app/blob/main/main.py"
click node_patient_db "https://github.com/neliken/pulmonogy_app/blob/main/main.py"
click node_patient_forms "https://github.com/neliken/pulmonogy_app/blob/main/templates/add_patient.html"
click node_patient_list "https://github.com/neliken/pulmonogy_app/blob/main/templates/patient_list.html"
click node_patient_detail "https://github.com/neliken/pulmonogy_app/blob/main/templates/patient_detail.html"
click node_home "https://github.com/neliken/pulmonogy_app/blob/main/templates/home.html"
click node_xray_form "https://github.com/neliken/pulmonogy_app/blob/main/templates/upload_xray.html"
click node_cancer_form "https://github.com/neliken/pulmonogy_app/blob/main/templates/lung_cancer_test.html"
click node_xray_image "https://github.com/neliken/pulmonogy_app/tree/main/static/uploads"
click node_xray_pipeline "https://github.com/neliken/pulmonogy_app/blob/main/main.py"
click node_cancer_pipeline "https://github.com/neliken/pulmonogy_app/blob/main/main.py"
click node_cancer_model "https://github.com/neliken/pulmonogy_app/blob/main/trained_pipeline.pkl"

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,node_patient_model,node_patient_db,node_user toneBlue
class node_xray_image,node_xray_pipeline,node_xray_model,node_cancer_pipeline,node_cancer_model toneAmber
class node_patient_forms,node_patient_list,node_patient_detail,node_home,node_xray_form,node_xray_result,node_cancer_form toneMint
```

## Components

### Patient records

- [Flask routes](https://github.com/neliken/pulmonogy_app/blob/main/main.py): `main.py`
- [Patient model](https://github.com/neliken/pulmonogy_app/blob/main/main.py): `main.py`
- [Patient database](https://github.com/neliken/pulmonogy_app/blob/main/main.py): `main.py`

### Diagnostics

- [Uploaded X-rays](https://github.com/neliken/pulmonogy_app/tree/main/static/uploads): `static/uploads`
- [X-ray inference](https://github.com/neliken/pulmonogy_app/blob/main/main.py): `main.py`
- **X-ray model**
- [Cancer risk inference](https://github.com/neliken/pulmonogy_app/blob/main/main.py): `main.py`
- [Cancer classifier](https://github.com/neliken/pulmonogy_app/blob/main/trained_pipeline.pkl): `trained_pipeline.pkl`

### Web views

- [Patient views](https://github.com/neliken/pulmonogy_app/blob/main/templates/add_patient.html): `templates/add_patient.html`
- [Patient list view](https://github.com/neliken/pulmonogy_app/blob/main/templates/patient_list.html): `templates/patient_list.html`
- [Patient detail view](https://github.com/neliken/pulmonogy_app/blob/main/templates/patient_detail.html): `templates/patient_detail.html`
- [Home view](https://github.com/neliken/pulmonogy_app/blob/main/templates/home.html): `templates/home.html`
- [X-ray upload view](https://github.com/neliken/pulmonogy_app/blob/main/templates/upload_xray.html): `templates/upload_xray.html`
- **X-ray result view**
- [Cancer assessment view](https://github.com/neliken/pulmonogy_app/blob/main/templates/lung_cancer_test.html): `templates/lung_cancer_test.html`

### Other components

- **Cabinet user**

## Connections

- Cabinet user → Flask routes: uses (evidence: `main.py`)
- Flask routes → Home view: renders (evidence: `main.py`)
- Flask routes → Patient views: renders (evidence: `main.py`)
- Flask routes → Patient list view: renders (evidence: `main.py`)
- Flask routes → Patient detail view: renders (evidence: `main.py`)
- Flask routes → Patient model: queries and updates (evidence: `main.py`)
- Patient model → Patient database: persists (evidence: `main.py`)
- Flask routes → X-ray upload view: renders (evidence: `main.py`)
- Flask routes → Uploaded X-rays: saves image (evidence: `main.py`)
- Flask routes → X-ray inference: preprocesses image (evidence: `main.py`)
- X-ray inference → X-ray model: infers classes (evidence: `main.py`)
- Flask routes → Patient model: stores probabilities (evidence: `main.py`)
- Flask routes → X-ray result view: renders result (evidence: `main.py`)
- Flask routes → Cancer assessment view: renders (evidence: `main.py`)
- Flask routes → Cancer risk inference: builds assessment (evidence: `main.py`)
- Cancer risk inference → Cancer classifier: predicts risk (evidence: `main.py`)
- Flask routes → Patient model: stores risk (evidence: `main.py`)
