# anjithrao/rxreader-medical-ai architecture

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

- Interactive diagram: https://gitdiagram.com/anjithrao/rxreader-medical-ai
- Repository: https://github.com/anjithrao/rxreader-medical-ai

## Overview

RxReader turns a prescription image into structured medicine information, then offers reference translation, medicine-scoped Q&A, and nearby pharmacy discovery with routing. The main path runs from upload through OCR and name correction to enriched results; chat and pharmacy search are separate follow-on workflows. The README documents key processing and integrations; source excerpts and the SOURCE INDEX confirm selected wiring, but several route and service implementations were not shown, so uncertain internal links are omitted.

Main entry points: [`src/api.js`](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/api.js) (REST client), [`app/main.py`](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/main.py) (FastAPI app), [`src/App.jsx`](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/App.jsx) (App flow), [`app/routes/ocr.py`](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/ocr.py) (OCR endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web experience"]
  node_app["App flow<br/>[App.jsx]"]
  node_upload["Prescription upload<br/>[UploadZone.jsx]"]
  node_results["Medicine results<br/>[ResultsPage.jsx]"]
  node_chat_ui["Medicine chat<br/>[RagChat.jsx]"]
  node_pharmacy_ui["Pharmacy search<br/>[PharmaciesPage.jsx]"]
  node_api_client["REST client<br/>[api.js]"]
end

subgraph group_api["API workflows"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_ocr_route["OCR endpoint<br/>[ocr.py]"]
  node_reference_route["Reference endpoint<br/>[reference.py]"]
  node_chat_route["Chat endpoint<br/>[chat.py]"]
  node_pharmacy_route["Pharmacy endpoints<br/>[pharmacy.py]"]
end

subgraph group_medicine["Medicine processing"]
  node_model_registry["OCR model registry<br/>[registry.py]"]
  node_ocr_service["Image OCR<br/>[ocr_service.py]"]
  node_text_utils["Text normalization<br/>[text.py]"]
  node_correction["Medicine correction<br/>[correct.py]"]
  node_gemini_service["Extraction and translation<br/>[gemini_service.py]"]
  node_reference_service["Medicine references"]
end

subgraph group_assistant["RAG assistant"]
  node_rag_service["Hybrid retrieval and answers<br/>[rag_service.py]"]
  node_vector_store[("Vector store<br/>[vector_store.py]")]
  node_embedding_service["Embeddings"]
  node_index_builder["Medicine index builder<br/>[build_index.py]"]
end

subgraph group_discovery["Pharmacy discovery"]
  node_pharmacy_service["Nearby search and routes"]
  node_geo_utils["Geospatial helpers<br/>[geo.py]"]
end

node_user(("User"))
node_gemini{{"Gemini API"}}
node_reference_data[("OpenFDA and local data")]
node_map_services{{"OSM, Overpass, OSRM"}}

node_user -->|"submits image"| node_upload
node_upload -->|"passes image"| node_app
node_app -->|"processes image"| node_api_client
node_api_client -->|"POST /process"| node_ocr_route
node_fastapi -->|"registers route"| node_ocr_route
node_ocr_route -->|"invokes OCR"| node_ocr_service
node_ocr_route -->|"requests extraction"| node_gemini_service
node_ocr_service -->|"uses models"| node_model_registry
node_ocr_service -->|"normalizes text"| node_text_utils
node_text_utils -->|"corrects names"| node_correction
node_gemini_service -->|"extracts medicines"| node_gemini
node_gemini_service -->|"resolves references"| node_reference_service
node_reference_service -->|"checks dictionary"| node_model_registry
node_reference_service -.->|"uses fallback data"| node_reference_data
node_app -->|"shows results"| node_results
node_results -->|"opens assistant"| node_chat_ui
node_chat_ui -->|"asks question"| node_api_client
node_api_client -->|"POST /chat"| node_chat_route
node_fastapi -->|"registers route"| node_chat_route
node_chat_route -->|"requests answer"| node_rag_service
node_rag_service -->|"retrieves documents"| node_vector_store
node_vector_store -->|"gets embeddings"| node_embedding_service
node_index_builder -->|"builds index"| node_vector_store
node_rag_service -->|"generates answer"| node_gemini
node_app -->|"opens search"| node_pharmacy_ui
node_pharmacy_ui -->|"requests search and route"| node_api_client
node_api_client -->|"calls endpoints"| node_pharmacy_route
node_fastapi -->|"registers route"| node_pharmacy_route
node_pharmacy_route -->|"delegates requests"| node_pharmacy_service
node_pharmacy_service -->|"uses geo helpers"| node_geo_utils
node_pharmacy_service -->|"searches and routes"| node_map_services
node_api_client -->|"POST translation"| node_reference_route
node_fastapi -->|"registers route"| node_reference_route
node_reference_route -->|"translates references"| node_gemini_service

click node_app "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/App.jsx"
click node_upload "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/components/UploadZone.jsx"
click node_results "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/pages/ResultsPage.jsx"
click node_chat_ui "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/components/RagChat.jsx"
click node_pharmacy_ui "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/pages/PharmaciesPage.jsx"
click node_api_client "https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/api.js"
click node_fastapi "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/main.py"
click node_ocr_route "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/ocr.py"
click node_reference_route "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/reference.py"
click node_chat_route "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/chat.py"
click node_pharmacy_route "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/pharmacy.py"
click node_model_registry "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/models/registry.py"
click node_ocr_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/ocr_service.py"
click node_text_utils "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/utils/text.py"
click node_correction "https://github.com/anjithrao/rxreader-medical-ai/blob/main/correct.py"
click node_gemini_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/gemini_service.py"
click node_reference_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/reference_service.py"
click node_rag_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/rag_service.py"
click node_vector_store "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/vector_store.py"
click node_embedding_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/embedding_service.py"
click node_index_builder "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/data/build_index.py"
click node_pharmacy_service "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/pharmacy_service.py"
click node_geo_utils "https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/utils/geo.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_app,node_upload,node_results,node_chat_ui,node_pharmacy_ui,node_api_client,node_user toneBlue
class node_fastapi,node_ocr_route,node_reference_route,node_chat_route,node_pharmacy_route,node_reference_data toneAmber
class node_model_registry,node_ocr_service,node_text_utils,node_correction,node_gemini_service,node_reference_service,node_gemini toneMint
class node_rag_service,node_vector_store,node_embedding_service,node_index_builder toneRose
class node_pharmacy_service,node_geo_utils,node_map_services toneIndigo
```

## Components

### Web experience

- [App flow](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/App.jsx): `src/App.jsx`
- [Prescription upload](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/components/UploadZone.jsx): `src/components/UploadZone.jsx`
- [Medicine results](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/pages/ResultsPage.jsx): `src/pages/ResultsPage.jsx`
- [Medicine chat](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/components/RagChat.jsx): `src/components/RagChat.jsx`
- [Pharmacy search](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/pages/PharmaciesPage.jsx): `src/pages/PharmaciesPage.jsx`
- [REST client](https://github.com/anjithrao/rxreader-medical-ai/blob/main/src/api.js): `src/api.js`

### API workflows

- [FastAPI app](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/main.py): `app/main.py`
- [OCR endpoint](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/ocr.py): `app/routes/ocr.py`
- [Reference endpoint](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/reference.py): `app/routes/reference.py`
- [Chat endpoint](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/chat.py): `app/routes/chat.py`
- [Pharmacy endpoints](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/routes/pharmacy.py): `app/routes/pharmacy.py`

### Medicine processing

- [OCR model registry](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/models/registry.py): `app/models/registry.py`
- [Image OCR](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/ocr_service.py): `app/services/ocr_service.py`
- [Text normalization](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/utils/text.py): `app/utils/text.py`
- [Medicine correction](https://github.com/anjithrao/rxreader-medical-ai/blob/main/correct.py): `correct.py`
- [Extraction and translation](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/gemini_service.py): `app/services/gemini_service.py`
- [Medicine references](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/reference_service.py): `app/services/reference_service.py`

### RAG assistant

- [Hybrid retrieval and answers](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/rag_service.py): `app/services/rag_service.py`
- [Vector store](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/vector_store.py): `app/services/vector_store.py`
- [Embeddings](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/embedding_service.py): `app/services/embedding_service.py`
- [Medicine index builder](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/data/build_index.py): `app/data/build_index.py`

### Pharmacy discovery

- [Nearby search and routes](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/services/pharmacy_service.py): `app/services/pharmacy_service.py`
- [Geospatial helpers](https://github.com/anjithrao/rxreader-medical-ai/blob/main/app/utils/geo.py): `app/utils/geo.py`

### Other components

- **User**
- **Gemini API**
- **OpenFDA and local data**
- **OSM, Overpass, OSRM**

## Connections

- User → Prescription upload: submits image (evidence: `README.md`)
- Prescription upload → App flow: passes image
- App flow → REST client: processes image (evidence: `src/App.jsx`)
- REST client → OCR endpoint: POST /process (evidence: `src/api.js`)
- FastAPI app → OCR endpoint: registers route (evidence: `app/main.py`)
- OCR endpoint → Image OCR: invokes OCR (evidence: `app/routes/ocr.py`)
- OCR endpoint → Extraction and translation: requests extraction (evidence: `app/routes/ocr.py`)
- Image OCR → OCR model registry: uses models (evidence: `app/routes/ocr.py`)
- Image OCR → Text normalization: normalizes text (evidence: `app/routes/ocr.py`)
- Text normalization → Medicine correction: corrects names (evidence: `README.md`)
- Extraction and translation → Gemini API: extracts medicines (evidence: `app/services/gemini_service.py`)
- Extraction and translation → Medicine references: resolves references (evidence: `app/services/gemini_service.py`)
- Medicine references → OCR model registry: checks dictionary (evidence: `app/services/reference_service.py`)
- Medicine references → OpenFDA and local data: uses fallback data (evidence: `README.md`)
- App flow → Medicine results: shows results (evidence: `src/App.jsx`)
- Medicine results → Medicine chat: opens assistant (evidence: `src/pages/ResultsPage.jsx`)
- Medicine chat → REST client: asks question (evidence: `src/components/RagChat.jsx`)
- REST client → Chat endpoint: POST /chat (evidence: `src/api.js`)
- FastAPI app → Chat endpoint: registers route (evidence: `app/main.py`)
- Chat endpoint → Hybrid retrieval and answers: requests answer (evidence: `app/routes/chat.py`)
- Hybrid retrieval and answers → Vector store: retrieves documents (evidence: `app/services/rag_service.py`)
- Vector store → Embeddings: gets embeddings (evidence: `app/services/vector_store.py`)
- Medicine index builder → Vector store: builds index (evidence: `app/data/build_index.py`)
- Hybrid retrieval and answers → Gemini API: generates answer (evidence: `README.md`)
- App flow → Pharmacy search: opens search (evidence: `src/App.jsx`)
- Pharmacy search → REST client: requests search and route (evidence: `src/pages/PharmaciesPage.jsx`)
- REST client → Pharmacy endpoints: calls endpoints (evidence: `src/api.js`)
- FastAPI app → Pharmacy endpoints: registers route (evidence: `app/main.py`)
- Pharmacy endpoints → Nearby search and routes: delegates requests (evidence: `app/routes/pharmacy.py`)
- Nearby search and routes → Geospatial helpers: uses geo helpers (evidence: `app/services/pharmacy_service.py`)
- Nearby search and routes → OSM, Overpass, OSRM: searches and routes (evidence: `README.md`)
- REST client → Reference endpoint: POST translation (evidence: `src/api.js`)
- FastAPI app → Reference endpoint: registers route (evidence: `app/main.py`)
- Reference endpoint → Extraction and translation: translates references (evidence: `app/routes/reference.py`)
