Skip to content

Getting Started

Golam Kuadir Khan Prince edited this page Nov 19, 2026 · 1 revision

Getting Started

The Electron Scattering Simulator can be accessed online, installed as an offline Progressive Web App (PWA), executed locally via Node.js, or deployed as a container with Docker.


1. Using Online

You can access the hosted application directly without any local installation:

All calculations default to the in-browser WebAssembly engine, ensuring client-side execution without transmitting simulation parameters to external servers.


2. Installing as a Progressive Web App (PWA)

The simulator is built with a standard Web App Manifest (public/manifest.json) and a dedicated Service Worker (public/sw.js), allowing installation as a standalone desktop or mobile application.

Installation Instructions

  1. Open https://electron-scattering.onrender.com/ in a supported modern browser (Chrome 87+, Edge 88+, Firefox 114+, Safari 15+).
  2. Click the install icon in the address bar (or select Install App in the header banner).
  3. Confirm the installation prompt. The application will launch in its own standalone window without browser chrome.

Offline Operation

Once loaded, the Service Worker precaches the frontend shell, stylesheets, icons, and the complete ELSEPA WebAssembly package (elsepa.js, elsepa.wasm, and elsepa.data). Calculations can be run entirely offline without internet connectivity.


3. Running Locally

System Prerequisites

  • Node.js: Version ^20.19.0 || >=22.12.0 (Node 22 LTS or Node 24 recommended).
  • npm: Version 9 or higher (bundled with Node.js).
  • Modern Web Browser: Supporting WebAssembly, Web Workers with ES modules ({ type: "module" }), and Service Workers.
  • (Optional) gfortran: GCC Fortran compiler. If installed and present on your system PATH, the Express server compiles the Fortran sources on first launch and executes native binaries. If gfortran is absent, calculations automatically run via in-browser WebAssembly.

Step-by-Step Local Setup

  1. Clone the repository:

    git clone https://github.com/The-Studio-of-Sadiq/Electron-Scattering.git
    cd Electron-Scattering
  2. Install exact dependencies:

    npm ci
  3. Start the local development server:

    npm run dev

    Open your browser at http://localhost:3000.

    This command launches the Express server with integrated Vite middleware. If gfortran is detected, the server compiles fortran/ on demand into native executables (elsepa_exec and elscatm_exec).

  4. Running in browser-only mode (static): If you do not require the backend server or native Fortran execution, you can run Vite directly:

    npx vite
  5. Building for production:

    npm run build

    This generates the optimized static assets in dist/ and bundles the production server into dist/server.cjs. To serve the production bundle locally:

    npm start

4. Running with Docker

Pre-built container images containing Node.js, gfortran, and precompiled ELSEPA binaries are published to the GitHub Container Registry (GHCR).

Pull and Run from GHCR

docker run -p 3000:3000 ghcr.io/the-studio-of-sadiq/electron-scattering:latest

Access the application at http://localhost:3000.

Build and Run Locally

To build the multi-stage Docker image from source:

docker build -t elsepa-simulator .
docker run -p 3000:3000 elsepa-simulator

The containerized environment compiles elscata.f and elscatm.f using gfortran -O2, provides native execution through the Express API, and serves the production React bundle on port 3000.

Clone this wiki locally