# adrikabharti/ai-medical-report-analyser1 architecture

> Architecture diagram of the GitHub repository adrikabharti/ai-medical-report-analyser1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adrikabharti/ai-medical-report-analyser1
- Repository: https://github.com/adrikabharti/ai-medical-report-analyser1

## Overview

AI Medical Report Analyzer accepts lab reports or manually supplied measurements, turns report text into normalized findings and model inputs, then serves disease-screening predictions and supporting guidance through an API and browser UI. Its documented report workflow includes extraction, abnormal-value assessment, five-disease screening, SHAP explanations, health scores, follow-up suggestions, and per-profile trends. A separate research and training branch compares datasets and prepares deployment models. Source excerpts establish the report-processing and model-training internals; several API and UI details are documented only in the README.

Main entry points: [`app.py`](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/app.py) (FastAPI service), [`report_pipeline.py`](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_pipeline.py) (Report pipeline), [`disease_model_comparison.py`](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/disease_model_comparison.py) (Model comparison), [`report_extractor.py`](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_extractor.py) (Report router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Report Intake"]
  node_report["Report router"]
  node_pdf["PDF text reader<br/>[pdf_extractor.py]"]
  node_ocr["OCR reader<br/>[ocr_extractor.py]"]
end

subgraph group_analysis["Clinical Analysis"]
  node_parser["Lab parameter parser"]
  node_normalizer["Unit normalizer<br/>[unit_normalizer.py]"]
  node_abnormal["Abnormal detector"]
  node_pipeline["Report pipeline<br/>[report_pipeline.py]"]
end

subgraph group_screening["Screening and Guidance"]
  node_disease_models["Disease predictors"]
  node_shap["SHAP helpers<br/>[shap_utils.py]"]
  node_explainer["Patient explanation<br/>[explainer.py]"]
  node_score["Health score<br/>[health_score.py]"]
  node_followup["Follow-up suggestions<br/>[followup.py]"]
end

subgraph group_service["API and History"]
  node_ui["Browser UI<br/>[index.html]"]
  node_api["FastAPI service<br/>[app.py]"]
  node_history[("Trend history<br/>[history_store.py]")]
end

subgraph group_research["Model Research"]
  node_comparison["Model comparison"]
  node_feature_variants["Feature experiments"]
  node_ablation["Ablation analysis"]
  node_final_lr["Logistic model training<br/>[train_final.py]"]
  node_validation["External validation"]
end

node_person(("Report user"))

node_person -->|"uses"| node_ui
node_ui -->|"calls API"| node_api
node_person -->|"uploads report"| node_api
node_api -->|"analyzes report"| node_pipeline
node_pipeline -->|"extracts text"| node_report
node_report -->|"reads PDF"| node_pdf
node_report -->|"routes to OCR"| node_ocr
node_pipeline -->|"parses text"| node_parser
node_pipeline -->|"normalizes values"| node_normalizer
node_pipeline -->|"detects findings"| node_abnormal
node_api -->|"loads model artifacts"| node_disease_models
node_api -->|"builds explainers"| node_shap
node_api -->|"requests explanation"| node_explainer
node_api -->|"calculates score"| node_score
node_api -->|"suggests tests"| node_followup
node_api -->|"stores reports"| node_history
node_api -->|"serves trends"| node_history
node_comparison -->|"informs feature tests"| node_feature_variants
node_comparison -->|"supplies analysis"| node_ablation
node_comparison -->|"informs model choice"| node_final_lr
node_comparison -->|"compares algorithms"| node_disease_models
node_disease_models -.->|"scores saved models"| node_validation

click node_ui "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/static/index.html"
click node_api "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/app.py"
click node_report "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_extractor.py"
click node_pdf "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/pdf_extractor.py"
click node_ocr "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/ocr_extractor.py"
click node_parser "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/parameter_extractor.py"
click node_normalizer "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/unit_normalizer.py"
click node_abnormal "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/abnormal_detector.py"
click node_pipeline "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_pipeline.py"
click node_disease_models "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/train_final_best.py"
click node_shap "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/shap_utils.py"
click node_explainer "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/explainer.py"
click node_score "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/health_score.py"
click node_followup "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/followup.py"
click node_history "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/history_store.py"
click node_comparison "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/disease_model_comparison.py"
click node_feature_variants "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/feature_variants.py"
click node_ablation "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/Ablation_analysis.py"
click node_final_lr "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/train_final.py"
click node_validation "https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/External_Validation.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_report,node_pdf,node_ocr,node_person toneBlue
class node_parser,node_normalizer,node_abnormal,node_pipeline toneAmber
class node_disease_models,node_shap,node_explainer,node_score,node_followup toneMint
class node_ui,node_api,node_history toneRose
class node_comparison,node_feature_variants,node_ablation,node_final_lr,node_validation toneIndigo
```

## Components

### Report Intake

- [Report router](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_extractor.py): `report_extractor.py`
- [PDF text reader](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/pdf_extractor.py): `pdf_extractor.py`
- [OCR reader](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/ocr_extractor.py): `ocr_extractor.py`

### Clinical Analysis

- [Lab parameter parser](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/parameter_extractor.py): `parameter_extractor.py`
- [Unit normalizer](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/unit_normalizer.py): `unit_normalizer.py`
- [Abnormal detector](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/abnormal_detector.py): `abnormal_detector.py`
- [Report pipeline](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/report_pipeline.py): `report_pipeline.py`

### Screening and Guidance

- [Disease predictors](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/train_final_best.py): `train_final_best.py`
- [SHAP helpers](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/shap_utils.py): `shap_utils.py`
- [Patient explanation](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/explainer.py): `explainer.py`
- [Health score](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/health_score.py): `health_score.py`
- [Follow-up suggestions](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/followup.py): `followup.py`

### API and History

- [Browser UI](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/static/index.html): `static/index.html`
- [FastAPI service](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/app.py): `app.py`
- [Trend history](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/history_store.py): `history_store.py`

### Model Research

- [Model comparison](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/disease_model_comparison.py): `disease_model_comparison.py`
- [Feature experiments](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/feature_variants.py): `feature_variants.py`
- [Ablation analysis](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/Ablation_analysis.py): `Ablation_analysis.py`
- [Logistic model training](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/train_final.py): `train_final.py`
- [External validation](https://github.com/adrikabharti/ai-medical-report-analyser1/blob/main/External_Validation.py): `External_Validation.py`

### Other components

- **Report user**

## Connections

- Report user → Browser UI: uses (evidence: `README.md`)
- Browser UI → FastAPI service: calls API (evidence: `README.md`)
- Report user → FastAPI service: uploads report (evidence: `README.md`)
- FastAPI service → Report pipeline: analyzes report (evidence: `README.md`)
- Report pipeline → Report router: extracts text (evidence: `report_pipeline.py`)
- Report router → PDF text reader: reads PDF (evidence: `report_extractor.py`)
- Report router → OCR reader: routes to OCR (evidence: `report_extractor.py`)
- Report pipeline → Lab parameter parser: parses text (evidence: `report_pipeline.py`)
- Report pipeline → Unit normalizer: normalizes values (evidence: `report_pipeline.py`)
- Report pipeline → Abnormal detector: detects findings (evidence: `report_pipeline.py`)
- FastAPI service → Disease predictors: loads model artifacts (evidence: `README.md`)
- FastAPI service → SHAP helpers: builds explainers (evidence: `app.py`)
- FastAPI service → Patient explanation: requests explanation (evidence: `README.md`)
- FastAPI service → Health score: calculates score (evidence: `README.md`)
- FastAPI service → Follow-up suggestions: suggests tests (evidence: `README.md`)
- FastAPI service → Trend history: stores reports (evidence: `README.md`)
- FastAPI service → Trend history: serves trends (evidence: `README.md`)
- Model comparison → Feature experiments: informs feature tests (evidence: `feature_variants.py`)
- Model comparison → Ablation analysis: supplies analysis (evidence: `Ablation_analysis.py`)
- Model comparison → Logistic model training: informs model choice (evidence: `train_final.py`)
- Model comparison → Disease predictors: compares algorithms (evidence: `train_final_best.py`)
- Disease predictors → External validation: scores saved models
