# ernesto905/unity-vr-bloch-sphere architecture

> Architecture diagram of the GitHub repository ernesto905/unity-vr-bloch-sphere, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ernesto905/unity-vr-bloch-sphere
- Repository: https://github.com/ernesto905/unity-vr-bloch-sphere

## Overview

##### Component Relationships

a. Data flow between Unity and Python:
- Unity VR Environment <---> Socket Communication <---> Python/Qiskit Backend

##### Detailed Subcomponents

Unity Side (Show as nested components):
- XR Interaction System
- Hand Controllers (HandController.cs)
- Button Interactions (H_Button.cs, M_Button.cs, etc.)
- Visualization System
- Bloch Sphere Renderer (MyBloch.cs)
- Animation System
- Input Processing
- OpenXR Integration
- Controller Mapping

Python Side:
- Qiskit Framework
- Quantum Circuit Handler
- State Vector Calculator
- Socket Server
- Data Serialization
- Command Processing

**[VR Interface Layer]**
- ↕
**[Unity Core Layer]**
- ↕
**[Communication Layer]**
- ↕
**[Python/Qiskit Layer]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph VR_Interface
        XRRig["XR Rig"]
        HandTracking["Hand Tracking System"]
        InputSystem["VR Input System"]
        PlayerSetup["VR Player Setup"]
    end

    subgraph Unity_Core
        BlochVis["Bloch Sphere Visualization"]
        GateInterface["Quantum Gate Interface"]
        XRCore["VR Core Setup"]
        
        subgraph Gate_Buttons
            HButton["H Gate Button"]
            XButton["X Gate Button"]
            YButton["Y Gate Button"]
            ZButton["Z Gate Button"]
            MButton["M Gate Button"]
        end
    end

    subgraph Communication
        Socket["Socket Communication"]
    end

    subgraph Backend
        QiskitCore["Qiskit Framework"]
        StateCalc["State Vector Calculator"]
        CircuitHandler["Quantum Circuit Handler"]
    end

    %% Relationships
    XRRig --> HandTracking
    HandTracking --> InputSystem
    InputSystem --> GateInterface
    GateInterface --> Socket
    Socket --> QiskitCore
    QiskitCore --> StateCalc
    StateCalc --> CircuitHandler
    CircuitHandler --> Socket
    Socket --> BlochVis
    
    Gate_Buttons --> GateInterface

    %% Click Events
    click HandTracking "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/HandController.cs"
    click BlochVis "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/MyBloch.cs"
    click XRCore "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/XR/Settings/Open XR Package Settings.asset"
    click InputSystem "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Samples/XR Interaction Toolkit/1.0.0-pre.5/Default Input Actions/XRI Default Input Actions.inputactions"
    click PlayerSetup "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Prefab/Player.prefab"
    click XRRig "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Prefab/XR Rig.prefab"
    click HButton "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/H_Button.cs"
    click XButton "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/X_Button.cs"
    click YButton "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/Y_Button.cs"
    click ZButton "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/Z_Button.cs"
    click MButton "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/Assets/Scripts/M_Button.cs"
    click QiskitCore "https://github.com/Ernesto905/Unity-VR-Bloch-Sphere/blob/main/python/qiskitConnection.py"

    %% Styling
    classDef vr fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef unity fill:#66b3ff,stroke:#333,stroke-width:2px
    classDef comm fill:#ffeb99,stroke:#333,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef button fill:#b3d9ff,stroke:#333,stroke-width:2px

    class XRRig,HandTracking,InputSystem,PlayerSetup vr
    class BlochVis,GateInterface,XRCore unity
    class Socket comm
    class QiskitCore,StateCalc,CircuitHandler backend
    class HButton,XButton,YButton,ZButton,MButton button
```
