# snmiitb-bit/chem-image-to-smiles architecture

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

- Interactive diagram: https://gitdiagram.com/snmiitb-bit/chem-image-to-smiles
- Repository: https://github.com/snmiitb-bit/chem-image-to-smiles

## Overview

The repository provides two ways to turn chemical-structure images into SMILES: a Streamlit web app that sends image bytes to Hugging Face DECIMER, and a command-line function that runs DECIMER locally on an image path. Both validate and canonicalize predictions with RDKit; valid results are copied to the clipboard, and the web app also displays a molecular preview. The README is empty, so the workflow and capabilities shown here are based on the sampled source files.

Main entry points: [`app.py`](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py) (Streamlit app), [`image2smiles.py`](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py) (Image converter)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_web_user(("Web user"))
node_cli_user(("CLI user"))
node_streamlit_app["Streamlit app<br/>[app.py]"]
node_huggingface_decimer["Hugging Face DECIMER"]
node_web_rdkit["SMILES validation<br/>[app.py]"]
node_web_clipboard["Clipboard copy<br/>[app.py]"]
node_web_preview["Molecule preview<br/>[app.py]"]
node_cli_converter["Image converter<br/>[image2smiles.py]"]
node_local_decimer["Local DECIMER<br/>[image2smiles.py]"]
node_cli_rdkit["SMILES validation<br/>[image2smiles.py]"]
node_cli_clipboard["Clipboard copy<br/>[image2smiles.py]"]

node_web_user -->|"uploads image"| node_streamlit_app
node_streamlit_app -->|"posts image bytes"| node_huggingface_decimer
node_huggingface_decimer -->|"returns prediction"| node_streamlit_app
node_streamlit_app -->|"validates prediction"| node_web_rdkit
node_streamlit_app -->|"copies SMILES"| node_web_clipboard
node_streamlit_app -->|"renders molecule"| node_web_preview
node_cli_user -->|"provides image path"| node_cli_converter
node_cli_converter -->|"predicts SMILES"| node_local_decimer
node_cli_converter -->|"validates prediction"| node_cli_rdkit
node_cli_converter -->|"copies SMILES"| node_cli_clipboard

click node_streamlit_app "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py"
click node_web_rdkit "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py"
click node_web_clipboard "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py"
click node_web_preview "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py"
click node_cli_converter "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py"
click node_local_decimer "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py"
click node_cli_rdkit "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py"
click node_cli_clipboard "https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.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_user,node_cli_user,node_web_preview toneBlue
class node_streamlit_app,node_web_rdkit,node_web_clipboard,node_cli_converter,node_local_decimer,node_cli_rdkit,node_cli_clipboard toneTeal
class node_huggingface_decimer toneIndigo
```

## Components

### Other components

- **Web user**
- **CLI user**
- [Streamlit app](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py): `app.py`
- **Hugging Face DECIMER**
- [SMILES validation](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py): `app.py`
- [Clipboard copy](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py): `app.py`
- [Molecule preview](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/app.py): `app.py`
- [Image converter](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py): `image2smiles.py`
- [Local DECIMER](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py): `image2smiles.py`
- [SMILES validation](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py): `image2smiles.py`
- [Clipboard copy](https://github.com/snmiitb-bit/chem-image-to-smiles/blob/main/image2smiles.py): `image2smiles.py`

## Connections

- Web user → Streamlit app: uploads image (evidence: `app.py`)
- Streamlit app → Hugging Face DECIMER: posts image bytes (evidence: `app.py`)
- Hugging Face DECIMER → Streamlit app: returns prediction (evidence: `app.py`)
- Streamlit app → SMILES validation: validates prediction (evidence: `app.py`)
- Streamlit app → Clipboard copy: copies SMILES (evidence: `app.py`)
- Streamlit app → Molecule preview: renders molecule (evidence: `app.py`)
- CLI user → Image converter: provides image path (evidence: `image2smiles.py`)
- Image converter → Local DECIMER: predicts SMILES (evidence: `image2smiles.py`)
- Image converter → SMILES validation: validates prediction (evidence: `image2smiles.py`)
- Image converter → Clipboard copy: copies SMILES (evidence: `image2smiles.py`)
