# prithish44/pharma-help architecture

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

- Interactive diagram: https://gitdiagram.com/prithish44/pharma-help
- Repository: https://github.com/prithish44/pharma-help

## Overview

Pharma Help digitizes handwritten prescriptions, grounds extracted medications against CMS data, and scores the result through deterministic and visual audits. The user uploads an image in the scanner UI; the backend processes it and returns structured clinical data, an audit, and an anonymized preview for review and export. The sampled source shows the API, RAG service, and UI request path; several additional extraction and redaction details are documented in the README, so those relationships are attributed to that documentation.

Main entry points: [`main.py`](https://github.com/prithish44/pharma-help/blob/main/main.py) (Processing API), [`rag_service.py`](https://github.com/prithish44/pharma-help/blob/main/rag_service.py) (Prescription enrichment), [`frontend/src/PrescriptionScanner.jsx`](https://github.com/prithish44/pharma-help/blob/main/frontend/src/PrescriptionScanner.jsx) (Scanner UI), [`chroma_db`](https://github.com/prithish44/pharma-help/tree/main/chroma_db) (Chroma vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Scanner experience"]
  node_scanner["Scanner UI"]
  node_review["Review and export"]
end

subgraph group_processing["Prescription processing"]
  node_api["Processing API<br/>[main.py]"]
  node_image["Image preparation<br/>[main.py]"]
  node_redaction["Privacy redaction<br/>[main.py]"]
  node_transcription["Clinical transcription<br/>[main.py]"]
  node_weights["YOLO model weights<br/>[best.pt]"]
end

subgraph group_grounding["Clinical grounding"]
  node_enrichment["Prescription enrichment<br/>[rag_service.py]"]
  node_cms["CMS drug dataset<br/>[CMS-DATASET.csv]"]
  node_clinical["Clinical entities dataset"]
  node_vectorstore[("Chroma vector store")]
  node_cms_matching["CMS medication matching<br/>[rag_service.py]"]
  node_clinical_lookup["Clinical entity lookup<br/>[rag_service.py]"]
end

subgraph group_quality["Quality evaluation"]
  node_rule_audit["Deterministic audit<br/>[main.py]"]
  node_visual_audit["Visual audit<br/>[main.py]"]
  node_result["Scored prescription result<br/>[main.py]"]
end

node_user(("Clinician"))
node_gemini{{"Gemini API"}}
node_yolo{{"YOLO detector"}}

node_user -->|"uploads image"| node_scanner
node_scanner -->|"submits image"| node_api
node_api -->|"decodes image"| node_image
node_api -->|"redacts regions"| node_redaction
node_redaction -->|"detects regions"| node_yolo
node_yolo -->|"loads weights"| node_weights
node_api -->|"transcribes image"| node_transcription
node_transcription -->|"requests extraction"| node_gemini
node_api -->|"grounds extracted data"| node_enrichment
node_enrichment -->|"checks medications"| node_cms_matching
node_cms_matching -->|"queries formulary"| node_vectorstore
node_enrichment -->|"looks up entities"| node_clinical_lookup
node_clinical_lookup -->|"queries entities"| node_vectorstore
node_enrichment -->|"indexes dataset"| node_cms
node_enrichment -->|"indexes entities"| node_clinical
node_api -->|"runs rule audit"| node_rule_audit
node_api -->|"runs visual audit"| node_visual_audit
node_visual_audit -->|"critiques transcription"| node_gemini
node_api -->|"assembles scores"| node_result
node_api -->|"returns result"| node_review
node_review -->|"shows and exports"| node_user

click node_scanner "https://github.com/prithish44/pharma-help/blob/main/frontend/src/PrescriptionScanner.jsx"
click node_review "https://github.com/prithish44/pharma-help/blob/main/frontend/src/PrescriptionScanner.jsx"
click node_api "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_image "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_redaction "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_transcription "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_weights "https://github.com/prithish44/pharma-help/blob/main/runs/detect/train8/weights/best.pt"
click node_enrichment "https://github.com/prithish44/pharma-help/blob/main/rag_service.py"
click node_cms "https://github.com/prithish44/pharma-help/blob/main/CMS-DATASET.csv"
click node_clinical "https://github.com/prithish44/pharma-help/blob/main/ANALYSIS%20OF%20PRESCRIPTION%20ENTITIES%20-%20Updated%20Entities.csv"
click node_vectorstore "https://github.com/prithish44/pharma-help/tree/main/chroma_db"
click node_cms_matching "https://github.com/prithish44/pharma-help/blob/main/rag_service.py"
click node_clinical_lookup "https://github.com/prithish44/pharma-help/blob/main/rag_service.py"
click node_rule_audit "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_visual_audit "https://github.com/prithish44/pharma-help/blob/main/main.py"
click node_result "https://github.com/prithish44/pharma-help/blob/main/main.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_scanner,node_review toneBlue
class node_api,node_image,node_redaction,node_transcription,node_weights toneAmber
class node_enrichment,node_cms,node_clinical,node_vectorstore,node_cms_matching,node_clinical_lookup,node_gemini toneMint
class node_rule_audit,node_visual_audit,node_result toneRose
class node_user,node_yolo toneIndigo
```

## Components

### Scanner experience

- [Scanner UI](https://github.com/prithish44/pharma-help/blob/main/frontend/src/PrescriptionScanner.jsx): `frontend/src/PrescriptionScanner.jsx`
- [Review and export](https://github.com/prithish44/pharma-help/blob/main/frontend/src/PrescriptionScanner.jsx): `frontend/src/PrescriptionScanner.jsx`

### Prescription processing

- [Processing API](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [Image preparation](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [Privacy redaction](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [Clinical transcription](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [YOLO model weights](https://github.com/prithish44/pharma-help/blob/main/runs/detect/train8/weights/best.pt): `runs/detect/train8/weights/best.pt`

### Clinical grounding

- [Prescription enrichment](https://github.com/prithish44/pharma-help/blob/main/rag_service.py): `rag_service.py`
- [CMS drug dataset](https://github.com/prithish44/pharma-help/blob/main/CMS-DATASET.csv): `CMS-DATASET.csv`
- [Clinical entities dataset](https://github.com/prithish44/pharma-help/blob/main/ANALYSIS%20OF%20PRESCRIPTION%20ENTITIES%20-%20Updated%20Entities.csv): `ANALYSIS OF PRESCRIPTION ENTITIES - Updated Entities.csv`
- [Chroma vector store](https://github.com/prithish44/pharma-help/tree/main/chroma_db): `chroma_db`
- [CMS medication matching](https://github.com/prithish44/pharma-help/blob/main/rag_service.py): `rag_service.py`
- [Clinical entity lookup](https://github.com/prithish44/pharma-help/blob/main/rag_service.py): `rag_service.py`

### Quality evaluation

- [Deterministic audit](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [Visual audit](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`
- [Scored prescription result](https://github.com/prithish44/pharma-help/blob/main/main.py): `main.py`

### Other components

- **Clinician**
- **Gemini API**
- **YOLO detector**

## Connections

- Clinician → Scanner UI: uploads image (evidence: `README.txt`)
- Scanner UI → Processing API: submits image (evidence: `frontend/src/PrescriptionScanner.jsx`)
- Processing API → Image preparation: decodes image (evidence: `main.py`)
- Processing API → Privacy redaction: redacts regions (evidence: `main.py`)
- Privacy redaction → YOLO detector: detects regions (evidence: `main.py`)
- YOLO detector → YOLO model weights: loads weights
- Processing API → Clinical transcription: transcribes image (evidence: `README.txt`)
- Clinical transcription → Gemini API: requests extraction (evidence: `README.txt`)
- Processing API → Prescription enrichment: grounds extracted data (evidence: `README.txt`)
- Prescription enrichment → CMS medication matching: checks medications (evidence: `rag_service.py`)
- CMS medication matching → Chroma vector store: queries formulary (evidence: `rag_service.py`)
- Prescription enrichment → Clinical entity lookup: looks up entities (evidence: `rag_service.py`)
- Clinical entity lookup → Chroma vector store: queries entities (evidence: `rag_service.py`)
- Prescription enrichment → CMS drug dataset: indexes dataset (evidence: `rag_service.py`)
- Prescription enrichment → Clinical entities dataset: indexes entities (evidence: `rag_service.py`)
- Processing API → Deterministic audit: runs rule audit (evidence: `main.py`)
- Processing API → Visual audit: runs visual audit (evidence: `main.py`)
- Visual audit → Gemini API: critiques transcription (evidence: `main.py`)
- Processing API → Scored prescription result: assembles scores (evidence: `main.py`)
- Processing API → Review and export: returns result (evidence: `frontend/src/PrescriptionScanner.jsx`)
- Review and export → Clinician: shows and exports (evidence: `README.txt`)
