Summary
Implement MQTT IoT telemetry client — pkg/iot/mqtt_client.go is future-gated and no soil sensor or methane detector data can flow in via MQTT broker.
Social Media Link
Let's collaborate on Discord. And ensure to star our repo.
Problem Statement
Confirmed in project-portal/project-portal-backend/pkg/iot/mqtt_client.go and project-portal/project-portal-backend/internal/monitoring:
-
File is entirely stubbed out: mqtt_client.go contains only //go:build future / // +build future tags, package iot, and // Implementation pending — zero exported types or functions.
-
No MQTT client library dependency: No eclipse/paho.mqtt.golang (or equivalent) import exists in go.mod for this package.
-
No broker connection configuration: No MQTT_BROKER_URL, TLS certificate, or client-ID configuration surfaced in internal/config for connecting to a broker.
-
No topic subscription model: There is no defined topic scheme (e.g. sensors/{project_id}/{sensor_type}) for soil moisture, methane, or biomass sensor payloads.
-
No payload decoding: No struct or JSON schema exists to decode MQTT sensor payloads into monitoring.SystemMetric or a project-specific telemetry record.
-
internal/monitoring/processing/biomass_estimator.go has no ingestion source: The biomass estimator (also future-gated per the backlog) has no upstream sensor feed since MQTT ingestion doesn't exist.
-
No QoS or reconnect handling: Since there is no client, there is naturally no at-least-once QoS handling or automatic reconnect-with-backoff on broker disconnects.
-
No TLS/mutual-auth support: No certificate-based device authentication path exists for IoT devices connecting to the broker.
-
No persistence of raw telemetry: There is no table or repository method for storing raw sensor readings before they are aggregated into monitoring metrics.
-
No backpressure or buffering: A stub means there is also no bounded queue or worker pool to absorb bursts of sensor messages without blocking the broker connection.
-
No health/status reporting: MQTT connection health is not exposed on the /health endpoint or as a Prometheus-style metric.
-
No test coverage: No mqtt_client_test.go exists, and no integration test exercises a local/mock broker.
Required Changes
-
Remove the //go:build future tag and implement a real MQTT client using github.com/eclipse/paho.mqtt.golang.
-
Add MQTT_BROKER_URL, MQTT_CLIENT_ID, and TLS certificate configuration to internal/config.
-
Define topic subscription patterns for soil moisture, methane, and biomass sensor data.
-
Define payload structs and JSON decoding for each supported sensor type.
-
Wire decoded telemetry into the monitoring ingestion pipeline (internal/monitoring/ingestion) so it becomes queryable SystemMetric data.
-
Add automatic reconnect with exponential backoff on broker disconnect.
-
Add TLS mutual-auth support for device certificate-based authentication.
-
Add a bounded in-memory queue (or worker pool) to buffer bursts of incoming sensor messages.
-
Add a repository method to persist raw sensor readings before aggregation.
-
Expose MQTT connection health via the /health endpoint.
-
Add structured logging for connect/disconnect/subscribe events.
-
Add mqtt_client_test.go with unit tests against a mocked or embedded test broker.
Acceptance Criteria
mqtt_client.go compiles in normal (non-future) builds.
- The client connects to a configured MQTT broker and subscribes to defined sensor topics.
- Incoming sensor payloads are decoded and persisted as raw telemetry.
- Decoded telemetry flows into the monitoring ingestion pipeline as queryable metrics.
- The client reconnects automatically with backoff after a broker disconnect.
- TLS mutual-auth is supported for device connections.
- MQTT connection status is visible via the
/health endpoint.
- Message bursts are buffered without blocking the broker connection.
- Unit tests cover connect, subscribe, decode, and reconnect behavior.
- No
//go:build future tag remains on this file.
Directory to Work on:
project-portal/project-portal-backend/
Summary
Implement MQTT IoT telemetry client —
pkg/iot/mqtt_client.gois future-gated and no soil sensor or methane detector data can flow in via MQTT broker.Social Media Link
Let's collaborate on Discord. And ensure to star our repo.
Problem Statement
Confirmed in
project-portal/project-portal-backend/pkg/iot/mqtt_client.goandproject-portal/project-portal-backend/internal/monitoring:File is entirely stubbed out:
mqtt_client.gocontains only//go:build future/// +build futuretags,package iot, and// Implementation pending— zero exported types or functions.No MQTT client library dependency: No
eclipse/paho.mqtt.golang(or equivalent) import exists ingo.modfor this package.No broker connection configuration: No
MQTT_BROKER_URL, TLS certificate, or client-ID configuration surfaced ininternal/configfor connecting to a broker.No topic subscription model: There is no defined topic scheme (e.g.
sensors/{project_id}/{sensor_type}) for soil moisture, methane, or biomass sensor payloads.No payload decoding: No struct or JSON schema exists to decode MQTT sensor payloads into
monitoring.SystemMetricor a project-specific telemetry record.internal/monitoring/processing/biomass_estimator.gohas no ingestion source: The biomass estimator (also future-gated per the backlog) has no upstream sensor feed since MQTT ingestion doesn't exist.No QoS or reconnect handling: Since there is no client, there is naturally no at-least-once QoS handling or automatic reconnect-with-backoff on broker disconnects.
No TLS/mutual-auth support: No certificate-based device authentication path exists for IoT devices connecting to the broker.
No persistence of raw telemetry: There is no table or repository method for storing raw sensor readings before they are aggregated into monitoring metrics.
No backpressure or buffering: A stub means there is also no bounded queue or worker pool to absorb bursts of sensor messages without blocking the broker connection.
No health/status reporting: MQTT connection health is not exposed on the
/healthendpoint or as a Prometheus-style metric.No test coverage: No
mqtt_client_test.goexists, and no integration test exercises a local/mock broker.Required Changes
Remove the
//go:build futuretag and implement a real MQTT client usinggithub.com/eclipse/paho.mqtt.golang.Add
MQTT_BROKER_URL,MQTT_CLIENT_ID, and TLS certificate configuration tointernal/config.Define topic subscription patterns for soil moisture, methane, and biomass sensor data.
Define payload structs and JSON decoding for each supported sensor type.
Wire decoded telemetry into the monitoring ingestion pipeline (
internal/monitoring/ingestion) so it becomes queryableSystemMetricdata.Add automatic reconnect with exponential backoff on broker disconnect.
Add TLS mutual-auth support for device certificate-based authentication.
Add a bounded in-memory queue (or worker pool) to buffer bursts of incoming sensor messages.
Add a repository method to persist raw sensor readings before aggregation.
Expose MQTT connection health via the
/healthendpoint.Add structured logging for connect/disconnect/subscribe events.
Add
mqtt_client_test.gowith unit tests against a mocked or embedded test broker.Acceptance Criteria
mqtt_client.gocompiles in normal (non-future) builds./healthendpoint.//go:build futuretag remains on this file.Directory to Work on:
project-portal/project-portal-backend/