# anhsirksai/off-label-radar architecture

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

- Interactive diagram: https://gitdiagram.com/anhsirksai/off-label-radar
- Repository: https://github.com/anhsirksai/off-label-radar

## Overview

Off-Label Radar finds active clinical trials that test approved drugs beyond their labeled indications, using Jev’s typed decisions to score and rank evidence. Users enter drug names or a plain-language condition in the web UI; the API starts the corresponding workflow, which gathers registry, label, and literature data, then presents ranked candidates and supporting evidence. The README documents capabilities beyond the sampled excerpts; those links are included where documented, while unsampled implementation details are not assumed.

Main entry points: [`pipeline.py`](https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py) (Drug workflow), [`condition.py`](https://github.com/anhsirksai/off-label-radar/blob/main/condition.py) (Condition workflow), [`main.py`](https://github.com/anhsirksai/off-label-radar/blob/main/main.py) (FastAPI), [`db.py`](https://github.com/anhsirksai/off-label-radar/blob/main/db.py) (SQLite cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["User interface"]
  node_web_ui["Radar UI<br/>[app.js]"]
  node_api["FastAPI<br/>[main.py]"]
end

subgraph group_workflows["Research workflows"]
  node_drug_flow["Drug workflow<br/>[pipeline.py]"]
  node_condition_flow["Condition workflow<br/>[condition.py]"]
  node_pair_gate["Off-label gate<br/>[pipeline.py]"]
  node_literature["Evidence lookup<br/>[pipeline.py]"]
  node_judge_rank["Judge and rank<br/>[pipeline.py]"]
end

subgraph group_services["Data and judgment services"]
  node_ctgov{{"ClinicalTrials.gov"}}
  node_rxnorm{{"RxNorm"}}
  node_dailymed{{"DailyMed"}}
  node_pubmed{{"PubMed"}}
  node_jev_service{{"Jev API"}}
  node_net_layer["Request controls<br/>[net.py]"]
end

subgraph group_state["Run state and storage"]
  node_database[("SQLite cache<br/>[db.py]")]
  node_run_state["Run status<br/>[net.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"enters query"| node_web_ui
node_web_ui -->|"calls API"| node_api
node_api -->|"starts drug run"| node_drug_flow
node_api -->|"starts condition run"| node_condition_flow
node_api -->|"reads candidates"| node_database
node_api -->|"reports status"| node_run_state
node_drug_flow -->|"resolves drugs"| node_rxnorm
node_drug_flow -->|"fetches labels"| node_dailymed
node_drug_flow -->|"finds active trials"| node_ctgov
node_condition_flow -->|"searches condition"| node_ctgov
node_condition_flow -->|"matches MeSH"| node_jev_service
node_condition_flow -->|"resolves interventions"| node_rxnorm
node_condition_flow -->|"fetches labels"| node_dailymed
node_condition_flow -->|"uses shared gate"| node_pair_gate
node_drug_flow -->|"judges trial pairs"| node_pair_gate
node_pair_gate -->|"asks typed questions"| node_jev_service
node_pair_gate -->|"saves gate scores"| node_database
node_drug_flow -->|"requests evidence"| node_literature
node_literature -->|"fetches abstracts"| node_pubmed
node_literature -->|"stores evidence"| node_database
node_drug_flow -->|"judges and ranks"| node_judge_rank
node_condition_flow -->|"uses shared judge"| node_judge_rank
node_judge_rank -->|"scores plausibility"| node_jev_service
node_judge_rank -->|"persists results"| node_database
node_drug_flow -->|"caches workflow data"| node_database
node_condition_flow -->|"caches condition data"| node_database
node_drug_flow -->|"uses rate limits"| node_net_layer
node_condition_flow -->|"uses rate limits"| node_net_layer
node_web_ui -->|"displays results"| node_api

click node_web_ui "https://github.com/anhsirksai/off-label-radar/blob/main/static/app.js"
click node_api "https://github.com/anhsirksai/off-label-radar/blob/main/main.py"
click node_drug_flow "https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py"
click node_condition_flow "https://github.com/anhsirksai/off-label-radar/blob/main/condition.py"
click node_pair_gate "https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py"
click node_literature "https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py"
click node_judge_rank "https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py"
click node_net_layer "https://github.com/anhsirksai/off-label-radar/blob/main/net.py"
click node_database "https://github.com/anhsirksai/off-label-radar/blob/main/db.py"
click node_run_state "https://github.com/anhsirksai/off-label-radar/blob/main/net.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_web_ui,node_api toneBlue
class node_drug_flow,node_condition_flow,node_pair_gate,node_literature,node_judge_rank toneAmber
class node_ctgov,node_rxnorm,node_dailymed,node_pubmed,node_jev_service,node_net_layer toneMint
class node_database,node_run_state toneRose
class node_researcher toneIndigo
```

## Components

### User interface

- [Radar UI](https://github.com/anhsirksai/off-label-radar/blob/main/static/app.js): `static/app.js`
- [FastAPI](https://github.com/anhsirksai/off-label-radar/blob/main/main.py): `main.py`

### Research workflows

- [Drug workflow](https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py): `pipeline.py`
- [Condition workflow](https://github.com/anhsirksai/off-label-radar/blob/main/condition.py): `condition.py`
- [Off-label gate](https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py): `pipeline.py`
- [Evidence lookup](https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py): `pipeline.py`
- [Judge and rank](https://github.com/anhsirksai/off-label-radar/blob/main/pipeline.py): `pipeline.py`

### Data and judgment services

- **ClinicalTrials.gov**
- **RxNorm**
- **DailyMed**
- **PubMed**
- **Jev API**
- [Request controls](https://github.com/anhsirksai/off-label-radar/blob/main/net.py): `net.py`

### Run state and storage

- [SQLite cache](https://github.com/anhsirksai/off-label-radar/blob/main/db.py): `db.py`
- [Run status](https://github.com/anhsirksai/off-label-radar/blob/main/net.py): `net.py`

### Other components

- **Researcher**

## Connections

- Researcher → Radar UI: enters query (evidence: `README.md`)
- Radar UI → FastAPI: calls API (evidence: `static/app.js`)
- FastAPI → Drug workflow: starts drug run (evidence: `main.py`)
- FastAPI → Condition workflow: starts condition run (evidence: `main.py`)
- FastAPI → SQLite cache: reads candidates (evidence: `main.py`)
- FastAPI → Run status: reports status (evidence: `main.py`)
- Drug workflow → RxNorm: resolves drugs (evidence: `README.md`)
- Drug workflow → DailyMed: fetches labels (evidence: `pipeline.py`)
- Drug workflow → ClinicalTrials.gov: finds active trials (evidence: `README.md`)
- Condition workflow → ClinicalTrials.gov: searches condition (evidence: `README.md`)
- Condition workflow → Jev API: matches MeSH (evidence: `condition.py`)
- Condition workflow → RxNorm: resolves interventions (evidence: `condition.py`)
- Condition workflow → DailyMed: fetches labels (evidence: `README.md`)
- Condition workflow → Off-label gate: uses shared gate (evidence: `README.md`)
- Drug workflow → Off-label gate: judges trial pairs (evidence: `pipeline.py`)
- Off-label gate → Jev API: asks typed questions (evidence: `pipeline.py`)
- Off-label gate → SQLite cache: saves gate scores (evidence: `pipeline.py`)
- Drug workflow → Evidence lookup: requests evidence (evidence: `README.md`)
- Evidence lookup → PubMed: fetches abstracts (evidence: `pipeline.py`)
- Evidence lookup → SQLite cache: stores evidence (evidence: `README.md`)
- Drug workflow → Judge and rank: judges and ranks (evidence: `README.md`)
- Condition workflow → Judge and rank: uses shared judge (evidence: `README.md`)
- Judge and rank → Jev API: scores plausibility (evidence: `README.md`)
- Judge and rank → SQLite cache: persists results (evidence: `README.md`)
- Drug workflow → SQLite cache: caches workflow data (evidence: `README.md`)
- Condition workflow → SQLite cache: caches condition data (evidence: `README.md`)
- Drug workflow → Request controls: uses rate limits (evidence: `pipeline.py`)
- Condition workflow → Request controls: uses rate limits (evidence: `condition.py`)
- Radar UI → FastAPI: displays results (evidence: `README.md`)
