Scientific software

Mercurion

I designed Mercurion to find, edit and analyse a molecule in one workspace. The Angular client queries the catalogue through GraphQL. In the editor, results from the Python service appear alongside the structure.

Mercurion editor showing the structure of aspirin alongside the analysis panel.
Context
Mercurion is an ongoing personal project. Over 18 months I designed and built the web application and its scientific computing service in Python. The MercurionWeb repository alone has over 3,400 commits.
Goal
Start from a reference molecule, develop a working structure and keep it in a personal collection so the analysis can continue in a later session.
Solution
The NestJS API connects the interface to the data and delegates calculations to MercurionTox21 over NATS. This lets me update the machine learning model independently of the editor.

Technology stack

GraphQL for the catalogue and collections

I defined the schema in NestJS and serve it with Mercurius on Fastify. With Apollo Angular, search requests just a few fields per result. Opening a molecule runs a second query for its structure, synonyms and properties. Mutations save edits and add the molecule to collections.

The molecular editor in Angular

I integrated Ketcher into the Angular interface to draw and edit structures. RxJS coordinates edits and analysis requests. PrimeNG components and Tailwind CSS place the results alongside the drawing so users can consult them as they edit.

REST APIs, Socket.IO events and sessions

I implemented JWT authentication, second-factor verification and session revocation using Redis. The client uses REST for sign-in and analysis requests. Socket.IO delivers notifications and tells the client when a session expires. Both interfaces have TypeScript contracts shared by client and server.

Text and vector search

Meilisearch supports text searches of the ChEMBL catalogue with filters for molecule type and molecular weight. I use TypeORM for persistence in PostgreSQL. To find similar molecules among those already indexed, pgvector compares their vector representations using cosine distance.

Scientific computing in Python

The backend sends requests to MercurionTox21 over NATS. The service processes structures with RDKit and looks up their names in PubChem. A separate pipeline prepares the Tox21 data, trains and evaluates a neural network in PyTorch, and exports the model used for inference.

Containers and automated checks

Docker Compose starts the services and nginx routes web traffic. In GitHub Actions, I use GraphQL Code Generator to check that Angular operations and generated types match the NestJS schema. The pipeline also runs unit and end-to-end tests, checks REST and Socket.IO contracts, and starts the containers for smoke tests.

Features

  • Find aspirin in ChEMBL and open its record to see the structure, synonyms and properties.
  • Edit the structure and inspect its analysis and toxicity predictions.
  • Save the edited molecule to a collection and reopen it in a later session.
Aspirin search results in Mercurion’s ChEMBL catalogue.