28  Creating Web Apps

As part of the HSMA programme, we teach how to use the Streamlit web application framework to produce a front-end for a discrete event simulation model.

This can be a hugely powerful way of distributing your model. By creating a web application, stakeholders can interact with the model and adjust parameters themselves, seeing the impact this has. A carefully designed web app can guide them through the process of understanding the impact of different changes to the system.

It is beyond the scope of this book to give a full treatment of this topic at this time, though it may be expanded on in the future (by the end of 2024).

In the meantime, there are several resources available to you.

28.1 Video guide: creating a streamlit web app interface for a DES model

This video is the masterclass on Streamlit interfaces from the fifth round of the HSMA programme. This is delivered by Tom Monks, another member of the PenCHORD team.

The classes and structure used for the model are very slightly different to the style used in this book, but overall the techniques are very applicable.

28.1.1 Book

A book has also been written to accompany the above tutorial.

The book can be accessed (here)[https://health-data-science-or.github.io/simpy-streamlit-tutorial/content/03_streamlit/01_intro.html].

28.2 Example apps

28.2.1 The DES Playground

The following app contains a range of pages that allow users to explore a DES model of growing complexity.

You can see the range of sliders and inputs that you can make available to your end users.

Warning

Note that this link will not work if you are viewing this book in Firefox. All other major browsers should work, including mobile browsers.

The full code can be seen here.

Look at the code within the pages subfolder to see how different features are implemented.

Other features that may be useful to adapt for your own use include - the ability to save and compare the results from multiple scenarios - a range of interactive visualisations of simulation metrics

28.2.2 The HSMA SimPy Example Library

As part of the SimPy visualisation library project, a range of different SimPy models have been created with a Streamlit frontend.

The code for all of these examples can be explored in this Github Repository.

In each case, the code for the model classes, simulation execution and simulation summary functions can be found inside a subfolder within the examples folder.

Note that again the classes and format used for these models differs slightly from the examples given in this book, but are fundamentally very similar so should be possible to adapt.