# eorkuncelik/molecular-property-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/eorkuncelik/molecular-property-prediction
- Repository: https://github.com/eorkuncelik/molecular-property-prediction

## Overview

This is a molecular-solubility prediction platform. A user submits a SMILES string in the React UI; the API validates and canonicalizes it, computes descriptors, runs the shared model, stores the result, and returns prediction details for display. Separate offline modules support ESOL data preparation, scaffold-aware splitting, model training and evaluation. The README documents additional capabilities beyond the sampled code; connections for those are included only where its statements or the source index support them.

Main entry points: [`scripts/train_model.py`](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/scripts/train_model.py) (Training orchestration), [`frontend/src/App.jsx`](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/App.jsx) (Prediction interface), [`ml/inference.py`](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/inference.py) (Solubility inference), [`backend/app/api/v1/endpoints/predictions.py`](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/api/v1/endpoints/predictions.py) (Prediction routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Prediction interface<br/>[App.jsx]"]
  node_client["REST client<br/>[client.js]"]
  node_result["Prediction display"]
  node_history["History display<br/>[HistoryTable.jsx]"]
  node_molecule["SMILES input<br/>[SmilesForm.jsx]"]
end

subgraph group_api["Prediction API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_routes["Prediction routes<br/>[predictions.py]"]
  node_health["Health route<br/>[health.py]"]
  node_service["Prediction service"]
  node_records[("Prediction records<br/>[models.py]")]
end

subgraph group_runtime["Shared ML runtime"]
  node_chem["Chemistry service<br/>[chem.py]"]
  node_viz["Structure rendering<br/>[visualization.py]"]
  node_loader["Model loader<br/>[model_loader.py]"]
  node_inference["Solubility inference<br/>[inference.py]"]
  node_validation["SMILES validation<br/>[validation.py]"]
  node_descriptors["Molecular descriptors<br/>[descriptors.py]"]
  node_registry["Model registry<br/>[registry.py]"]
end

subgraph group_training["Offline modeling"]
  node_config["ML configuration<br/>[config.py]"]
  node_loader_data["Dataset loading<br/>[loader.py]"]
  node_preprocess["Data preprocessing<br/>[preprocessing.py]"]
  node_split["Scaffold splitting<br/>[splitting.py]"]
  node_features["Feature pipeline<br/>[pipeline.py]"]
  node_train["Model training<br/>[train.py]"]
  node_evaluate["Model evaluation<br/>[evaluate.py]"]
  node_driver["Training orchestration<br/>[train_model.py]"]
  node_fingerprints["Morgan fingerprints<br/>[fingerprints.py]"]
end

node_user(("Molecule user"))
node_database[("PostgreSQL")]

node_user -->|"enters SMILES"| node_app
node_app -->|"renders input"| node_molecule
node_app -->|"requests data"| node_client
node_client -->|"REST/JSON"| node_backend
node_app -->|"renders result"| node_result
node_app -->|"renders history"| node_history
node_backend -->|"mounts routes"| node_routes
node_routes -->|"invokes"| node_service
node_routes -->|"renders structure"| node_viz
node_service -->|"predicts molecule"| node_inference
node_service -->|"persists and queries"| node_records
node_records -->|"stored in"| node_database
node_routes -->|"also exposes"| node_health
node_inference -->|"validates input"| node_validation
node_inference -->|"computes features"| node_descriptors
node_inference -->|"loads bundle"| node_registry
node_loader -->|"initializes predictor"| node_inference
node_driver -->|"loads dataset"| node_loader_data
node_driver -->|"prepares data"| node_preprocess
node_driver -->|"validates molecules"| node_validation
node_driver -->|"splits scaffolds"| node_split
node_driver -->|"builds features"| node_features
node_features -->|"computes descriptors"| node_descriptors
node_driver -->|"fits candidates"| node_train
node_driver -->|"evaluates models"| node_evaluate
node_driver -->|"saves model bundle"| node_registry
node_driver -->|"uses settings"| node_config
node_inference -->|"shares feature pipeline"| node_features
node_app -->|"loads history and health"| node_client
node_result -->|"requests structure image"| node_client
node_client -->|"predict and history endpoints"| node_routes
node_driver -.->|"optional featurization"| node_fingerprints

click node_app "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/App.jsx"
click node_client "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/api/client.js"
click node_result "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/PredictionResult.jsx"
click node_history "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/HistoryTable.jsx"
click node_molecule "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/SmilesForm.jsx"
click node_backend "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/main.py"
click node_routes "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/api/v1/endpoints/predictions.py"
click node_health "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/api/v1/endpoints/health.py"
click node_service "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/prediction_service.py"
click node_records "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/db/models.py"
click node_chem "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/chem.py"
click node_viz "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/visualization.py"
click node_loader "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/ml_runtime/model_loader.py"
click node_inference "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/inference.py"
click node_validation "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/validation.py"
click node_descriptors "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/features/descriptors.py"
click node_registry "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/registry.py"
click node_config "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/config.py"
click node_loader_data "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/loader.py"
click node_preprocess "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/preprocessing.py"
click node_split "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/splitting.py"
click node_features "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/pipeline.py"
click node_train "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/train.py"
click node_evaluate "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/evaluate.py"
click node_driver "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/scripts/train_model.py"
click node_fingerprints "https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/features/fingerprints.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_client,node_result,node_history,node_molecule,node_user toneBlue
class node_backend,node_routes,node_health,node_service,node_records,node_database toneAmber
class node_chem,node_viz,node_loader,node_inference,node_validation,node_descriptors,node_registry toneMint
class node_config,node_loader_data,node_preprocess,node_split,node_features,node_train,node_evaluate,node_driver,node_fingerprints toneRose
```

## Components

### User interface

- [Prediction interface](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [REST client](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Prediction display](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/PredictionResult.jsx): `frontend/src/components/PredictionResult.jsx`
- [History display](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/HistoryTable.jsx): `frontend/src/components/HistoryTable.jsx`
- [SMILES input](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/frontend/src/components/SmilesForm.jsx): `frontend/src/components/SmilesForm.jsx`

### Prediction API

- [FastAPI application](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prediction routes](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/api/v1/endpoints/predictions.py): `backend/app/api/v1/endpoints/predictions.py`
- [Health route](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/api/v1/endpoints/health.py): `backend/app/api/v1/endpoints/health.py`
- [Prediction service](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/prediction_service.py): `backend/app/services/prediction_service.py`
- [Prediction records](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/db/models.py): `backend/app/db/models.py`

### Shared ML runtime

- [Chemistry service](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/chem.py): `backend/app/services/chem.py`
- [Structure rendering](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/services/visualization.py): `backend/app/services/visualization.py`
- [Model loader](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/backend/app/ml_runtime/model_loader.py): `backend/app/ml_runtime/model_loader.py`
- [Solubility inference](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/inference.py): `ml/inference.py`
- [SMILES validation](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/validation.py): `ml/data/validation.py`
- [Molecular descriptors](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/features/descriptors.py): `ml/features/descriptors.py`
- [Model registry](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/registry.py): `ml/models/registry.py`

### Offline modeling

- [ML configuration](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/config.py): `ml/config.py`
- [Dataset loading](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/loader.py): `ml/data/loader.py`
- [Data preprocessing](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/preprocessing.py): `ml/data/preprocessing.py`
- [Scaffold splitting](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/data/splitting.py): `ml/data/splitting.py`
- [Feature pipeline](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/pipeline.py): `ml/pipeline.py`
- [Model training](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/train.py): `ml/models/train.py`
- [Model evaluation](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/models/evaluate.py): `ml/models/evaluate.py`
- [Training orchestration](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/scripts/train_model.py): `scripts/train_model.py`
- [Morgan fingerprints](https://github.com/eorkuncelik/molecular-property-prediction/blob/main/ml/features/fingerprints.py): `ml/features/fingerprints.py`

### Other components

- **Molecule user**
- **PostgreSQL**

## Connections

- Molecule user → Prediction interface: enters SMILES (evidence: `frontend/src/App.jsx`)
- Prediction interface → SMILES input: renders input (evidence: `frontend/src/App.jsx`)
- Prediction interface → REST client: requests data (evidence: `frontend/src/App.jsx`)
- REST client → FastAPI application: REST/JSON
- Prediction interface → Prediction display: renders result (evidence: `frontend/src/App.jsx`)
- Prediction interface → History display: renders history (evidence: `frontend/src/App.jsx`)
- FastAPI application → Prediction routes: mounts routes (evidence: `backend/app/main.py`)
- Prediction routes → Prediction service: invokes (evidence: `backend/app/api/v1/endpoints/predictions.py`)
- Prediction routes → Structure rendering: renders structure (evidence: `backend/app/api/v1/endpoints/predictions.py`)
- Prediction service → Solubility inference: predicts molecule (evidence: `backend/app/services/prediction_service.py`)
- Prediction service → Prediction records: persists and queries (evidence: `backend/app/services/prediction_service.py`)
- Prediction records → PostgreSQL: stored in
- Prediction routes → Health route: also exposes (evidence: `backend/app/api/v1/router.py`)
- Solubility inference → SMILES validation: validates input (evidence: `ml/inference.py`)
- Solubility inference → Molecular descriptors: computes features (evidence: `ml/inference.py`)
- Solubility inference → Model registry: loads bundle (evidence: `ml/inference.py`)
- Model loader → Solubility inference: initializes predictor (evidence: `backend/app/ml_runtime/model_loader.py`)
- Training orchestration → Dataset loading: loads dataset (evidence: `scripts/train_model.py`)
- Training orchestration → Data preprocessing: prepares data (evidence: `scripts/train_model.py`)
- Training orchestration → SMILES validation: validates molecules (evidence: `scripts/train_model.py`)
- Training orchestration → Scaffold splitting: splits scaffolds (evidence: `scripts/train_model.py`)
- Training orchestration → Feature pipeline: builds features (evidence: `scripts/train_model.py`)
- Feature pipeline → Molecular descriptors: computes descriptors (evidence: `ml/pipeline.py`)
- Training orchestration → Model training: fits candidates (evidence: `scripts/train_model.py`)
- Training orchestration → Model evaluation: evaluates models (evidence: `scripts/train_model.py`)
- Training orchestration → Model registry: saves model bundle (evidence: `scripts/train_model.py`)
- Training orchestration → ML configuration: uses settings (evidence: `scripts/train_model.py`)
- Solubility inference → Feature pipeline: shares feature pipeline (evidence: `ml/pipeline.py`)
- Prediction interface → REST client: loads history and health (evidence: `frontend/src/App.jsx`)
- Prediction display → REST client: requests structure image
- REST client → Prediction routes: predict and history endpoints
- Training orchestration → Morgan fingerprints: optional featurization
