{"id":30899894,"url":"https://github.com/yaptide/geant-web-application","last_synced_at":"2026-02-12T07:07:22.318Z","repository":{"id":312917540,"uuid":"1049290757","full_name":"yaptide/geant-web-application","owner":"yaptide","description":"Repository holding main Geant4 WebAssembly  module","archived":false,"fork":false,"pushed_at":"2025-09-18T22:17:38.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-19T00:38:43.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaptide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-02T18:59:00.000Z","updated_at":"2025-09-18T22:17:42.000Z","dependencies_parsed_at":"2025-09-02T21:04:57.198Z","dependency_job_id":"b6badefb-a736-4ec5-ba4d-c8e06e9e187a","html_url":"https://github.com/yaptide/geant-web-application","commit_stats":null,"previous_names":["yaptide/geant-web-application"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yaptide/geant-web-application","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaptide%2Fgeant-web-application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaptide%2Fgeant-web-application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaptide%2Fgeant-web-application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaptide%2Fgeant-web-application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaptide","download_url":"https://codeload.github.com/yaptide/geant-web-application/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaptide%2Fgeant-web-application/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29360771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-09T04:11:41.175Z","updated_at":"2026-02-12T07:07:22.313Z","avatar_url":"https://github.com/yaptide.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Geant4 WebAssembly module (geant-web-application)\n\nThis repository builds a **Geant4** simulation runtime into a **WebAssembly (WASM)** module intended to run in a **Web Worker** (browser-side) and be distributed together with the required **Geant4 datasets**.\n\nBesides the C++ sources, the repository includes scripts that:\n\n* bootstrap a reproducible Emscripten toolchain + dependencies (Expat, Xerces-C, Geant4)\n* package Geant4 datasets for Emscripten’s virtual filesystem\n* publish build artifacts and datasets to **Cyfronet S3 / Ceph**\n* update a separate “stubs” repository with the generated JS glue code and TypeScript typings\n\n\u003e **Audience:** This repo is primarily a *build/artifact* repository (WASM module + datasets), not a full web UI.\n\n## What gets produced\n\nWhen built for Emscripten, the output includes:\n\n* `geant4_wasm.wasm` – the WebAssembly module\n* `geant4_wasm.js` – Emscripten JS loader (ES module export name: `createWasmModule`)\n* `geant4_wasm.d.ts` – generated TypeScript typings\n* dataset payloads and preload scripts under `build/data/` and `build/js/`\n* optional “lazy loading” metadata JSON files under `build/lazy_files/`\n\n## Repository layout\n\n* `geant4.cpp / geant4.hpp` – WASM-facing API surface (Emscripten embind)\n* `include/` + `src/` – Geant4 user classes (physics list, generator, actions)\n* `scripts/setup_env.js` – injected with `--pre-js` to set Geant4 dataset env vars in the WASM runtime\n* `utils/lazy_json_generator.py` – generates JSON manifests used for lazy dataset loading\n* `prepare.sh` – downloads \u0026 builds the toolchain/deps and stages datasets\n* `compile_application.sh` – builds the WASM module and stages artifacts\n* `publish.sh` – uploads staged artifacts to S3 and configures CORS/policy\n* `publish_repo.sh` – copies generated stubs (JS + d.ts + preload scripts) into `geant-web-stubs`\n\n## Prerequisites\n\n### For the provided scripts\n\nThe scripts assume an environment with:\n\n* **Environment Modules** (`module add ...`) providing at least `cmake` and `rclone`\n* `wget`, `tar`, `git`, `npm`, `python`\n* outbound network access to download Geant4 datasets and sources\n* a writable staging area referenced by `MEMFS`\n\n\u003e If you’re *not* on an HPC environment that provides `module`, you can still build locally, but you’ll need to adapt the scripts (see `docs/DEVELOPMENT.md`).\n\n### Versions pinned by `prepare.sh`\n\n* Emscripten SDK: **4.0.13**\n* Geant4: **11.3.2**\n* Expat: **2.6.4**\n* Xerces-C: **3.3.0**\n* Geant4 datasets (subset staged by default):\n  * `G4NDL.4.7.1` → `G4NDL4.7.1`\n  * `G4EMLOW.8.6.1` → `G4EMLOW8.6.1`\n  * `G4PhotonEvaporation.6.1` → `PhotonEvaporation6.1`\n  * `G4ENSDFSTATE.3.0` → `G4ENSDFSTATE3.0`\n  * `G4SAIDDATA.2.0` → `G4SAIDDATA2.0`\n  * `G4PARTICLEXS.4.1` → `G4PARTICLEXS4.1`\n\n## Quickstart (scripted build \u0026 publish)\n\nThe happy path (as intended by this repo) is:\n\n```bash\n./prepare.sh\n./compile_application.sh\n./publish.sh\n./publish_repo.sh\n```\n\n### Required environment variables\n\nThe scripts rely on `MEMFS` pointing to a writable working directory used for downloads, builds, and staging.\n\nExample:\n\n```bash\nexport MEMFS=/path/to/fast/scratch\n```\n\n### S3 credentials (.env)\n\n`publish.sh` reads S3 credentials through `setup_env.sh` which expects a `.env` file containing `RCLONE_CONFIG_*` variables.\n\nTemplate:\n\n```env\nRCLONE_CONFIG_GEANT4_WEB_TYPE=s3\nRCLONE_CONFIG_GEANT4_WEB_PROVIDER=Ceph\nRCLONE_CONFIG_GEANT4_WEB_ACCESS_KEY_ID=\u003caccess_key_id\u003e\nRCLONE_CONFIG_GEANT4_WEB_SECRET_ACCESS_KEY=\u003csecret_key\u003e\nRCLONE_CONFIG_GEANT4_WEB_ENDPOINT=https://s3p.cloud.cyfronet.pl\nRCLONE_CONFIG_GEANT4_WEB_REGION=\nRCLONE_CONFIG_GEANT4_WEB_LOCATION_CONSTRAINT=\nRCLONE_CONFIG_GEANT4_WEB_ACL=private\n```\n\n\u003e `setup_env.sh` also generates a local `.s3cfg` used by `s3cmd` for setting bucket CORS and policy.\n\n## Using the WASM module from JavaScript\n\nThe module is compiled with:\n\n* ES module export name: **`createWasmModule`**\n* environment: **`worker`**\n* runtime methods exported: **`FS`** and **`addFunction`**\n\nHigh-level usage pattern:\n\n1. Instantiate the module (`await createWasmModule(...)`).\n2. Write your input files (GDML + macro) into Emscripten FS.\n3. Optionally register a progress callback.\n4. Call `Geant4GDMRun(gdmlPath, macroPath)`.\n5. Read the resulting `output.root` from FS.\n\nExample (simplified):\n\n```js\nimport createWasmModule from \"./geant4_wasm.js\";\n\nconst mod = await createWasmModule({\n  // Adjust if you host .wasm/.data files on a CDN\n  locateFile: (p) =\u003e new URL(p, self.location.href).toString(),\n});\n\n// Progress callback (called every 100 events)\nconst cbPtr = mod.addFunction((eventId) =\u003e {\n  console.log(\"progress event\", eventId);\n}, \"vi\");\nmod.Geant4SetProgressFunction(cbPtr);\n\n// Provide inputs\nmod.FS.writeFile(\"/geometry.gdml\", gdmlText);\nmod.FS.writeFile(\"/run.mac\", macroText);\n\n// Run\nmod.Geant4GDMRun(\"/geometry.gdml\", \"/run.mac\");\n\n// Retrieve output produced by G4AnalysisManager\nconst rootBytes = mod.FS.readFile(\"output.root\");\n```\n\n\u003e Geant4 dataset environment variables (e.g. `G4LEDATA`, `G4NEUTRONHPDATA`, …) are set by `scripts/setup_env.js` at startup.\n\n## Documentation\n\n* `docs/DEVELOPMENT.md` – building locally vs in an HPC/modules environment\n* `docs/ARCHITECTURE.md` – how the WASM build is wired (CMake + Emscripten + datasets)\n* `docs/API.md` – runtime API exposed to JS (inputs/outputs)\n* `docs/DEPLOYMENT.md` – publishing to S3 and updating stub artifacts\n* `docs/TROUBLESHOOTING.md` – common build/runtime issues\n\n## Contributing\n\nSee `docs/DEVELOPMENT.md` for build conventions and tips.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaptide%2Fgeant-web-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaptide%2Fgeant-web-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaptide%2Fgeant-web-application/lists"}