# kuntalsaha05/egfr-drugdiscovery-xai architecture

> Architecture diagram of the GitHub repository kuntalsaha05/egfr-drugdiscovery-xai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kuntalsaha05/egfr-drugdiscovery-xai
- Repository: https://github.com/kuntalsaha05/egfr-drugdiscovery-xai

## Overview

This is a Streamlit assistant for early virtual screening of compounds against human EGFR. A user submits a SMILES structure; the application validates and profiles it, predicts activity with the trained RF/GB ensemble, and presents structural views, SHAP explanations, drug-likeness results, and similarity to EGFR therapies. It can also produce PDF dossiers. A separate data-preparation path harvests ChEMBL bioactivity records and trains the models used for inference. Edges reflect the excerpts and README; some UI-to-report wiring is documented but not visible in the sampled app excerpt.

Main entry points: [`DrugDiscoveryAI/app.py`](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/app.py) (Streamlit app), [`DrugDiscoveryAI/chem_engine.py`](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py) (SMILES and chemoinformatics), [`DrugDiscoveryAI/train_model.py`](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/train_model.py) (Model training and evaluation), [`DrugDiscoveryAI/ai_model.py`](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/ai_model.py) (Activity inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_screening["Screening experience"]
  node_ui["Streamlit app<br/>[app.py]"]
end

subgraph group_chem["Molecular analysis"]
  node_chem["SMILES and chemoinformatics<br/>[chem_engine.py]"]
  node_visual["2D/3D structure views<br/>[chem_engine.py]"]
  node_druglikeness["Drug-likeness scorecard<br/>[chem_engine.py]"]
  node_similarity["EGFR drug similarity"]
end

subgraph group_models["Data and models"]
  node_predictor["Activity inference<br/>[ai_model.py]"]
  node_artifacts[("Trained model artifacts")]
  node_trainer["Model training and evaluation<br/>[train_model.py]"]
  node_dataset[("Curated EGFR dataset")]
  node_harvester["Bioactivity data processing<br/>[fetch_data.py]"]
end

subgraph group_outputs["Interpretation and outputs"]
  node_shap["SHAP attribution<br/>[explainability.py]"]
  node_pdf["PDF screening dossier"]
end

node_user(("Researcher"))
node_chembl["ChEMBL service"]

node_user -->|"submits SMILES"| node_ui
node_ui -->|"validates and profiles"| node_chem
node_ui -->|"requests structure views"| node_visual
node_ui -->|"shows scorecard"| node_druglikeness
node_ui -->|"requests prediction"| node_predictor
node_predictor -->|"featurizes molecule"| node_chem
node_artifacts -->|"loads models"| node_predictor
node_ui -->|"requests explanation"| node_shap
node_shap -->|"maps atoms and renders"| node_chem
node_ui -->|"searches analogues"| node_similarity
node_ui -->|"generates dossier"| node_pdf
node_pdf -->|"renders molecule and scorecard"| node_chem
node_chembl -->|"provides bioactivity records"| node_harvester
node_harvester -->|"writes curated records"| node_dataset
node_dataset -->|"supplies training data"| node_trainer
node_trainer -->|"extracts features"| node_chem
node_trainer -->|"saves models and metrics"| node_artifacts

click node_ui "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/app.py"
click node_chem "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py"
click node_visual "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py"
click node_druglikeness "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py"
click node_similarity "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/similarity_engine.py"
click node_predictor "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/ai_model.py"
click node_artifacts "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/tree/main/DrugDiscoveryAI/models"
click node_trainer "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/train_model.py"
click node_dataset "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/data/egfr_chembl203_bioactivity.csv"
click node_harvester "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/fetch_data.py"
click node_shap "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/explainability.py"
click node_pdf "https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/report_generator.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_ui toneBlue
class node_chem,node_visual,node_druglikeness,node_similarity toneAmber
class node_predictor,node_artifacts,node_trainer,node_dataset,node_harvester toneMint
class node_shap,node_pdf toneRose
class node_user,node_chembl toneIndigo
```

## Components

### Screening experience

- [Streamlit app](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/app.py): `DrugDiscoveryAI/app.py`

### Molecular analysis

- [SMILES and chemoinformatics](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py): `DrugDiscoveryAI/chem_engine.py`
- [2D/3D structure views](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py): `DrugDiscoveryAI/chem_engine.py`
- [Drug-likeness scorecard](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/chem_engine.py): `DrugDiscoveryAI/chem_engine.py`
- [EGFR drug similarity](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/similarity_engine.py): `DrugDiscoveryAI/similarity_engine.py`

### Data and models

- [Activity inference](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/ai_model.py): `DrugDiscoveryAI/ai_model.py`
- [Trained model artifacts](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/tree/main/DrugDiscoveryAI/models): `DrugDiscoveryAI/models`
- [Model training and evaluation](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/train_model.py): `DrugDiscoveryAI/train_model.py`
- [Curated EGFR dataset](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/data/egfr_chembl203_bioactivity.csv): `DrugDiscoveryAI/data/egfr_chembl203_bioactivity.csv`
- [Bioactivity data processing](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/fetch_data.py): `DrugDiscoveryAI/fetch_data.py`

### Interpretation and outputs

- [SHAP attribution](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/explainability.py): `DrugDiscoveryAI/explainability.py`
- [PDF screening dossier](https://github.com/kuntalsaha05/egfr-drugdiscovery-xai/blob/main/DrugDiscoveryAI/report_generator.py): `DrugDiscoveryAI/report_generator.py`

### Other components

- **Researcher**
- **ChEMBL service**

## Connections

- Researcher → Streamlit app: submits SMILES (evidence: `README.md`)
- Streamlit app → SMILES and chemoinformatics: validates and profiles (evidence: `DrugDiscoveryAI/app.py`)
- Streamlit app → 2D/3D structure views: requests structure views (evidence: `DrugDiscoveryAI/app.py`)
- Streamlit app → Drug-likeness scorecard: shows scorecard (evidence: `README.md`)
- Streamlit app → Activity inference: requests prediction (evidence: `DrugDiscoveryAI/app.py`)
- Activity inference → SMILES and chemoinformatics: featurizes molecule (evidence: `DrugDiscoveryAI/ai_model.py`)
- Trained model artifacts → Activity inference: loads models (evidence: `DrugDiscoveryAI/ai_model.py`)
- Streamlit app → SHAP attribution: requests explanation (evidence: `DrugDiscoveryAI/app.py`)
- SHAP attribution → SMILES and chemoinformatics: maps atoms and renders (evidence: `DrugDiscoveryAI/explainability.py`)
- Streamlit app → EGFR drug similarity: searches analogues (evidence: `DrugDiscoveryAI/app.py`)
- Streamlit app → PDF screening dossier: generates dossier (evidence: `README.md`)
- PDF screening dossier → SMILES and chemoinformatics: renders molecule and scorecard (evidence: `DrugDiscoveryAI/report_generator.py`)
- ChEMBL service → Bioactivity data processing: provides bioactivity records (evidence: `DrugDiscoveryAI/fetch_data.py`)
- Bioactivity data processing → Curated EGFR dataset: writes curated records (evidence: `DrugDiscoveryAI/fetch_data.py`)
- Curated EGFR dataset → Model training and evaluation: supplies training data (evidence: `DrugDiscoveryAI/train_model.py`)
- Model training and evaluation → SMILES and chemoinformatics: extracts features (evidence: `DrugDiscoveryAI/train_model.py`)
- Model training and evaluation → Trained model artifacts: saves models and metrics (evidence: `DrugDiscoveryAI/train_model.py`)
