Skip to content
chenDeepinPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌳 DrugTree

A visual universe of drugs β€” explore structures, therapeutic areas, drug genealogy, and disease hierarchies at a glance.

Vision

Problem: Drug databases are fragmented, require logins, and hide structures behind captchas. It's hard to see how drugs relate across generations or therapeutic areas.

Solution: An interactive human body atlas showing all approved small-molecule drugs, with deep-linkable drug detail pages, zoomable genealogy trees, and ATC-aware disease navigation.

Features

Core Features

  • πŸ—ΊοΈ Central Body Atlas - Interactive human body with clickable organs and floating ATC tags
  • 🧬 Structure Viewer - Instant 2D molecular visualization via RDKit.js
  • 🧭 Route-Aware Drug Detail Pages - Open any drug as a deep-linkable #drug/{id} detail surface with browser-back support
  • 🌳 Drug Genealogy - See how drugs evolved across generations (parent drugs β†’ successors)
  • 🦠 Disease Navigation - Browse drugs by an ATC-aware disease hierarchy that prunes empty branches from the visible tree
  • πŸ” Dual Display Modes - Public (simplified) and Scientist (detailed) views
  • πŸ”Ž Genealogy Zoom Controls - Zoom in, zoom out, and reset the lineage tree in scientist detail views

Data Features

  • 7,359 Small-Molecule Drugs from ChEMBL, KEGG, DrugBank, and FDA sources
  • 55.4% ATC Coverage (4,079 drugs with valid ATC codes, 3,280 awaiting enrichment)
  • 14 ATC Level 1 Categories with color-coded navigation
  • 14 Body Regions mapped to therapeutic areas
  • Drug Families - Group related drugs by mechanism/target
  • Drug Lineages - Track evolutionary relationships
  • Drug Targets - Protein target lookup with disease associations
  • Graph Knowledge Engine - Unified drug-disease-target graph with evidence
  • Source Provenance - Track where each drug's data originated
  • Canonical Root Data Files - frontend embeds are generated from repo-root datasets

Quick Start

# Clone
git clone https://github.com/chenDeepin/DrugTree.git
cd DrugTree

# Start frontend (static server with generated gzip/Brotli sidecar support)
python3 scripts/serve_frontend.py --port 8080 --host 127.0.0.1

# Open in browser
open http://127.0.0.1:8080

# Optional backend (FastAPI + SQLite)
uvicorn src.backend.main:app --reload --port 8000

# Frontend regression tests
npx playwright test --config tests/frontend/playwright.config.ts

# Frontend data integration checks
node tests/frontend/e2e/disease-universe.mjs

Test harness note: tests/frontend/playwright.config.ts serves the frontend on http://localhost:8766 to avoid collisions with a backend/API service on 8765.

Important: http://127.0.0.1:8000/ is the API service, not the atlas UI. Open the static frontend URL (http://127.0.0.1:8080/) to review the body map and drug data in a browser.

Generated embed note: scripts/build_frontend_embeds.py writes frontend embeds plus .gz and .br sidecars. scripts/serve_frontend.py serves the precompressed sidecars when the browser advertises support.

Architecture

UI Layout: Central Body Atlas

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Topbar (Glassmorphism)                                 β”‚
β”‚  [DrugTree] [Search...] [Clear] [Public/Scientist]      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Atlas Hero Section                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚    [N] ←←←  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β†’β†’β†’ [S]             β”‚  β”‚
β”‚  β”‚    [R] ←←   β”‚   Human     β”‚   β†’β†’ [C]             β”‚  β”‚
β”‚  β”‚    [L] ←←   β”‚    Body     β”‚   β†’β†’ [B]             β”‚  β”‚
β”‚  β”‚    [M] ←←   β”‚   (Glow)    β”‚   β†’β†’ [D]             β”‚  β”‚
β”‚  β”‚    [P] ←←   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β†’β†’ [G]             β”‚  β”‚
β”‚  β”‚    [A] ←←                     β†’β†’ [H]             β”‚  β”‚
β”‚  β”‚    [J] ←←                     β†’β†’ [V]             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Active Filters: [ATC: C βœ•] [Search: statin βœ•]         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Route-aware Detail: /#drug/atorvastatin                β”‚
β”‚  Deep-linkable detail page with structure + genealogy   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Matching Drugs (X results)                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”              β”‚
β”‚  β”‚Drug1β”‚ β”‚Drug2β”‚ β”‚Drug3β”‚ β”‚Drug4β”‚ β”‚Drug5β”‚ ...          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

DrugTree/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ drugs.json                    # canonical drug database (7,359 drugs)
β”‚   β”œβ”€β”€ diseases.json                 # disease hierarchy (50 diseases)
β”‚   β”œβ”€β”€ disease_drug_edges.json       # disease-drug relationships
β”‚   β”œβ”€β”€ ontology/body-ontology.json   # body region definitions
β”‚   β”œβ”€β”€ processed/                    # derived data (families, lineages)
β”‚   β”œβ”€β”€ curated/                      # manual overrides
β”‚   β”œβ”€β”€ seeds/                        # seed data for ETL
β”‚   └── changes/                      # change-log entries
β”œβ”€β”€ scripts/
β”‚   └── build_frontend_embeds.py      # regenerate frontend data embeds
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ frontend/                     # Vanilla JS web app
β”‚   β”‚   β”œβ”€β”€ index.html               # Entry point
β”‚   β”‚   β”œβ”€β”€ css/style.css            # Dark atlas theme
β”‚   β”‚   β”œβ”€β”€ assets/                   # SVG body atlas
β”‚   β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”‚   β”œβ”€β”€ app.js               # DrugTreeApp class
β”‚   β”‚   β”‚   β”œβ”€β”€ app-state.js         # State management helpers
β”‚   β”‚   β”‚   β”œβ”€β”€ structure.js         # RDKit.js molecule viewer
β”‚   β”‚   β”‚   β”œβ”€β”€ components/          # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ stores/              # State stores
β”‚   β”‚   β”‚   └── views/               # View renderers
β”‚   β”‚   └── data/                    # generated mirrors/embeds
β”‚   └── backend/                      # FastAPI + SQLite service
β”‚       β”œβ”€β”€ main.py                  # Entry point
β”‚       β”œβ”€β”€ run_etl.sh               # ETL pipeline launcher
β”‚       β”œβ”€β”€ routers/                 # API route modules (drugs, diseases, targets, graph, admin)
β”‚       β”œβ”€β”€ models/                  # Pydantic & DB models
β”‚       β”œβ”€β”€ services/                # Business logic & graph engine
β”‚       β”œβ”€β”€ etl/                     # drug / disease / ATC / target pipelines
β”‚       β”œβ”€β”€ db/                      # SQLite connection & schema
β”‚       β”œβ”€β”€ migrations/              # SQL migrations
β”‚       β”œβ”€β”€ cache/                   # API response caching
β”‚       β”œβ”€β”€ export/                  # Data exporters
β”‚       └── validation/              # Migration & data validators
└── tests/
    β”œβ”€β”€ backend/                      # pytest suites
    └── frontend/                     # Playwright e2e + Node tests
        └── e2e/p0-regression.spec.ts # route/detail/disease high-signal regressions

Tech Stack

Layer Technology
Frontend Vanilla JS + RDKit.js
Backend FastAPI (Python) + SQLite
Data ChEMBL + DrugBank + PubChem + KEGG + FDA
E2E Tests Playwright
Hosting GitHub Pages (MVP)

ATC Categories (14 Total)

Code Category Color Drugs (valid ATC)
A Alimentary & Metabolism Green ~300+
B Blood & Blood-forming Red ~250+
C Cardiovascular Pink ~400+
D Dermatological Orange ~200+
G Genito-urinary Purple ~250+
H Systemic Hormones Brown ~150+
J Anti-infectives Blue ~800+
L Antineoplastic Dark Red ~600+
M Musculo-skeletal Grey ~200+
N Nervous System Deep Purple ~700+
P Antiparasitic Teal ~100+
R Respiratory Cyan ~300+
S Sensory Organs Indigo ~150+
V Various Grey ~3,097 (many need re-classification)

Note: Exact counts vary as ATC enrichment continues. See /data/drugs.json for current state.

Data Schemas

Drug Schema

{
  "id": "atorvastatin",
  "name": "atorvastatin",
  "smiles": "CC(C)OC(=O)C(C)(C)Oc1ccc(C(=O)c2ccc(Cl)cc2)cc1",
  "inchikey": "YMTINGFKWWXKFG-UHFFFAOYSA-N",
  "atc_code": "C10AA05",
  "atc_category": "C",
  "molecular_weight": 360.84,
  "phase": "IV",
  "year_approved": null,
  "generation": 1,
  "indication": "approved",
  "targets": [],
  "company": null,
  "synonyms": [],
  "class": null,
  "body_region": "blood_immune",
  "secondary_body_regions": ["eye_ear", "heart_vascular", "kidney_urinary", "liver_biliary_pancreas"],
  "chembl_id": "CHEMBL1487",
  "kegg_id": "D00565",
  "clinical_trials": ["NCT00504829", "NCT00362323"]
}

Drug Family Schema

{
  "family_id": "target_hmg_coa_reductase_7169b791",
  "label": "Hmg Coa Reductase Target Family",
  "family_basis": "target",
  "prototype_drug_id": "atorvastatin",
  "member_drug_ids": ["atorvastatin", "simvastatin", "lovastatin", "pravastatin"],
  "representative_target_ids": ["HMG-CoA reductase"],
  "description": "Drugs targeting hmg coa reductase",
  "atc_codes": ["C10AA05", "C10AA01", "C10AA02", "C10AA03"]
}

Lineage Edge Schema

{
  "edge_id": "omeprazole_to_lansoprazole",
  "from_drug_id": "omeprazole",
  "to_drug_id": "lansoprazole",
  "edge_type": "follow_on",
  "confidence": 0.843,
  "rationale_tags": [],
  "score_breakdown": {
    "chronology_score": 1.0,
    "mechanism_score": 1.0,
    "scaffold_score": 0.478
  },
  "provenance": "auto",
  "explanation": "Lansoprazole (1995) derived from Omeprazole (1989) | scores: chronology=1.0, mechanism=1.0, scaffold=0.48"
}

Backend API Endpoints

All endpoints are prefixed with /api/v1.

Endpoint Method Description
/api/v1/drugs GET List all drugs (with pagination, filters: category, search, phase)
/api/v1/drugs/{id} GET Get drug by ID
/api/v1/drugs/search GET Search drugs by name, target, class, or synonyms (?q=query&limit=100&offset=0)
/api/v1/drugs/category/{category} GET Filter drugs by ATC category (A-V, with limit/offset)
/api/v1/families GET List drug families (limit/offset, limit capped at 1000)
/api/v1/families/{family_id} GET Get family by ID
/api/v1/lineages GET List lineage edges (filters: drug_id, edge_type, plus limit/offset, limit capped at 1000)
/api/v1/lineage/{drug_id} GET Get genealogy tree for a drug (with threshold param)
/api/v1/regions GET List all body regions from ontology
/api/v1/tree/disease/{disease_id} GET Get body region and paginated drugs for a disease (limit/offset, limit capped at 100; response includes total)
/api/v1/graph/stats GET Get graph index statistics
/api/v1/graph/node/{node_id} GET Get graph node by namespaced ID
/api/v1/graph/neighborhood/{node_id} GET N-hop neighborhood (?max_hops=1-5)
/api/v1/graph/evidence/{edge_id} GET Evidence supporting a graph edge
/api/v1/graph/subgraph GET Subgraph extraction (?node_ids=a,b,c)
/api/v1/diseases GET List disease hierarchy (with pagination)
/api/v1/diseases/{id} GET Get disease by ID
/api/v1/diseases/search/{query} GET Search diseases by name, synonym, or mechanism (with limit/offset)
/api/v1/diseases/region/{region} GET List diseases in a body region (with limit/offset)
/api/v1/diseases/{id}/drugs GET Get drugs for a disease (with limit/offset)
/api/v1/admin/health/data-quality GET Data quality health check
/api/v1/admin/refresh POST Refresh runtime snapshot, graph index, and graph query caches
/api/v1/targets GET List all drug targets (with pagination)
/api/v1/targets/{target_id} GET Get target detail by ID

Documentation

License

MIT

Author

Built by chenDeepin 🎯

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages