# dugati201-glitch/digital_twin architecture

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

- Interactive diagram: https://gitdiagram.com/dugati201-glitch/digital_twin
- Repository: https://github.com/dugati201-glitch/digital_twin

## Overview

This repository is an early Digital Twin edge gateway: its camera service is implemented, while gateway code is explicitly not yet implemented. The camera workflow loads and validates configuration, captures and encodes frames, then serves an MJPEG stream and health endpoint. Shared utilities provide YAML loading and logging configuration. The README documents the intended UART/MQTT gateway connections; those links describe planned responsibilities, not verified runtime calls.

Main entry points: [`services/camera/src/camera_service/app.py`](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/app.py) (HTTP service), [`services/gateway`](https://github.com/dugati201-glitch/digital_twin/tree/main/services/gateway) (Gateway service (planned)), [`services/camera/src/camera_service/config.py`](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/config.py) (Camera configuration), [`services/camera/src/camera_service/capture.py`](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/capture.py) (Frame capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_camera["Camera service"]
  node_camera_app["HTTP service<br/>[app.py]"]
  node_camera_config["Camera configuration<br/>[config.py]"]
  node_capture["Frame capture<br/>[capture.py]"]
end

subgraph group_common["Shared utilities"]
  node_yaml_loader["YAML loader<br/>[config.py]"]
  node_logging["Logging setup<br/>[logging.py]"]
end

subgraph group_interfaces["Twin interfaces"]
  node_camera_device["Camera hardware"]
  node_web_twin(("Web interface"))
  node_gateway["Gateway service &#40;planned&#41;"]
  node_experiment_equipment["Experiment equipment"]
  node_mqtt{{"External MQTT broker"}}
end

node_operator(("Service operator"))

node_operator -->|"starts"| node_camera_app
node_camera_app -->|"loads"| node_camera_config
node_camera_config -->|"loads YAML"| node_yaml_loader
node_camera_app -->|"configures"| node_logging
node_logging -->|"loads YAML"| node_yaml_loader
node_camera_app -->|"starts and streams"| node_capture
node_capture -.->|"captures frames"| node_camera_device
node_web_twin -->|"requests video"| node_camera_app
node_gateway -.->|"communicates via UART"| node_experiment_equipment
node_gateway -.->|"bridges messages"| node_mqtt
node_web_twin -.->|"exchanges messages"| node_mqtt

click node_camera_app "https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/app.py"
click node_camera_config "https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/config.py"
click node_capture "https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/capture.py"
click node_yaml_loader "https://github.com/dugati201-glitch/digital_twin/blob/main/shared/src/digital_twin_common/config.py"
click node_logging "https://github.com/dugati201-glitch/digital_twin/blob/main/shared/src/digital_twin_common/logging.py"
click node_gateway "https://github.com/dugati201-glitch/digital_twin/tree/main/services/gateway"

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_camera_app,node_camera_config,node_capture toneBlue
class node_yaml_loader,node_logging toneAmber
class node_camera_device,node_web_twin,node_gateway,node_experiment_equipment,node_mqtt toneMint
class node_operator toneIndigo
```

## Components

### Camera service

- [HTTP service](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/app.py): `services/camera/src/camera_service/app.py`
- [Camera configuration](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/config.py): `services/camera/src/camera_service/config.py`
- [Frame capture](https://github.com/dugati201-glitch/digital_twin/blob/main/services/camera/src/camera_service/capture.py): `services/camera/src/camera_service/capture.py`

### Shared utilities

- [YAML loader](https://github.com/dugati201-glitch/digital_twin/blob/main/shared/src/digital_twin_common/config.py): `shared/src/digital_twin_common/config.py`
- [Logging setup](https://github.com/dugati201-glitch/digital_twin/blob/main/shared/src/digital_twin_common/logging.py): `shared/src/digital_twin_common/logging.py`

### Twin interfaces

- **Camera hardware**
- **Web interface**
- [Gateway service (planned)](https://github.com/dugati201-glitch/digital_twin/tree/main/services/gateway): `services/gateway`
- **Experiment equipment**
- **External MQTT broker**

### Other components

- **Service operator**

## Connections

- Service operator → HTTP service: starts (evidence: `services/camera/src/camera_service/app.py`)
- HTTP service → Camera configuration: loads (evidence: `services/camera/src/camera_service/app.py`)
- Camera configuration → YAML loader: loads YAML (evidence: `services/camera/src/camera_service/config.py`)
- HTTP service → Logging setup: configures (evidence: `services/camera/src/camera_service/app.py`)
- Logging setup → YAML loader: loads YAML (evidence: `shared/src/digital_twin_common/logging.py`)
- HTTP service → Frame capture: starts and streams (evidence: `services/camera/src/camera_service/app.py`)
- Frame capture → Camera hardware: captures frames
- Web interface → HTTP service: requests video (evidence: `README.md`)
- Gateway service (planned) → Experiment equipment: communicates via UART (evidence: `README.md`)
- Gateway service (planned) → External MQTT broker: bridges messages (evidence: `README.md`)
- Web interface → External MQTT broker: exchanges messages (evidence: `README.md`)
