# digitalshoestringsolutions/sm_sensingdc architecture

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

- Interactive diagram: https://gitdiagram.com/digitalshoestringsolutions/sm_sensingdc
- Repository: https://github.com/digitalshoestringsolutions/sm_sensingdc

## Overview

Shoestring Sensing Service runs on a Raspberry Pi, reading locally attached sensors and publishing measurements over MQTT. TOML configuration selects interfaces, devices, calculations, pipelines, sampling strategies, and output mappings. The principal flow is configuration → measurement process → sampling strategy and sensing stacks → formatted messages → MQTT wrapper → broker. The graph includes the documented sensor, interface, calculation, and sampling subsystems; several implementation links are omitted because their wiring lies in unsampled source.

Main entry points: [`code/measure.py`](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/measure.py) (Measurement process), [`code/core/sensing_stack.py`](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/sensing_stack.py) (Sensing stack), [`code/main.py`](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/main.py) (Process supervisor), [`code/mqtt_out.py`](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/mqtt_out.py) (MQTT wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Service orchestration"]
  node_config["Config loader<br/>[config_manager.py]"]
  node_main["Process supervisor<br/>[main.py]"]
  node_measure["Measurement process<br/>[measure.py]"]
end

subgraph group_sensing["Sensor acquisition"]
  node_stack["Sensing stack<br/>[sensing_stack.py]"]
  node_devices["Sensor drivers"]
  node_interfaces["Hardware interfaces"]
end

subgraph group_processing["Measurement processing"]
  node_measurement["Sampling strategies<br/>[gen_sample.py]"]
  node_pipeline["Calculation pipeline<br/>[pipeline.py]"]
  node_calculations["Calculations"]
  node_errors["Sampling errors<br/>[exceptions.py]"]
end

subgraph group_delivery["Output delivery"]
  node_output["Message formatting<br/>[output.py]"]
  node_transport["ZMQ transport"]
  node_wrapper["MQTT wrapper<br/>[mqtt_out.py]"]
end

node_operator["Solution config"]
node_hardware{{"Attached sensors"}}
node_broker(("MQTT broker"))

node_operator -->|"provides TOML"| node_config
node_config -->|"returns config"| node_main
node_main -->|"starts process"| node_measure
node_main -->|"starts process"| node_wrapper
node_measure -->|"runs loop"| node_measurement
node_measurement -->|"executes stacks"| node_stack
node_stack -.->|"samples device"| node_devices
node_devices -.->|"uses interface"| node_interfaces
node_interfaces -.->|"communicates with"| node_hardware
node_stack -->|"executes pipeline"| node_pipeline
node_pipeline -->|"runs calculations"| node_calculations
node_stack -->|"raises sampling errors"| node_errors
node_measure -->|"formats results"| node_output
node_measure -->|"sends messages"| node_transport
node_transport -->|"forwards messages"| node_wrapper
node_wrapper -->|"publishes MQTT"| node_broker

click node_config "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/utilities/config_manager.py"
click node_main "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/main.py"
click node_measure "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/measure.py"
click node_measurement "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/measurement_modules/gen_sample.py"
click node_stack "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/sensing_stack.py"
click node_devices "https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/device_modules"
click node_interfaces "https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/interface_modules"
click node_pipeline "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/pipeline.py"
click node_calculations "https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/calculation_modules"
click node_errors "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/exceptions.py"
click node_output "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/output.py"
click node_wrapper "https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/mqtt_out.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_config,node_main,node_measure toneBlue
class node_stack,node_devices,node_interfaces toneAmber
class node_measurement,node_pipeline,node_calculations,node_errors toneMint
class node_output,node_transport,node_wrapper toneRose
class node_operator,node_hardware,node_broker toneIndigo
```

## Components

### Service orchestration

- [Config loader](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/utilities/config_manager.py): `code/utilities/config_manager.py`
- [Process supervisor](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/main.py): `code/main.py`
- [Measurement process](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/measure.py): `code/measure.py`

### Sensor acquisition

- [Sensing stack](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/sensing_stack.py): `code/core/sensing_stack.py`
- [Sensor drivers](https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/device_modules): `code/core/device_modules`
- [Hardware interfaces](https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/interface_modules): `code/core/interface_modules`

### Measurement processing

- [Sampling strategies](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/measurement_modules/gen_sample.py): `code/core/measurement_modules/gen_sample.py`
- [Calculation pipeline](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/pipeline.py): `code/core/pipeline.py`
- [Calculations](https://github.com/digitalshoestringsolutions/sm_sensingdc/tree/main/code/core/calculation_modules): `code/core/calculation_modules`
- [Sampling errors](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/exceptions.py): `code/core/exceptions.py`

### Output delivery

- [Message formatting](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/core/output.py): `code/core/output.py`
- **ZMQ transport**
- [MQTT wrapper](https://github.com/digitalshoestringsolutions/sm_sensingdc/blob/main/code/mqtt_out.py): `code/mqtt_out.py`

### Other components

- **Solution config**
- **Attached sensors**
- **MQTT broker**

## Connections

- Solution config → Config loader: provides TOML
- Config loader → Process supervisor: returns config (evidence: `code/main.py`)
- Process supervisor → Measurement process: starts process (evidence: `code/main.py`)
- Process supervisor → MQTT wrapper: starts process (evidence: `code/main.py`)
- Measurement process → Sampling strategies: runs loop (evidence: `code/measure.py`)
- Sampling strategies → Sensing stack: executes stacks (evidence: `code/core/measurement_modules/gen_sample.py`)
- Sensing stack → Sensor drivers: samples device
- Sensor drivers → Hardware interfaces: uses interface
- Hardware interfaces → Attached sensors: communicates with
- Sensing stack → Calculation pipeline: executes pipeline (evidence: `code/core/sensing_stack.py`)
- Calculation pipeline → Calculations: runs calculations (evidence: `code/core/pipeline.py`)
- Sensing stack → Sampling errors: raises sampling errors (evidence: `code/core/sensing_stack.py`)
- Measurement process → Message formatting: formats results (evidence: `code/measure.py`)
- Measurement process → ZMQ transport: sends messages (evidence: `code/measure.py`)
- ZMQ transport → MQTT wrapper: forwards messages
- MQTT wrapper → MQTT broker: publishes MQTT (evidence: `code/mqtt_out.py`)
