CAD for Drug Design
Hi all! I've been using Convex as our backing DB for a tool we've been working on for a while. I'm working with a biotech that's on track to entire phase 1 clinical trials with a novel therapeutic for leukemia and through our journey we built some internal tech to help improve our computational modeling.
Over time, we decided to spin it off as a standalone product. The focus right now is mostly around white boarding and structuring information (IE: are the structural biologists looking at the problem in a way that creates blind spots your chemist might notice?)
The goal is to make it a communication tool initially, but then help inform and guide early phase biotech R&D. Our focus is very much on preclinical work to try and prevent unnecessary experiments in lab.
Anyway, figured I'd share progress here. Convex ended up fitting like a glove for our use case.
Encoding state for proteins, molecules, etc is pretty complicated. We built an entity component system (ECS) around Convex that lets us basically add components on the fly and allows the consumer of the data to be more opinionated than the producer. In other words, we don't need a complex unified data model to represent the protein / molecule. Instead we have a convex table representing each component of the entity and infer the entity type from the components available.
Tbh, Convex is the only reason we were able to get something this complex into a real time DB since otherwise we'd have to spend ages wrestling with an ORM, table structures, sql, etc.
May end up writing a blog post on how we did ECS with convex for this use case, since it's pretty interesting.

11 Replies
Here's a video (apologies, uncompressed so it's pretty big)
You'll notice at the end the card on the canvas doesn't load, we're being rate limited by a public data provider for these structures. Working on a fix for that 🙃
It's super early stages. Will be a while before it's ready even for an alpha, figured I'd share anyway
Just Realized we have a mutual friend, This looks pretty intresting! I might not be a chemist but I can see potential for this in Engineering tools, Great job!! You might be one of the people whom might benifit from the #local-sync
very cool. i'd love to read about how you went about implementing it.
We built an entity component system (ECS) around Convex that lets us basically add components on the fly and allows the consumer of the data to be more opinionated than the producer.i've been thinking about this since you mentioned it last time. i explored something approaching this idea some time ago, when thinking about representing graph-like structures in convex. i've been looking for an excuse to try it again, maybe by adding ReactThreeFiber into the mix i'll come up with something...
This is awesome and yes to a blog post please
Oh yeah! Simon is awesome, met him in a marketing discord I used to be an admin for. Really smart guy.
Also, I'm super interested in local sync. Our business model is similar to a game engine like Unreal (if you're familiar) where we charge royalties for products created with our system instead of a monthly charge. The thought process there is that drug design companies aren't worth anything until they have a drug on the market, so we want the tool accessible to everyone with an idea then make revenue off the drugs that go to market. Makes our platform attractive for super early stage R&D.
But because of that model, we really want to keep our overhead cost as low as possible. Local first is on the roadmap for that.
We're currently using react three fiber for our project and (soon) planning on representing a graph in the canvas view. We're really trying to focus on information architecture. The ideal case would be a scientist working in the system passively creates a knowledge graph of their concept just by doing their work within the platform.
Discussing things like bond angles, atomic distances, etc then linking the ideas together in the tool. If done right, the hope is we can use that knowledge graph to inform models that can create molecular dynamic simulations.
Basically, if we have enough information about how we expect two molecules to move, we can keyframe it based on the comformations (the position of the protein) publicly available. Our example we're demoing with is the movement of a kinase during ATP uptake, but we're really focusing our platform at new and novel drugs. Drugs for things that we don't have a clear understanding for the underlying biological mechanisms.
The whole hypothesis underlying our tool is that the better the scientist can describe those mechanisms and connect them to the target they're trying to affect, the more successful they'll be in lab when they conduct in-vitro experiments.
Will do!! We have a big demo coming up (presenting to a former Nobel laureate and some major pharma players in a month!) then we're opening a funding round at the start of the next quarter. Trying to get this in a demoable state all while having a newborn is eating most of my time, but convex actually lends itself pretty well to ECS principles like composition. It's definitely on my list of todos haha
I did end up doing something really silly where I'm constructing my component arrays inside the client instead of inside a convex function. This has led to uhhh less than optimal function calls haha. I have 5k function calls for effectively only 10 users which is way too high.
In the process of moving a lot of the component construction to the convex function since components are stored in individual tables right now.

This is not bad numbers for prod, it seems optimized well!
Simon is an Intelligent fellow yeah, I'm super interested to know how you built this from the ground up, you've put great thought into this it looks like
Alright so, one of the cool things about convex is that iterating over multiple queries / mutations is relatively cheap. That's actually perfect for structures of arrays since it lets me build my arrays convex side.
Let's say I want to create a new entity, it's common to represent them as a sparse set. The sparse array has an index that represents the potential for any entity to have a component. The sparse array has a pointer to a packed array which only contains the entities which have a component. We do this so that way we minimize the size of the list we need to traverse if we need to get all entities that have, let's say, component A. (Image for reference)
In Convex, I can do something like this pretty "free"
Where I iterate over every single component table and increment the sparse array. If I wanted to add some components as a part of the creation logic I can do it here as well and it only counts as a single function call AND (most importantly) it's a single transaction!
Convex is cool 🙂

Progress 🙂
since otherwise we'd have to spend ages wrestling with an ORM, table structures, sql, etc.makes me love convex so much more ❤️