# Which library for a Monte Carlo web app?

**URL:** <https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397>\
**Category:** Visualization\
**Created:** [December 1, 2021, 6:52pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397 "2021-12-01T18:52:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://discourse.julialang.org/u/patrick)\
**Post date:** [December 1, 2021, 6:52pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/1 "2021-12-01T18:52:30Z")

</div>

Let me preface this by saying that I’m a Julia novice, and I have never done any web dev or serious plotting. So, a quick pointer to the right packages for my needs should suffice as an answer.

In a nutshell: I want to write a website that uses Julia to provide an interactive real-time simulation of the Ising model similar to [this one](https://demonstrations.wolfram.com/The2DIsingModelMonteCarloSimulationUsingTheMetropolisAlgorit/) done in Mathematica. What packages are best suited to this purpose?

Key features I would like: sliders and buttons that control parameters of the simulation, aesthetically pleasing graphics, and the ability to embed auxiliary graphs of various parameters of the simulation (all updated in real time). I’d also like the ability to do 3D graphics, in order to simulate the 3D Ising model.

Some Googling suggests that Makie for visualization and Genie for the web stuff is one solution. Is it the best? It seems that maybe generating javascript directly with something like VegaLite.jl might be easier, but that this comes at the cost of less control/power for the visuals.

I see that InteractiveDynamics.jl has an interactive orbit diagram using Makie that’s pretty close to what I’m looking for (though not real-time): [https://juliadynamics.github.io/InteractiveDynamics.jl/dev/od/](https://juliadynamics.github.io/InteractiveDynamics.jl/dev/od/).

Any advice is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [December 1, 2021, 7:39pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/2 "2021-12-01T19:39:25Z")

</div>

If this is just for yourself to run locally, you could make a [Pluto](https://github.com/fonsp/Pluto.jl) notebook and use the [PlutoUI](https://github.com/JuliaPluto/PlutoUI.jl) package for the interface.

If you want to make something that be more easily accessed by someone over the internet, you can look at dashboard packages like [Dash.jl](https://dash-julia.plotly.com/) and [Stipple.jl](https://github.com/GenieFramework/Stipple.jl). Dash relies on Plotly’s tools, while Stipple is uses the Genie framework.

---

<div class="post-metadata">

**Author:** ![sashmit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sashmit/32/18791_2.png) [@sashmit](https://discourse.julialang.org/u/sashmit)\
**Post date:** [December 1, 2021, 7:58pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/3 "2021-12-01T19:58:56Z")

</div>

You can also use Pluto in non-local environments:

> **[GitHub - JuliaPluto/PlutoSliderServer.jl: Web server to run just the \`@bind\`...](https://github.com/JuliaPluto/PlutoSliderServer.jl)**
>
> Web server to run just the \`@bind\` parts of a Pluto.jl notebook - GitHub - JuliaPluto/PlutoSliderServer.jl: Web server to run just the \`@bind\` parts of a Pluto.jl notebook

which is used for example in this class:  
[https://computationalthinking.mit.edu/Spring21/simulating\_component\_failure/](https://computationalthinking.mit.edu/Spring21/simulating_component_failure/)

it is even getting a serverless version soon:

> <https://github.com/JuliaPluto/PlutoSliderServer.jl/pull/29>
>
> This draft PR will find all possible combinations of sliders, run those, and sav…e the results to a file. \*\*THIS MEANS that you will be able to get most of the coolness of PlutoSliderServer without having to run a server!\*\*
> 
> These files, and their filenames, exactly match the requests that the sliderserver would get if it was actually running. This means that you can \*\*statically serve the folder with generated files\*\*, and it respond to the \`GET\` requests just like a running slider server.
> 
> E.g., currently our sliderserver responds to requests like this:
> 
> \`GET ./staterequest/\<notebook hash\>/\<bond values dict msgpack base64\>\`
> 
> which exactly matches the request to access the generated file from our static server!
> 
> 
> You need the matching changes to Pluto.jl by @Pangoraw https://github.com/fonsp/Pluto.jl/pull/1600
> 
> TODO
> \- \[\] More rigorous testing
> - Huge product iterators
> - Huge list of possibilities
> - Large filenames
> \- \[x\] Handle NotGiven and InfinitePossibilities correctly
> \- \[\] Config for maximum connection
> \- \[x\] Estimate total file size and compute time by doing a random sample
> \- \[x\] Terminal UI with tips to make the number of combinations smaller
> \- \[x\] Merge Pluto PRs https://github.com/fonsp/Pluto.jl/pull/1703 and https://github.com/fonsp/Pluto.jl/pull/1600, add version compat bound
> \- \[\] Use \`Pluto.possible\_bond\_values\_length\` during estimate
> \- \[x\] #45
> \- \[\] \*\*Put this in the cache system\*\*
> \- \[\] Figure out the workflow with github actions
> \- \[\] Enable a hybrid mode for sliderserver: use fully cached version of a notebook if possible, leave running otherwise
> 
> \<img alt="Schermafbeelding 2021-11-30 om 18 43 01" src="https://user-images.githubusercontent.com/6933510/144099802-f2d908f6-e5de-4817-a65d-d21da313331d.png"\>
> 
> Demo video of debugging GUI:
> 
> https://youtu.be/gDZ33Lpj8Hw

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://discourse.julialang.org/u/patrick)\
**Post date:** [December 1, 2021, 10:45pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/4 "2021-12-01T22:45:22Z")

</div>

Thanks for the replies.

Pluto is not really suitable for my needs, since I don’t want to expose the underlying code, only the widget. (Not that I’m trying to hide anything, just that it’s messy.)

Indeed, I’m trying to make something that could be hosted online. Do Dash or Stipple have any particular advantages relative to Mackie? Are they capable of visualizing real-time simulations? All the examples I could find looked like static graphs that were updated in response to user input.

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [December 1, 2021, 11:06pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/5 "2021-12-01T23:06:49Z")

</div>

I think you should be able to make [animations in plotly,](https://plotly.com/python/animations/#animated-figures-in-dash) which means you should be able to embed animations of a simulation in either Dash.jl or Stipple (via the [StipplePlotly](https://github.com/GenieFramework/StipplePlotly.jl) package)

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [December 1, 2021, 11:08pm UTC](https://discourse.julialang.org/t/which-library-for-a-monte-carlo-web-app/72397/6 "2021-12-01T23:08:55Z")

</div>

It looks like there might be a way to create a web page using the WGLMakie package, but that looks like it would involve more JavaScript know-how.

[http://juliaplots.org/WGLMakie.jl/stable/](http://juliaplots.org/WGLMakie.jl/stable/)
