# meta-quest/meta-openxr-sdk architecture

> Architecture diagram of the GitHub repository meta-quest/meta-openxr-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meta-quest/meta-openxr-sdk
- Repository: https://github.com/meta-quest/meta-openxr-sdk

## Overview

##### Project Type and Purpose
- This project is a native OpenXR SDK with a suite of sample applications that demonstrate experimental and pre-release OpenXR APIs specifically for Meta Quest devices (e.g., Meta Quest 2, Quest 3, Quest Pro).
- The SDK provides header files and API definitions (found in the “OpenXR” directory) alongside multiple sample projects (located under “Samples”) that integrate diverse OpenXR extensions and features.
- The README further outlines the variety of samples and their target devices, emphasizing several experimental extensions (e.g., body tracking, hand tracking, scene capture).

##### File Structure: Key Observations
- Top-Level Directories:
- .github: Contains CI/CD workflows, which implies integration with automated build or release processes.
- OpenXR: Contains header files and API definitions for “meta openxr preview” including various extension headers (e.g., meta_body_tracking_*, meta_hand_tracking_microgestures, etc.).
- Samples: Consists of a large number of sample projects grouped by functionality (e.g., XrHandsFB, XrPassthrough, XrControllers, etc.) with each sample typically having subdirectories for source code (C/C++ files, Java files for Android), build scripts (CMakeLists.txt, build.gradle, etc.), assets, and resources.
- The Samples directory is further subdivided into first-party, third-party components, and sample frameworks. This separation highlights that the project supports both core SDK functionality and practical demonstration apps.
- Build and configuration files (like build.gradle, gradle.properties, CMakeLists.txt) underline that the project is built using multiple toolchains (Android Studio with Gradle, CMake for Windows/Quest Link).

a. OpenXR SDK Core & API Definitions:
- “OpenXR” directory as the core API layer. This component encapsulates the header files, experimental extension definitions, and any helper functions.
- That these definitions are intended to be integrated into the final Khronos OpenXR SDK.

b. Sample Applications:
- Native C/C++ components (for cross-platform, Quest Link support via CMake).
- Android-specific layers (Java activities, Gradle projects).
- Resource management (assets, scripts, shaders).
- How these sample applications depend on and interact with the OpenXR core API.

c. Build & CI/CD Infrastructure:
- CI pipelines from the “.github/workflows” directory that manage tasks like packaging releases.
- Build systems (Gradle for Android, CMake for cross-platform builds) and any external dependency management components.

d. External Dependencies & Device Interactions:
- External tools such as Android Studio, NDK, CMake, as well as the integration with the Meta Quest Link when running samples on Windows.
- Flow from the sample apps to the target hardware (Meta Quest devices) via the OpenXR APIs.

##### Architectural Patterns and Relationships
- The design follows a modular architecture with a clear separation between the API definition (OpenXR core) and the consumer applications (Samples). This supports easy extensibility and demonstration of various features.
- How build scripts and CI pipelines (build automation) are responsible for compiling and packaging the projects.
- Mention any patterns that stand out, such as the separation of platform-specific code (Android native projects vs. Windows builds) using different build configurations (Gradle, CMake).

##### Essential Elements
- OpenXR Core Component (header/API definitions)
- Sample Applications (grouped by purpose, e.g., XrHandsFB, XrPassthrough, etc.)
- Build Tools & Scripts (Gradle, CMake, CI workflows)
- External Dependencies and Tools (Android Studio, NDK, CMake and Meta Quest Link)
- Device/Runtime Environment (Meta Quest devices and Headset operations)
- Dependency from Samples to OpenXR Core.
- Data/control flows from Sample Applications to hardware via the API.
- Build flows from source code through CI/CD pipelines.
- Annotations that capture:
- Key architectural patterns (modularity and separation of concerns)
- Versioning and experimental nature of some extensions as highlighted in the README.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core API Definition
    CoreAPI["OpenXR SDK Core & API Definitions"]:::core

    %% Sample Applications Subgraph
    subgraph "Sample Applications"
        direction TB
        FP["First Party Samples"]:::sample
        ES["Extended Sample Applications"]:::sample
    end

    %% Build & CI/CD Infrastructure
    BuildInfra["CI/CD & Build Tools"]:::build

    %% External Dependencies & Third-Party Libraries
    ThirdParty["Third-Party Dependencies & Libraries"]:::external

    %% Target Device / Runtime Environment
    MetaQuest["Meta Quest Hardware"]:::device

    %% Relationships
    FP -->|"uses_API"| CoreAPI
    ES -->|"uses_API"| CoreAPI
    BuildInfra -->|"builds"| FP
    BuildInfra -->|"builds"| ES
    BuildInfra -->|"builds"| CoreAPI
    ThirdParty -->|"supplies"| FP
    ThirdParty -->|"supplies"| ES
    FP -->|"deploys_to"| MetaQuest
    ES -->|"deploys_to"| MetaQuest

    %% Click Events
    click CoreAPI "https://github.com/meta-quest/meta-openxr-sdk/tree/main/OpenXR/meta_openxr_preview"
    click FP "https://github.com/meta-quest/meta-openxr-sdk/tree/main/Samples/1stParty"
    click ES "https://github.com/meta-quest/meta-openxr-sdk/tree/main/Samples/XrSamples"
    click BuildInfra "https://github.com/meta-quest/meta-openxr-sdk/tree/main/.github/workflows"
    click ThirdParty "https://github.com/meta-quest/meta-openxr-sdk/tree/main/Samples/3rdParty"

    %% Styles
    classDef core fill:#fce5cd,stroke:#d9ab6a,stroke-width:2px;
    classDef sample fill:#d9ead3,stroke:#6aa84f,stroke-width:2px;
    classDef build fill:#cfe2f3,stroke:#6fa8dc,stroke-width:2px;
    classDef external fill:#ead1dc,stroke:#b85c8f,stroke-width:2px;
    classDef device fill:#fff2cc,stroke:#f1c232,stroke-width:2px;
```
