# nitrosaccharose/qt-unity-socket architecture

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

- Interactive diagram: https://gitdiagram.com/nitrosaccharose/qt-unity-socket
- Repository: https://github.com/nitrosaccharose/qt-unity-socket

## Overview

This repository demonstrates a Qt desktop client communicating over a socket with a Unity object simulator. The main workflow is: an operator connects and sends movement keys from Qt; Unity simulates the object and returns its state for display in Qt. The README documents both directions, while the supplied Qt source confirms connection, key sending, and message display. Unity source was not sampled, so internal Unity dispatch and simulation links are omitted. A separate Qt widget implements timer-driven charts.

Main entry points: [`qt-project/mainwindow.cpp`](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/mainwindow.cpp) (Main window), [`unity-project/Assets/SocketClient.cs`](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/SocketClient.cs) (Socket client), [`qt-project/main.cpp`](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/main.cpp) (Qt entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_qt["Qt client"]
  node_qt_entry["Qt entry<br/>[main.cpp]"]
  node_qt_window["Main window<br/>[mainwindow.cpp]"]
  node_qt_charts["Timer charts<br/>[widget.cpp]"]
end

subgraph group_unity["Unity simulator"]
  node_unity_socket["Socket client<br/>[SocketClient.cs]"]
  node_unity_camera["Camera controller"]
  node_unity_scene["Simulator scene<br/>[SampleScene.unity]"]
end

node_operator(("Operator"))

node_qt_entry -->|"creates window"| node_qt_window
node_operator -->|"connects, presses keys"| node_qt_window
node_qt_window -->|"sends key data"| node_unity_socket
node_unity_socket -->|"returns state"| node_qt_window
node_qt_window -->|"displays messages"| node_operator

click node_qt_entry "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/main.cpp"
click node_qt_window "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/mainwindow.cpp"
click node_unity_socket "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/SocketClient.cs"
click node_unity_camera "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/CameraController.cs"
click node_unity_scene "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/Scenes/SampleScene.unity"
click node_qt_charts "https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/widget.cpp"

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_qt_entry,node_qt_window,node_qt_charts toneBlue
class node_unity_socket,node_unity_camera,node_unity_scene toneAmber
class node_operator toneIndigo
```

## Components

### Qt client

- [Qt entry](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/main.cpp): `qt-project/main.cpp`
- [Main window](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/mainwindow.cpp): `qt-project/mainwindow.cpp`
- [Timer charts](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/qt-project/widget.cpp): `qt-project/widget.cpp`

### Unity simulator

- [Socket client](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/SocketClient.cs): `unity-project/Assets/SocketClient.cs`
- [Camera controller](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/CameraController.cs): `unity-project/Assets/CameraController.cs`
- [Simulator scene](https://github.com/nitrosaccharose/qt-unity-socket/blob/main/unity-project/Assets/Scenes/SampleScene.unity): `unity-project/Assets/Scenes/SampleScene.unity`

### Other components

- **Operator**

## Connections

- Qt entry → Main window: creates window
- Operator → Main window: connects, presses keys
- Main window → Socket client: sends key data
- Socket client → Main window: returns state
- Main window → Operator: displays messages
