# minmyatngwe/tempo_xrf_repo architecture

> Architecture diagram of the GitHub repository minmyatngwe/tempo_xrf_repo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/minmyatngwe/tempo_xrf_repo
- Repository: https://github.com/minmyatngwe/tempo_xrf_repo

## Overview

TEMPO XRF is a prototype workflow for configuring and running Geant4 X-ray fluorescence simulations, processing simulated detector output, and inspecting geometry and tracks in a browser. The documented user path runs from Streamlit configuration through the simulation launcher and Geant4 run, then into detector-response processing and visualization. The graph includes documented geometry, physics, source, and browser-debug capabilities; excerpts do not expose every frontend/backend handoff, so uncertain links are omitted.

Main entry points: [`sim.cpp`](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/sim.cpp) (Geant4 Entry), [`python_code/frontend/main.py`](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/main.py) (Streamlit Navigation), [`python_code/frontend/views/simulation.py`](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/simulation.py) (Run Controller), [`src/detectorConstruction.cpp`](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/detectorConstruction.cpp) (World & Detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Configuration UI"]
  node_ui["Streamlit Navigation<br/>[main.py]"]
  node_geometry_ui["Geometry Inputs<br/>[geometry.py]"]
  node_geometry_helpers["Geometry Editors<br/>[frontend_helper.py]"]
  node_tube_ui["X-ray Tube Setup<br/>[xray_tube.py]"]
  node_physics_ui["Physics Settings<br/>[physics_engine.py]"]
  node_physics_state["Physics Config State<br/>[physics_state.py]"]
  node_simulation_ui["Run Controller<br/>[simulation.py]"]
end

subgraph group_simulation["Geant4 Simulation"]
  node_config["Simulation Config"]
  node_entry["Geant4 Entry<br/>[sim.cpp]"]
  node_messenger["Runtime Commands"]
  node_construction["World &amp; Detector"]
  node_source["Photon Generator"]
  node_physics["XRF Physics<br/>[physicsList.cpp]"]
  node_actions["Run Actions"]
  node_sensitive["Detector Scoring"]
  node_browser_export["Geometry Export"]
  node_tracks_export["Track Export"]
end

subgraph group_analysis["Detector Analysis"]
  node_root_data["Simulation ROOT Output"]
  node_response["Detector Response<br/>[pipeline.py]"]
  node_results_ui["Results &amp; Noise UI"]
  node_xray_tool["X-ray Spectrum Tool<br/>[xray_tube.py]"]
end

subgraph group_viewer["Browser Debugging"]
  node_three_viewer["Three.js Viewer<br/>[main.js]"]
  node_geometry_json["Geometry JSON"]
  node_tracks_json["Tracks JSON<br/>[xrf_tracks.json]"]
end

node_user(("Researcher"))
node_geant4["Geant4 Runtime"]

node_user -->|"configures"| node_ui
node_ui -->|"opens"| node_geometry_ui
node_ui -->|"opens"| node_tube_ui
node_ui -->|"opens"| node_physics_ui
node_ui -->|"opens"| node_simulation_ui
node_ui -->|"opens"| node_results_ui
node_geometry_ui -->|"uses editors"| node_geometry_helpers
node_physics_ui -->|"builds settings"| node_physics_state
node_simulation_ui -->|"launches"| node_entry
node_simulation_ui -->|"generates spectrum"| node_xray_tool
node_entry -->|"loads JSON"| node_config
node_entry -->|"initializes"| node_messenger
node_entry -->|"registers"| node_construction
node_entry -->|"registers"| node_physics
node_entry -->|"registers"| node_actions
node_entry -->|"starts run"| node_geant4
node_construction -->|"attaches detector"| node_sensitive
node_construction -->|"exports geometry"| node_browser_export
node_actions -->|"configures"| node_tracks_export
node_geant4 -->|"writes results"| node_root_data
node_geant4 -->|"exports geometry"| node_geometry_json
node_geant4 -->|"exports tracks"| node_tracks_json
node_results_ui -->|"runs processing"| node_response
node_response -->|"reads ROOT"| node_root_data
node_response -->|"uses fluence"| node_xray_tool
node_three_viewer -->|"loads geometry"| node_geometry_json
node_three_viewer -->|"loads tracks"| node_tracks_json
node_user -->|"inspects"| node_three_viewer

click node_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/main.py"
click node_geometry_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/geometry.py"
click node_geometry_helpers "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/helper/frontend_helper.py"
click node_tube_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/xray_tube.py"
click node_physics_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/physics_engine.py"
click node_physics_state "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/physics_state.py"
click node_simulation_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/simulation.py"
click node_config "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/include/simulationConfig.hh"
click node_entry "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/sim.cpp"
click node_messenger "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/simulationMessenger.cpp"
click node_construction "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/detectorConstruction.cpp"
click node_source "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/primaryGenerator.cpp"
click node_physics "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/physicsList.cpp"
click node_actions "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/actionInitialization.cpp"
click node_sensitive "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/sensitiveDetector.cpp"
click node_browser_export "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/geometryExporter.cpp"
click node_tracks_export "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/browserTrackExporter.cpp"
click node_response "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/detector_noise/pipeline.py"
click node_results_ui "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/result_and_detector_noise.py"
click node_xray_tool "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/helper/xray_tube.py"
click node_three_viewer "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/main.js"
click node_geometry_json "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/public/xrf_geometry_vis.json"
click node_tracks_json "https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/public/xrf_tracks.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_geometry_ui,node_geometry_helpers,node_tube_ui,node_physics_ui,node_physics_state,node_simulation_ui toneBlue
class node_config,node_entry,node_messenger,node_construction,node_source,node_physics,node_actions,node_sensitive,node_browser_export,node_tracks_export toneAmber
class node_root_data,node_response,node_results_ui,node_xray_tool toneMint
class node_three_viewer,node_geometry_json,node_tracks_json toneRose
class node_user,node_geant4 toneIndigo
```

## Components

### Configuration UI

- [Streamlit Navigation](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/main.py): `python_code/frontend/main.py`
- [Geometry Inputs](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/geometry.py): `python_code/frontend/views/geometry.py`
- [Geometry Editors](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/helper/frontend_helper.py): `python_code/frontend/helper/frontend_helper.py`
- [X-ray Tube Setup](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/xray_tube.py): `python_code/frontend/views/xray_tube.py`
- [Physics Settings](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/physics_engine.py): `python_code/frontend/views/physics_engine.py`
- [Physics Config State](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/physics_state.py): `python_code/frontend/views/physics_state.py`
- [Run Controller](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/simulation.py): `python_code/frontend/views/simulation.py`

### Geant4 Simulation

- [Simulation Config](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/include/simulationConfig.hh): `include/simulationConfig.hh`
- [Geant4 Entry](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/sim.cpp): `sim.cpp`
- [Runtime Commands](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/simulationMessenger.cpp): `src/simulationMessenger.cpp`
- [World & Detector](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/detectorConstruction.cpp): `src/detectorConstruction.cpp`
- [Photon Generator](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/primaryGenerator.cpp): `src/primaryGenerator.cpp`
- [XRF Physics](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/physicsList.cpp): `src/physicsList.cpp`
- [Run Actions](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/actionInitialization.cpp): `src/actionInitialization.cpp`
- [Detector Scoring](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/sensitiveDetector.cpp): `src/sensitiveDetector.cpp`
- [Geometry Export](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/geometryExporter.cpp): `src/geometryExporter.cpp`
- [Track Export](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/src/browserTrackExporter.cpp): `src/browserTrackExporter.cpp`

### Detector Analysis

- **Simulation ROOT Output**
- [Detector Response](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/detector_noise/pipeline.py): `python_code/frontend/detector_noise/pipeline.py`
- [Results & Noise UI](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/views/result_and_detector_noise.py): `python_code/frontend/views/result_and_detector_noise.py`
- [X-ray Spectrum Tool](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/frontend/helper/xray_tube.py): `python_code/frontend/helper/xray_tube.py`

### Browser Debugging

- [Three.js Viewer](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/main.js): `python_code/vis/main.js`
- [Geometry JSON](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/public/xrf_geometry_vis.json): `python_code/vis/public/xrf_geometry_vis.json`
- [Tracks JSON](https://github.com/minmyatngwe/tempo_xrf_repo/blob/main/python_code/vis/public/xrf_tracks.json): `python_code/vis/public/xrf_tracks.json`

### Other components

- **Researcher**
- **Geant4 Runtime**

## Connections

- Researcher → Streamlit Navigation: configures
- Streamlit Navigation → Geometry Inputs: opens
- Streamlit Navigation → X-ray Tube Setup: opens
- Streamlit Navigation → Physics Settings: opens
- Streamlit Navigation → Run Controller: opens
- Streamlit Navigation → Results & Noise UI: opens
- Geometry Inputs → Geometry Editors: uses editors
- Physics Settings → Physics Config State: builds settings
- Run Controller → Geant4 Entry: launches
- Run Controller → X-ray Spectrum Tool: generates spectrum
- Geant4 Entry → Simulation Config: loads JSON
- Geant4 Entry → Runtime Commands: initializes
- Geant4 Entry → World & Detector: registers
- Geant4 Entry → XRF Physics: registers
- Geant4 Entry → Run Actions: registers
- Geant4 Entry → Geant4 Runtime: starts run
- World & Detector → Detector Scoring: attaches detector
- World & Detector → Geometry Export: exports geometry
- Run Actions → Track Export: configures
- Geant4 Runtime → Simulation ROOT Output: writes results
- Geant4 Runtime → Geometry JSON: exports geometry
- Geant4 Runtime → Tracks JSON: exports tracks
- Results & Noise UI → Detector Response: runs processing
- Detector Response → Simulation ROOT Output: reads ROOT
- Detector Response → X-ray Spectrum Tool: uses fluence
- Three.js Viewer → Geometry JSON: loads geometry
- Three.js Viewer → Tracks JSON: loads tracks
- Researcher → Three.js Viewer: inspects
