# rdkit/rdkit-js architecture

> Architecture diagram of the GitHub repository rdkit/rdkit-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rdkit/rdkit-js
- Repository: https://github.com/rdkit/rdkit-js

## Overview

##### Project Type and Purpose
- This is an open-source JavaScript/TypeScript library (“@rdkit/rdkit”) that packages a subset of the RDKit C++ core as a WebAssembly (WASM) module and provides a thin JS wrapper.
- It also includes multiple front-end example apps (plain JS, React, Vue, Angular, Next.js) plus Node and TS examples, all demonstrating how to consume the WASM API.
- CI/CD pipelines automate building the WASM, packaging to NPM, publishing new versions, and deploying the example websites.

##### File-Structure Analysis
Top level:
– “Dockerfile”, “.github/workflows/docker-build.yml”, “azure-pipelines.yml”: container builds & CI scripts
– “scripts/”: shell scripts to compile RDKit → WASM & run CI steps
– “docs/”: static HTML docs/site
– “examples/”: subfolders for each framework (angular, react, vue, nextjs, javascript, node, typescript)
– “package.json”, “.npmignore”, “yarn.lock”: NPM packaging
– “typescript/”: TS definition walkthrough

##### README Insights
- Scope: NPM builds/releases of core WASM, website deployments of examples, extra utilities atop core.
- Core WASM code lives in upstream RDKit repo; this repo compiles & packages a MinimalLib subset.
- Examples load “dist/RDKit_minimal.js” + “.wasm” via initRDKitModule().

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Environment"
        Dev["Developer Environment (IDE, Git)"]:::external
    end

    subgraph "Source Repositories"
        ThisRepo["This Repo (JS wrapper + build scripts + examples)"]:::core
        RDKitUpstream["Upstream RDKit C++ (MinimalLib)"]:::external
    end

    Dev -->|push code| ThisRepo
    ThisRepo -->|depends on| RDKitUpstream

    subgraph "Build & Packaging Pipeline"
        BuildScript["WASM Build (Emscripten)"]:::buildCI
        Docker["Build Isolation Docker Container"]:::buildCI
    end

    ThisRepo --> BuildScript
    BuildScript --> Docker

    subgraph "CI/CD Services"
        GHActions["GitHub Actions CI"]:::buildCI
        AzurePipelines["Azure Pipelines CD"]:::buildCI
        Vercel["Vercel Deploy"]:::external
    end

    Docker --> GHActions
    GHActions --> AzurePipelines
    GHActions -->|on merge| Vercel

    subgraph "NPM Registry"
        NPMRegistry["@rdkit/rdkit Package"]:::cylinder
    end

    AzurePipelines -->|publish| NPMRegistry

    subgraph "Example Consumer Apps"
        JSApp["Plain JS Example"]:::examples
        ReactApp["React Example"]:::examples
        VueApp["Vue Example"]:::examples
        AngularApp["Angular Example"]:::examples
        NextApp["Next.js Example"]:::examples
        NodeApp["Node.js Scripts"]:::examples
        TSApp["TypeScript Walkthrough"]:::examples
        StaticDocs["Static Docs Site"]:::examples
    end

    NPMRegistry --> JSApp
    NPMRegistry --> ReactApp
    NPMRegistry --> VueApp
    NPMRegistry --> AngularApp
    NPMRegistry --> NextApp
    NPMRegistry --> NodeApp
    NPMRegistry --> TSApp
    ThisRepo --> StaticDocs

    subgraph "End Users"
        EndUser["End Users"]:::external
    end

    JSApp -->|load WASM+JS| EndUser
    ReactApp --> EndUser
    VueApp --> EndUser
    AngularApp --> EndUser
    NextApp --> EndUser
    NodeApp --> EndUser
    TSApp --> EndUser
    StaticDocs --> EndUser

    click BuildScript "https://github.com/rdkit/rdkit-js/blob/master/scripts/build_rdkitjs.sh"
    click Docker "https://github.com/rdkit/rdkit-js/tree/master/Dockerfile"
    click GHActions "https://github.com/rdkit/rdkit-js/blob/master/.github/workflows/docker-build.yml"
    click AzurePipelines "https://github.com/rdkit/rdkit-js/blob/master/azure-pipelines.yml"
    click ThisRepo "https://github.com/rdkit/rdkit-js/blob/master/package.json"
    click StaticDocs "https://github.com/rdkit/rdkit-js/tree/master/docs/"
    click TSApp "https://github.com/rdkit/rdkit-js/blob/master/typescript/index.d.ts"
    click AngularApp "https://github.com/rdkit/rdkit-js/tree/master/examples/angular/"
    click ReactApp "https://github.com/rdkit/rdkit-js/tree/master/examples/react/"
    click VueApp "https://github.com/rdkit/rdkit-js/tree/master/examples/vue/"
    click NextApp "https://github.com/rdkit/rdkit-js/tree/master/examples/nextjs/"
    click JSApp "https://github.com/rdkit/rdkit-js/tree/master/examples/javascript/"
    click NodeApp "https://github.com/rdkit/rdkit-js/tree/master/examples/node/"

    classDef buildCI fill:#D0E8FF,stroke:#3299FF,color:#000
    classDef core fill:#CCCCCC,stroke:#999999,color:#000
    classDef examples fill:#DFFFD0,stroke:#88CC00,color:#000
    classDef external fill:#E0D0FF,stroke:#A020F0,color:#000
    classDef cylinder fill:#fff7a8,stroke:#f2c12e,color:#000
```
