# anur01/softwaredevproject_ml-kem architecture

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

- Interactive diagram: https://gitdiagram.com/anur01/softwaredevproject_ml-kem
- Repository: https://github.com/anur01/softwaredevproject_ml-kem

## Overview

This repository is a simulated legacy sensor-to-cloud telemetry system modernized with ML-KEM on the gateway–cloud hop. Its main workflow is sensor readings framed and encrypted by a constrained device, validated and forwarded by the gateway, then ingested and exposed by the cloud. The graph also preserves the documented legacy rollback path, cloud dashboard and APIs, operator health/metrics, shared logging, and baseline measurement capability. Some endpoint and forwarding details are unsampled; those relationships are included only where the README or source index supports them.

Main entry points: [`cloud_service/app.py`](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/app.py) (Telemetry API), [`edge_gateway/gateway.py`](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py) (Cloud forwarding), [`legacy_device/protocol.py`](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/legacy_device/protocol.py) (Legacy framing), [`edge_gateway/admin.py`](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/admin.py) (Gateway admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Legacy device"]
  node_sensor["Sensor simulator<br/>[device.py]"]
  node_legacy_protocol["Legacy framing<br/>[protocol.py]"]
end

subgraph group_gateway["Edge gateway"]
  node_gateway_ingest["Frame ingest<br/>[gateway.py]"]
  node_replay_check["Replay checks<br/>[gateway.py]"]
  node_gateway_uplink["Cloud forwarding<br/>[gateway.py]"]
  node_gateway_admin["Gateway admin<br/>[admin.py]"]
end

subgraph group_cloud["Cloud service"]
  node_cloud_api["Telemetry API<br/>[app.py]"]
  node_reading_store[("Reading store<br/>[app.py]")]
  node_dashboard["Live dashboard<br/>[dashboard.html]"]
end

subgraph group_security["Secure channels"]
  node_pqc_handshake["ML-KEM handshake<br/>[channel.py]"]
  node_message_crypto["Session encryption<br/>[channel.py]"]
  node_legacy_uplink["Legacy cloud path<br/>[gateway.py]"]
end

subgraph group_operations["Operations"]
  node_cloud_metrics["Cloud metrics<br/>[metrics.py]"]
  node_gateway_metrics["Gateway metrics<br/>[metrics.py]"]
  node_structured_logs["Structured logging<br/>[logs.py]"]
  node_baseline_tool["Baseline measurements<br/>[baseline.py]"]
end

node_device_actor(("Sensor device"))
node_operator(("Operator"))
node_prometheus(("Metrics scraper"))

node_device_actor -->|"starts"| node_sensor
node_sensor -->|"builds frames"| node_legacy_protocol
node_legacy_protocol -->|"sends TCP frames"| node_gateway_ingest
node_gateway_ingest -->|"decodes frames"| node_legacy_protocol
node_gateway_ingest -->|"checks sequence"| node_replay_check
node_gateway_ingest -->|"forwards reading"| node_gateway_uplink
node_gateway_uplink -->|"establishes session"| node_pqc_handshake
node_pqc_handshake -->|"requests key and session"| node_cloud_api
node_gateway_uplink -->|"seals readings"| node_message_crypto
node_gateway_uplink -->|"posts sealed telemetry"| node_cloud_api
node_cloud_api -->|"decapsulates session"| node_pqc_handshake
node_cloud_api -->|"opens messages"| node_message_crypto
node_cloud_api -->|"stores readings"| node_reading_store
node_operator -->|"queries APIs"| node_cloud_api
node_cloud_api -->|"serves dashboard"| node_dashboard
node_gateway_uplink -.->|"selects rollback mode"| node_legacy_uplink
node_legacy_uplink -->|"posts legacy readings"| node_cloud_api
node_gateway_admin -->|"renders metrics"| node_gateway_metrics
node_gateway_uplink -->|"provides gateway status"| node_gateway_admin
node_cloud_api -->|"exposes metrics"| node_cloud_metrics
node_prometheus -->|"scrapes metrics"| node_cloud_api
node_prometheus -->|"scrapes metrics"| node_gateway_admin
node_gateway_ingest -->|"logs events"| node_structured_logs
node_cloud_api -->|"logs events"| node_structured_logs
node_baseline_tool -->|"measures baseline"| node_legacy_protocol
node_baseline_tool -->|"measures PQC costs"| node_message_crypto

click node_sensor "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/legacy_device/device.py"
click node_legacy_protocol "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/legacy_device/protocol.py"
click node_gateway_ingest "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py"
click node_replay_check "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py"
click node_gateway_uplink "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py"
click node_gateway_admin "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/admin.py"
click node_cloud_api "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/app.py"
click node_reading_store "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/app.py"
click node_dashboard "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/static/dashboard.html"
click node_pqc_handshake "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/pqc_channel/channel.py"
click node_message_crypto "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/pqc_channel/channel.py"
click node_legacy_uplink "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py"
click node_cloud_metrics "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/metrics.py"
click node_gateway_metrics "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/metrics.py"
click node_structured_logs "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/logs.py"
click node_baseline_tool "https://github.com/anur01/softwaredevproject_ml-kem/blob/main/tools/baseline.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_sensor,node_legacy_protocol toneBlue
class node_gateway_ingest,node_replay_check,node_gateway_uplink,node_gateway_admin toneAmber
class node_cloud_api,node_reading_store,node_dashboard toneMint
class node_pqc_handshake,node_message_crypto,node_legacy_uplink toneRose
class node_cloud_metrics,node_gateway_metrics,node_structured_logs,node_baseline_tool,node_device_actor,node_operator,node_prometheus toneIndigo
```

## Components

### Legacy device

- [Sensor simulator](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/legacy_device/device.py): `legacy_device/device.py`
- [Legacy framing](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/legacy_device/protocol.py): `legacy_device/protocol.py`

### Edge gateway

- [Frame ingest](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py): `edge_gateway/gateway.py`
- [Replay checks](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py): `edge_gateway/gateway.py`
- [Cloud forwarding](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py): `edge_gateway/gateway.py`
- [Gateway admin](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/admin.py): `edge_gateway/admin.py`

### Cloud service

- [Telemetry API](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/app.py): `cloud_service/app.py`
- [Reading store](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/app.py): `cloud_service/app.py`
- [Live dashboard](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/cloud_service/static/dashboard.html): `cloud_service/static/dashboard.html`

### Secure channels

- [ML-KEM handshake](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/pqc_channel/channel.py): `pqc_channel/channel.py`
- [Session encryption](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/pqc_channel/channel.py): `pqc_channel/channel.py`
- [Legacy cloud path](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/edge_gateway/gateway.py): `edge_gateway/gateway.py`

### Operations

- [Cloud metrics](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/metrics.py): `observability/metrics.py`
- [Gateway metrics](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/metrics.py): `observability/metrics.py`
- [Structured logging](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/observability/logs.py): `observability/logs.py`
- [Baseline measurements](https://github.com/anur01/softwaredevproject_ml-kem/blob/main/tools/baseline.py): `tools/baseline.py`

### Other components

- **Sensor device**
- **Operator**
- **Metrics scraper**

## Connections

- Sensor device → Sensor simulator: starts (evidence: `README.md`)
- Sensor simulator → Legacy framing: builds frames (evidence: `legacy_device/device.py`)
- Legacy framing → Frame ingest: sends TCP frames (evidence: `README.md`)
- Frame ingest → Legacy framing: decodes frames (evidence: `edge_gateway/gateway.py`)
- Frame ingest → Replay checks: checks sequence (evidence: `README.md`)
- Frame ingest → Cloud forwarding: forwards reading (evidence: `README.md`)
- Cloud forwarding → ML-KEM handshake: establishes session (evidence: `edge_gateway/gateway.py`)
- ML-KEM handshake → Telemetry API: requests key and session (evidence: `README.md`)
- Cloud forwarding → Session encryption: seals readings (evidence: `README.md`)
- Cloud forwarding → Telemetry API: posts sealed telemetry (evidence: `README.md`)
- Telemetry API → ML-KEM handshake: decapsulates session (evidence: `cloud_service/app.py`)
- Telemetry API → Session encryption: opens messages (evidence: `README.md`)
- Telemetry API → Reading store: stores readings (evidence: `cloud_service/app.py`)
- Operator → Telemetry API: queries APIs (evidence: `README.md`)
- Telemetry API → Live dashboard: serves dashboard (evidence: `README.md`)
- Cloud forwarding → Legacy cloud path: selects rollback mode (evidence: `README.md`)
- Legacy cloud path → Telemetry API: posts legacy readings (evidence: `README.md`)
- Gateway admin → Gateway metrics: renders metrics (evidence: `edge_gateway/admin.py`)
- Cloud forwarding → Gateway admin: provides gateway status (evidence: `edge_gateway/gateway.py`)
- Telemetry API → Cloud metrics: exposes metrics (evidence: `cloud_service/app.py`)
- Metrics scraper → Telemetry API: scrapes metrics (evidence: `README.md`)
- Metrics scraper → Gateway admin: scrapes metrics (evidence: `README.md`)
- Frame ingest → Structured logging: logs events (evidence: `edge_gateway/gateway.py`)
- Telemetry API → Structured logging: logs events (evidence: `cloud_service/app.py`)
- Baseline measurements → Legacy framing: measures baseline (evidence: `tools/baseline.py`)
- Baseline measurements → Session encryption: measures PQC costs (evidence: `tools/baseline.py`)
