# sanjaykumar3110/mediscan architecture

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

- Interactive diagram: https://gitdiagram.com/sanjaykumar3110/mediscan
- Repository: https://github.com/sanjaykumar3110/mediscan

## Overview

MediScan is a Streamlit medical assistant whose main workflow turns an uploaded prescription into extracted text, then routes follow-up questions to medical chat or nearby-care search. The graph includes the documented safety and knowledge-base capabilities; the knowledge-base builder is present, but no runtime caller is shown. Edges follow excerpts or README workflow statements; unsampled implementation details are not inferred.

Main entry points: [`src/orchestrate.py`](https://github.com/sanjaykumar3110/mediscan/blob/main/src/orchestrate.py) (Orchestrator), [`src/agents/medic_agent.py`](https://github.com/sanjaykumar3110/mediscan/blob/main/src/agents/medic_agent.py) (Medical agent), [`src/helpers/chat_llm.py`](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/chat_llm.py) (Medical chat), [`app.py`](https://github.com/sanjaykumar3110/mediscan/blob/main/app.py) (Streamlit interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit interface<br/>[app.py]"]
end

subgraph group_routing["Request routing"]
  node_orchestrator["Orchestrator<br/>[orchestrate.py]"]
end

subgraph group_medical["Prescription assistance"]
  node_medical_agent["Medical agent<br/>[medic_agent.py]"]
  node_ocr["Prescription OCR<br/>[ocr_model.py]"]
  node_medical_chat["Medical chat<br/>[chat_llm.py]"]
end

subgraph group_location["Care discovery"]
  node_location_agent["Location agent<br/>[locate_agent.py]"]
  node_facility_search["Facility search<br/>[doc_locate.py]"]
end

subgraph group_knowledge["Safety and knowledge"]
  node_local_model["Local LLM loader<br/>[validate.py]"]
  node_safety["Safety validation<br/>[validate.py]"]
  node_kb_builder["Knowledge-base builder<br/>[build_kb.py]"]
end

node_user(("User"))
node_osm["OpenStreetMap Nominatim"]
node_chroma[("Persistent vector store")]

node_user -->|"uploads and asks"| node_streamlit
node_streamlit -->|"routes requests"| node_orchestrator
node_orchestrator -->|"dispatches image or chat"| node_medical_agent
node_orchestrator -->|"dispatches location"| node_location_agent
node_medical_agent -->|"extracts prescription"| node_ocr
node_medical_agent -->|"delegates chat"| node_medical_chat
node_medical_chat -->|"loads model"| node_local_model
node_medical_chat -->|"validates response"| node_safety
node_location_agent -->|"searches facilities"| node_facility_search
node_facility_search -->|"queries places"| node_osm
node_kb_builder -->|"writes collections"| node_chroma
node_orchestrator -.->|"validates responses"| node_safety
node_orchestrator -->|"returns answer"| node_streamlit

click node_streamlit "https://github.com/sanjaykumar3110/mediscan/blob/main/app.py"
click node_orchestrator "https://github.com/sanjaykumar3110/mediscan/blob/main/src/orchestrate.py"
click node_medical_agent "https://github.com/sanjaykumar3110/mediscan/blob/main/src/agents/medic_agent.py"
click node_ocr "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/ocr_model.py"
click node_medical_chat "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/chat_llm.py"
click node_location_agent "https://github.com/sanjaykumar3110/mediscan/blob/main/src/agents/locate_agent.py"
click node_facility_search "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/doc_locate.py"
click node_local_model "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/validate.py"
click node_safety "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/validate.py"
click node_kb_builder "https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/build_kb.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_streamlit,node_user toneBlue
class node_orchestrator,node_chroma toneAmber
class node_medical_agent,node_ocr,node_medical_chat toneMint
class node_location_agent,node_facility_search toneRose
class node_local_model,node_safety,node_kb_builder,node_osm toneIndigo
```

## Components

### User interface

- [Streamlit interface](https://github.com/sanjaykumar3110/mediscan/blob/main/app.py): `app.py`

### Request routing

- [Orchestrator](https://github.com/sanjaykumar3110/mediscan/blob/main/src/orchestrate.py): `src/orchestrate.py`

### Prescription assistance

- [Medical agent](https://github.com/sanjaykumar3110/mediscan/blob/main/src/agents/medic_agent.py): `src/agents/medic_agent.py`
- [Prescription OCR](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/ocr_model.py): `src/helpers/ocr_model.py`
- [Medical chat](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/chat_llm.py): `src/helpers/chat_llm.py`

### Care discovery

- [Location agent](https://github.com/sanjaykumar3110/mediscan/blob/main/src/agents/locate_agent.py): `src/agents/locate_agent.py`
- [Facility search](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/doc_locate.py): `src/helpers/doc_locate.py`

### Safety and knowledge

- [Local LLM loader](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/validate.py): `src/helpers/validate.py`
- [Safety validation](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/validate.py): `src/helpers/validate.py`
- [Knowledge-base builder](https://github.com/sanjaykumar3110/mediscan/blob/main/src/helpers/build_kb.py): `src/helpers/build_kb.py`

### Other components

- **User**
- **OpenStreetMap Nominatim**
- **Persistent vector store**

## Connections

- User → Streamlit interface: uploads and asks (evidence: `README.md`)
- Streamlit interface → Orchestrator: routes requests (evidence: `app.py`)
- Orchestrator → Medical agent: dispatches image or chat (evidence: `src/orchestrate.py`)
- Orchestrator → Location agent: dispatches location (evidence: `src/orchestrate.py`)
- Medical agent → Prescription OCR: extracts prescription (evidence: `src/agents/medic_agent.py`)
- Medical agent → Medical chat: delegates chat (evidence: `src/agents/medic_agent.py`)
- Medical chat → Local LLM loader: loads model (evidence: `src/helpers/chat_llm.py`)
- Medical chat → Safety validation: validates response (evidence: `src/helpers/chat_llm.py`)
- Location agent → Facility search: searches facilities (evidence: `src/agents/locate_agent.py`)
- Facility search → OpenStreetMap Nominatim: queries places (evidence: `src/helpers/doc_locate.py`)
- Knowledge-base builder → Persistent vector store: writes collections (evidence: `src/helpers/build_kb.py`)
- Orchestrator → Safety validation: validates responses (evidence: `README.md`)
- Orchestrator → Streamlit interface: returns answer (evidence: `README.md`)
