# fred-sheppard/detray architecture

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

- Interactive diagram: https://gitdiagram.com/fred-sheppard/detray
- Repository: https://github.com/fred-sheppard/detray

## Overview

Detray is a header-only, GPU-friendly detector-description and track-propagation library. A client builds or loads a flat detector model, supplies track parameters, and invokes propagation. Navigation queries detector volumes and acceleration structures; a stepper advances the track through magnetic field and material, while actors update parameters, covariance, and trajectories. Separate capabilities provide JSON I/O, detector validation, SVG visualization, configurable algebra backends, and generated Jacobian code. Several implementation relationships are inferred from documented responsibilities because only selected source excerpts were sampled.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_construction["Detector Construction"]
  node_detector_builder["Detector Builders"]
  node_detector_model["Flat Detector Model<br/>[detector.hpp]"]
  node_tracking_volume["Tracking Volumes"]
  node_material_model["Material Model<br/>[material_map.hpp]"]
end

subgraph group_navigation["Geometry Navigation"]
  node_navigator["Navigator<br/>[navigator.hpp]"]
  node_navigation_state["Navigation State"]
  node_accelerators["Search Accelerators<br/>[spatial_grid.hpp]"]
end

subgraph group_propagation["Track Propagation"]
  node_track_parameters["Track Parameters<br/>[tracks.hpp]"]
  node_propagator["Propagator<br/>[propagator.hpp]"]
  node_rk_stepper["Runge Kutta Stepper<br/>[rk_stepper.hpp]"]
  node_actor_chain["Propagation Actors<br/>[actor_chain.hpp]"]
  node_covariance_actor["Covariance Transport"]
  node_jacobian_engine["Jacobian Engine"]
  node_trajectory_result["Trajectory Results<br/>[trajectories.hpp]"]
end

subgraph group_io_tools["I/O and Tools"]
  node_detector_reader["Detector Reader"]
  node_detector_writer["Detector Writer"]
  node_consistency_checker["Consistency Checker"]
  node_svg_illustrator["SVG Illustrator<br/>[illustrator.hpp]"]
end

subgraph group_backends["Backends and Generation"]
  node_algebra_backend["Algebra Backends<br/>[algebra.hpp]"]
  node_metadata_generator["Metadata Generator"]
  node_symbolic_codegen["Symbolic Code Generation<br/>[codegen.py]"]
end

node_client(("Client Application"))
node_magnetic_field["Magnetic Field"]

node_client -->|"builds"| node_detector_builder
node_detector_builder -->|"creates"| node_detector_model
node_detector_model -->|"exposes"| node_tracking_volume
node_client -->|"loads"| node_detector_reader
node_detector_reader -->|"populates"| node_detector_model
node_client -->|"supplies"| node_track_parameters
node_client -->|"runs"| node_propagator
node_propagator -->|"navigates"| node_navigator
node_navigator -->|"reads geometry"| node_detector_model
node_navigator -->|"updates"| node_navigation_state
node_navigator -->|"queries"| node_accelerators
node_propagator -->|"advances"| node_rk_stepper
node_rk_stepper -.->|"samples"| node_magnetic_field
node_rk_stepper -->|"reads material"| node_material_model
node_propagator -->|"dispatches"| node_actor_chain
node_actor_chain -->|"runs"| node_covariance_actor
node_covariance_actor -->|"uses"| node_jacobian_engine
node_actor_chain -->|"records"| node_trajectory_result
node_propagator -->|"returns"| node_trajectory_result
node_client -->|"saves"| node_detector_writer
node_detector_writer -->|"reads"| node_detector_model
node_client -->|"validates"| node_consistency_checker
node_consistency_checker -->|"checks"| node_detector_model
node_client -.->|"renders"| node_svg_illustrator
node_svg_illustrator -.->|"reads"| node_detector_model
node_client -.->|"selects"| node_algebra_backend
node_client -.->|"configures"| node_metadata_generator
node_metadata_generator -.->|"generates types"| node_detector_model
node_client -.->|"generates"| node_symbolic_codegen
node_symbolic_codegen -.->|"emits code"| node_jacobian_engine

click node_detector_builder "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/builders/detector_builder.hpp"
click node_detector_model "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/core/detector.hpp"
click node_tracking_volume "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/geometry/tracking_volume.hpp"
click node_material_model "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/material/material_map.hpp"
click node_navigator "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/navigator.hpp"
click node_navigation_state "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/navigation_state.hpp"
click node_accelerators "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/accelerators/spatial_grid.hpp"
click node_track_parameters "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/tracks/tracks.hpp"
click node_propagator "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/propagator.hpp"
click node_rk_stepper "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/rk_stepper.hpp"
click node_actor_chain "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/actor_chain.hpp"
click node_covariance_actor "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/actors/codegen/covariance_transport.hpp"
click node_jacobian_engine "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/detail/jacobian_engine.hpp"
click node_trajectory_result "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/tracks/trajectories.hpp"
click node_detector_reader "https://github.com/fred-sheppard/detray/blob/main/io/include/detray/io/frontend/detector_reader.hpp"
click node_detector_writer "https://github.com/fred-sheppard/detray/blob/main/io/include/detray/io/frontend/detector_writer.hpp"
click node_consistency_checker "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/utils/consistency_checker.hpp"
click node_svg_illustrator "https://github.com/fred-sheppard/detray/blob/main/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp"
click node_algebra_backend "https://github.com/fred-sheppard/detray/blob/main/core/include/detray/definitions/algebra.hpp"
click node_metadata_generator "https://github.com/fred-sheppard/detray/blob/main/python/detray/detectors/impl/metadata_generator.py"
click node_symbolic_codegen "https://github.com/fred-sheppard/detray/blob/main/codegen/detray-sympy/detray_sympy/codegen.py"

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_detector_builder,node_detector_model,node_tracking_volume,node_material_model,node_client toneBlue
class node_navigator,node_navigation_state,node_accelerators toneAmber
class node_track_parameters,node_propagator,node_rk_stepper,node_actor_chain,node_covariance_actor,node_jacobian_engine,node_trajectory_result toneMint
class node_detector_reader,node_detector_writer,node_consistency_checker,node_svg_illustrator toneRose
class node_algebra_backend,node_metadata_generator,node_symbolic_codegen,node_magnetic_field toneIndigo
```

## Components

### Detector Construction

- [Detector Builders](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/builders/detector_builder.hpp): `core/include/detray/builders/detector_builder.hpp`
- [Flat Detector Model](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/core/detector.hpp): `core/include/detray/core/detector.hpp`
- [Tracking Volumes](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/geometry/tracking_volume.hpp): `core/include/detray/geometry/tracking_volume.hpp`
- [Material Model](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/material/material_map.hpp): `core/include/detray/material/material_map.hpp`

### Geometry Navigation

- [Navigator](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/navigator.hpp): `core/include/detray/navigation/navigator.hpp`
- [Navigation State](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/navigation_state.hpp): `core/include/detray/navigation/navigation_state.hpp`
- [Search Accelerators](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/navigation/accelerators/spatial_grid.hpp): `core/include/detray/navigation/accelerators/spatial_grid.hpp`

### Track Propagation

- [Track Parameters](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/tracks/tracks.hpp): `core/include/detray/tracks/tracks.hpp`
- [Propagator](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/propagator.hpp): `core/include/detray/propagator/propagator.hpp`
- [Runge Kutta Stepper](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/rk_stepper.hpp): `core/include/detray/propagator/rk_stepper.hpp`
- [Propagation Actors](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/actor_chain.hpp): `core/include/detray/propagator/actor_chain.hpp`
- [Covariance Transport](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/actors/codegen/covariance_transport.hpp): `core/include/detray/propagator/actors/codegen/covariance_transport.hpp`
- [Jacobian Engine](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/propagator/detail/jacobian_engine.hpp): `core/include/detray/propagator/detail/jacobian_engine.hpp`
- [Trajectory Results](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/tracks/trajectories.hpp): `core/include/detray/tracks/trajectories.hpp`

### I/O and Tools

- [Detector Reader](https://github.com/fred-sheppard/detray/blob/main/io/include/detray/io/frontend/detector_reader.hpp): `io/include/detray/io/frontend/detector_reader.hpp`
- [Detector Writer](https://github.com/fred-sheppard/detray/blob/main/io/include/detray/io/frontend/detector_writer.hpp): `io/include/detray/io/frontend/detector_writer.hpp`
- [Consistency Checker](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/utils/consistency_checker.hpp): `core/include/detray/utils/consistency_checker.hpp`
- [SVG Illustrator](https://github.com/fred-sheppard/detray/blob/main/plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp): `plugins/svgtools/include/detray/plugins/svgtools/illustrator.hpp`

### Backends and Generation

- [Algebra Backends](https://github.com/fred-sheppard/detray/blob/main/core/include/detray/definitions/algebra.hpp): `core/include/detray/definitions/algebra.hpp`
- [Metadata Generator](https://github.com/fred-sheppard/detray/blob/main/python/detray/detectors/impl/metadata_generator.py): `python/detray/detectors/impl/metadata_generator.py`
- [Symbolic Code Generation](https://github.com/fred-sheppard/detray/blob/main/codegen/detray-sympy/detray_sympy/codegen.py): `codegen/detray-sympy/detray_sympy/codegen.py`

### Other components

- **Client Application**
- **Magnetic Field**

## Connections

- Client Application → Detector Builders: builds
- Detector Builders → Flat Detector Model: creates
- Flat Detector Model → Tracking Volumes: exposes
- Client Application → Detector Reader: loads
- Detector Reader → Flat Detector Model: populates
- Client Application → Track Parameters: supplies
- Client Application → Propagator: runs
- Propagator → Navigator: navigates
- Navigator → Flat Detector Model: reads geometry
- Navigator → Navigation State: updates
- Navigator → Search Accelerators: queries
- Propagator → Runge Kutta Stepper: advances
- Runge Kutta Stepper → Magnetic Field: samples
- Runge Kutta Stepper → Material Model: reads material
- Propagator → Propagation Actors: dispatches
- Propagation Actors → Covariance Transport: runs
- Covariance Transport → Jacobian Engine: uses
- Propagation Actors → Trajectory Results: records
- Propagator → Trajectory Results: returns
- Client Application → Detector Writer: saves
- Detector Writer → Flat Detector Model: reads
- Client Application → Consistency Checker: validates
- Consistency Checker → Flat Detector Model: checks
- Client Application → SVG Illustrator: renders
- SVG Illustrator → Flat Detector Model: reads
- Client Application → Algebra Backends: selects
- Client Application → Metadata Generator: configures
- Metadata Generator → Flat Detector Model: generates types
- Client Application → Symbolic Code Generation: generates
- Symbolic Code Generation → Jacobian Engine: emits code
