Get PI via the Monte Carlo method
The front-end is built using Svelte + TypeScript. Follow these steps to run:
-
Create a
.envfile. -
Set the key in
.env:PUBLIC_BASEURL=http://127.0.0.1:8000 -
Run
npm i, thennpm run dev.
The back-end is built using FastAPI and Python. Follow these steps to run:
- Create a
.env.devfile based on the.env.examplefile. - Run one of the following:
docker build -t montecarlo .followed bydocker run -p 8000:8000 montecarlo- or
poetry shellfollowed byuvicorn api.main:app --reload
Here are some useful resources I used to complete this task:
- Svelte documentation - since it was my first time writing something with Svelte (I liked it).
- Python multiprocessing - I tried to improve the performance of the API when requesting certain random points.
- NumPy documentation.
- Monte Carlo (Wikipedia).