# imtiaz-techie/multimodal-ddi-checker architecture

> Architecture diagram of the GitHub repository imtiaz-techie/multimodal-ddi-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imtiaz-techie/multimodal-ddi-checker
- Repository: https://github.com/imtiaz-techie/multimodal-ddi-checker

## Overview

RxLens is a local medicine lookup and personal-health-record tool with medication interaction and patient-risk checks, plus prescription-image OCR utilities. The main CLI workflow stores a patient profile and medications, then checks those records (and optional prescription text) for risks; medicine lookup is a separate CLI option. The medicine engine reads the supplied medicine and generic CSV files, while OCR exposes image extraction and prescription-line parsing as utilities. The excerpts show the CLI-to-engine and local JSON-record relationships; no OCR-to-DDI integration is shown.

Main entry points: [`phr_ui.py`](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/phr_ui.py) (PHR CLI), [`rxlens_core.py`](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_core.py) (Medicine engine), [`rxlens_ddi.py`](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ddi.py) (DDI and risk checks), [`rxlens_ocr.py`](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ocr.py) (Image text extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI and PHR"]
  node_cli["PHR CLI<br/>[phr_ui.py]"]
  node_phr["PHR manager<br/>[phr_ui.py]"]
  node_record[("Local PHR JSON")]
end

subgraph group_medicine["Medicine lookup"]
  node_lookup["Medicine engine<br/>[rxlens_core.py]"]
  node_medicine_data[("Medicine catalogue<br/>[medicine.csv]")]
  node_generic_data[("Generic catalogue<br/>[generic.csv]")]
end

subgraph group_safety["Medication safety"]
  node_ddi["DDI and risk checks<br/>[rxlens_ddi.py]"]
end

subgraph group_ocr["Prescription OCR"]
  node_image["Prescription image"]
  node_ocr_extract["Image text extraction<br/>[rxlens_ocr.py]"]
  node_ocr_parse["Prescription line parsing<br/>[rxlens_ocr.py]"]
end

node_user(("CLI user"))

node_user -->|"uses"| node_cli
node_cli -->|"manages records"| node_phr
node_phr -->|"loads and saves"| node_record
node_cli -->|"looks up medicines"| node_lookup
node_cli -->|"requests risk check"| node_ddi
node_ddi -->|"reads medicine data"| node_lookup
node_lookup -->|"reads catalogue"| node_medicine_data
node_lookup -->|"reads catalogue"| node_generic_data
node_image -->|"provides image"| node_ocr_extract
node_ocr_extract -->|"passes extracted text"| node_ocr_parse

click node_cli "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/phr_ui.py"
click node_phr "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/phr_ui.py"
click node_lookup "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_core.py"
click node_medicine_data "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/medicine.csv/medicine.csv"
click node_generic_data "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/generic.csv/generic.csv"
click node_ddi "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ddi.py"
click node_ocr_extract "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ocr.py"
click node_ocr_parse "https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ocr.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_cli,node_phr,node_record,node_user toneBlue
class node_lookup,node_medicine_data,node_generic_data toneAmber
class node_ddi toneMint
class node_image,node_ocr_extract,node_ocr_parse toneRose
```

## Components

### CLI and PHR

- [PHR CLI](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/phr_ui.py): `phr_ui.py`
- [PHR manager](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/phr_ui.py): `phr_ui.py`
- **Local PHR JSON**

### Medicine lookup

- [Medicine engine](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_core.py): `rxlens_core.py`
- [Medicine catalogue](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/medicine.csv/medicine.csv): `medicine.csv/medicine.csv`
- [Generic catalogue](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/generic.csv/generic.csv): `generic.csv/generic.csv`

### Medication safety

- [DDI and risk checks](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ddi.py): `rxlens_ddi.py`

### Prescription OCR

- **Prescription image**
- [Image text extraction](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ocr.py): `rxlens_ocr.py`
- [Prescription line parsing](https://github.com/imtiaz-techie/multimodal-ddi-checker/blob/main/rxlens_ocr.py): `rxlens_ocr.py`

### Other components

- **CLI user**

## Connections

- CLI user → PHR CLI: uses (evidence: `phr_ui.py`)
- PHR CLI → PHR manager: manages records (evidence: `phr_ui.py`)
- PHR manager → Local PHR JSON: loads and saves (evidence: `phr_ui.py`)
- PHR CLI → Medicine engine: looks up medicines (evidence: `phr_ui.py`)
- PHR CLI → DDI and risk checks: requests risk check (evidence: `phr_ui.py`)
- DDI and risk checks → Medicine engine: reads medicine data (evidence: `rxlens_ddi.py`)
- Medicine engine → Medicine catalogue: reads catalogue (evidence: `rxlens_core.py`)
- Medicine engine → Generic catalogue: reads catalogue (evidence: `rxlens_core.py`)
- Prescription image → Image text extraction: provides image (evidence: `rxlens_ocr.py`)
- Image text extraction → Prescription line parsing: passes extracted text (evidence: `rxlens_ocr.py`)
