1

Background:

I'm writing a clinical trials simulator. The user defines future trial options, eg a trial with 100 placebo patients, 200 treatment patients, "optimistic" outcome scenario, etc. There can be 1-20,000 of such options. For each option 10,000 - 100,000 trial results are simulated. The simulated data are later used for analytics, for each assumed option.

Implementation:

It's an Angular/Electron desktop app (in future, there'll be a web extension). The front-end sends a REST API request with trial options. The Python back-end performs the simulations in parallel. It stores the results in a PostgreSQL database, with a row per option. The database is either on the user laptop or on external storage. There is a single user working on a simulation.

Performance:

The simulations can take long, with their results needing a lot of memory. Therefore once the user adds the trial options, I'd only simulate for these additions, rather than for every option. I also allow to abort a running simulation.

Data consistency:

What the user assumes the inputs - trial options - are must coincide with the inputs to the latest saved simulations (and to subsequent analytics). Therefore I want to always notify the user about a difference between the front-end and the database. So analytics would be disabled if there's a difference.

Question:

How could I ensure this consistency? For example, the front-end could track three sets of trial options: (1) for the finished simulations; (2) for simulations in progress and (3) for current user inputs without started simulations. But this seems fragile. Also, I'm not comfortable with using the front-end, rather than the back-end and database as the source of truth. Does this front-end approach make sense, or should I go with the back-end? Or what else would work better?

Note: Architecting a predictive modeling software discusses a similar software, although with stable user inputs and a focus on performance. Besides this, I haven't found much relevant info on SE.

2

What the user assumes the inputs - trial options - are […]

Don't allow the user to make such assumptions. With more that a handful of options, the user will guaranteed get some of them wrong.

Instead, let the user give each combination of options they want to use a descriptive name before starting a simulation. Then the user can recall that set of options later by using that name.

If you intend to move the backend into the cloud at some time in the future, then you should prepare the application also for a workflow where a simulation is started from computer A and the results are inspected from computer B. That could be precluded by extensive use of front-end storage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.