# ramnindra/fleetmanagementplatform architecture

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

- Interactive diagram: https://gitdiagram.com/ramnindra/fleetmanagementplatform
- Repository: https://github.com/ramnindra/fleetmanagementplatform

## Overview

Cloud Device Controller manages a fleet through registration, secure enrollment, MQTT heartbeats and telemetry, command delivery and acknowledgments, and status/message inspection in the web UI. Bulk provisioning renders enrollment bundles; device agents and the simulator connect as fleet members, while the load-test harness measures onboarding and command behavior. Internally, the controller separates REST handling, business logic, persistence, MQTT integration, and metrics. The graph includes documented monitoring and simulator capabilities; some connections rely on README statements because their implementation was not sampled.

Main entry points: [`controller/internal/api/api.go`](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/api/api.go) (REST API), [`controller/cmd/controller/main.go`](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/cmd/controller/main.go) (Controller Runtime), [`controller/internal/mqttc/mqttc.go`](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/mqttc/mqttc.go) (Controller MQTT), [`controller/internal/service/service.go`](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/service/service.go) (Fleet Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_onboarding["Onboarding"]
  node_bulk["Bulk Provisioner<br/>[main.go]"]
  node_provision["Provisioning Logic<br/>[provision.go]"]
end

subgraph group_controller["Controller"]
  node_controller["Controller Runtime<br/>[main.go]"]
  node_api["REST API<br/>[api.go]"]
  node_service["Fleet Service<br/>[service.go]"]
  node_security["Credential Security<br/>[security.go]"]
  node_mqtt["Controller MQTT<br/>[mqttc.go]"]
  node_store["Store Interface<br/>[store.go]"]
  node_postgres["Postgres Store<br/>[postgres.go]"]
  node_database[("PostgreSQL")]
  node_ui["Fleet Web UI<br/>[ui.go]"]
end

subgraph group_device["Device Runtime"]
  node_agent["Device Agent<br/>[main.go]"]
  node_enrollment["Agent Enrollment<br/>[enrollment.go]"]
  node_agentmqtt["Agent MQTT<br/>[mqttc.go]"]
  node_commands["Allowlisted Commands<br/>[commands.go]"]
  node_telemetry["Device Telemetry<br/>[telemetry.go]"]
end

subgraph group_simulation["Simulation"]
  node_simulator["Device Simulator<br/>[main.go]"]
  node_simcore["Simulation Runtime<br/>[sim.go]"]
  node_loadtest["Load Test<br/>[main.go]"]
end

subgraph group_operations["Operations"]
  node_metrics["Controller Metrics<br/>[metrics.go]"]
  node_prometheus["Prometheus"]
end

node_admin(("Fleet Operator"))
node_broker["EMQX Broker"]

node_admin -->|"provisions fleet"| node_bulk
node_bulk -->|"renders bundles"| node_provision
node_provision -->|"registers devices"| node_api
node_agent -->|"enrolls device"| node_enrollment
node_agent -->|"connects and publishes"| node_agentmqtt
node_agent -->|"executes commands"| node_commands
node_agent -->|"collects telemetry"| node_telemetry
node_agentmqtt -->|"exchanges MQTT"| node_broker
node_controller -->|"serves API"| node_api
node_controller -->|"constructs service"| node_service
node_controller -->|"starts client"| node_mqtt
node_controller -->|"initializes metrics"| node_metrics
node_controller -->|"connects store"| node_postgres
node_api -->|"handles fleet requests"| node_service
node_api -->|"publishes commands"| node_mqtt
node_api -.->|"serves interface"| node_ui
node_service -->|"validates credentials"| node_security
node_service -->|"reads and writes"| node_store
node_postgres -->|"persists fleet data"| node_database
node_postgres -->|"implements interface"| node_store
node_mqtt -->|"records device events"| node_service
node_mqtt -->|"exchanges MQTT"| node_broker
node_mqtt -->|"updates counters"| node_metrics
node_metrics -->|"reads device counts"| node_store
node_prometheus -->|"scrapes metrics"| node_metrics
node_simulator -->|"runs simulated fleet"| node_simcore
node_simcore -.->|"registers and enrolls"| node_api
node_simcore -.->|"simulates MQTT devices"| node_broker
node_loadtest -->|"provisions test devices"| node_simcore
node_loadtest -->|"measures commands"| node_api

click node_bulk "https://github.com/ramnindra/fleetmanagementplatform/blob/main/provisioning/cmd/bulk-provision/main.go"
click node_provision "https://github.com/ramnindra/fleetmanagementplatform/blob/main/provisioning/internal/provision/provision.go"
click node_agent "https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/cmd/device-agent/main.go"
click node_enrollment "https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/enrollment/enrollment.go"
click node_agentmqtt "https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/mqttc/mqttc.go"
click node_commands "https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/commands/commands.go"
click node_telemetry "https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/telemetry/telemetry.go"
click node_controller "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/cmd/controller/main.go"
click node_api "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/api/api.go"
click node_service "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/service/service.go"
click node_security "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/security/security.go"
click node_mqtt "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/mqttc/mqttc.go"
click node_store "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/store/store.go"
click node_postgres "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/store/postgres.go"
click node_ui "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/ui/ui.go"
click node_simulator "https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/cmd/simulator/main.go"
click node_simcore "https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/internal/sim/sim.go"
click node_loadtest "https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/cmd/load-test/main.go"
click node_metrics "https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/metrics/metrics.go"

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_bulk,node_provision toneBlue
class node_controller,node_api,node_service,node_security,node_mqtt,node_store,node_postgres,node_database,node_ui toneAmber
class node_agent,node_enrollment,node_agentmqtt,node_commands,node_telemetry toneMint
class node_simulator,node_simcore,node_loadtest toneRose
class node_metrics,node_prometheus,node_admin,node_broker toneIndigo
```

## Components

### Onboarding

- [Bulk Provisioner](https://github.com/ramnindra/fleetmanagementplatform/blob/main/provisioning/cmd/bulk-provision/main.go): `provisioning/cmd/bulk-provision/main.go`
- [Provisioning Logic](https://github.com/ramnindra/fleetmanagementplatform/blob/main/provisioning/internal/provision/provision.go): `provisioning/internal/provision/provision.go`

### Controller

- [Controller Runtime](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/cmd/controller/main.go): `controller/cmd/controller/main.go`
- [REST API](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/api/api.go): `controller/internal/api/api.go`
- [Fleet Service](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/service/service.go): `controller/internal/service/service.go`
- [Credential Security](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/security/security.go): `controller/internal/security/security.go`
- [Controller MQTT](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/mqttc/mqttc.go): `controller/internal/mqttc/mqttc.go`
- [Store Interface](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/store/store.go): `controller/internal/store/store.go`
- [Postgres Store](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/store/postgres.go): `controller/internal/store/postgres.go`
- **PostgreSQL**
- [Fleet Web UI](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/ui/ui.go): `controller/internal/ui/ui.go`

### Device Runtime

- [Device Agent](https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/cmd/device-agent/main.go): `device-agent/cmd/device-agent/main.go`
- [Agent Enrollment](https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/enrollment/enrollment.go): `device-agent/internal/enrollment/enrollment.go`
- [Agent MQTT](https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/mqttc/mqttc.go): `device-agent/internal/mqttc/mqttc.go`
- [Allowlisted Commands](https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/commands/commands.go): `device-agent/internal/commands/commands.go`
- [Device Telemetry](https://github.com/ramnindra/fleetmanagementplatform/blob/main/device-agent/internal/telemetry/telemetry.go): `device-agent/internal/telemetry/telemetry.go`

### Simulation

- [Device Simulator](https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/cmd/simulator/main.go): `simulator/cmd/simulator/main.go`
- [Simulation Runtime](https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/internal/sim/sim.go): `simulator/internal/sim/sim.go`
- [Load Test](https://github.com/ramnindra/fleetmanagementplatform/blob/main/simulator/cmd/load-test/main.go): `simulator/cmd/load-test/main.go`

### Operations

- [Controller Metrics](https://github.com/ramnindra/fleetmanagementplatform/blob/main/controller/internal/metrics/metrics.go): `controller/internal/metrics/metrics.go`
- **Prometheus**

### Other components

- **Fleet Operator**
- **EMQX Broker**

## Connections

- Fleet Operator → Bulk Provisioner: provisions fleet (evidence: `README.md`)
- Bulk Provisioner → Provisioning Logic: renders bundles (evidence: `provisioning/cmd/bulk-provision/main.go`)
- Provisioning Logic → REST API: registers devices
- Device Agent → Agent Enrollment: enrolls device (evidence: `device-agent/cmd/device-agent/main.go`)
- Device Agent → Agent MQTT: connects and publishes (evidence: `device-agent/cmd/device-agent/main.go`)
- Device Agent → Allowlisted Commands: executes commands (evidence: `device-agent/cmd/device-agent/main.go`)
- Device Agent → Device Telemetry: collects telemetry (evidence: `device-agent/cmd/device-agent/main.go`)
- Agent MQTT → EMQX Broker: exchanges MQTT (evidence: `README.md`)
- Controller Runtime → REST API: serves API (evidence: `controller/cmd/controller/main.go`)
- Controller Runtime → Fleet Service: constructs service (evidence: `controller/cmd/controller/main.go`)
- Controller Runtime → Controller MQTT: starts client (evidence: `controller/cmd/controller/main.go`)
- Controller Runtime → Controller Metrics: initializes metrics (evidence: `controller/cmd/controller/main.go`)
- Controller Runtime → Postgres Store: connects store (evidence: `controller/cmd/controller/main.go`)
- REST API → Fleet Service: handles fleet requests (evidence: `controller/internal/api/api.go`)
- REST API → Controller MQTT: publishes commands (evidence: `README.md`)
- REST API → Fleet Web UI: serves interface
- Fleet Service → Credential Security: validates credentials (evidence: `controller/internal/service/service.go`)
- Fleet Service → Store Interface: reads and writes (evidence: `controller/internal/service/service.go`)
- Postgres Store → PostgreSQL: persists fleet data (evidence: `README.md`)
- Postgres Store → Store Interface: implements interface (evidence: `controller/internal/store/postgres.go`)
- Controller MQTT → Fleet Service: records device events (evidence: `controller/internal/mqttc/mqttc.go`)
- Controller MQTT → EMQX Broker: exchanges MQTT (evidence: `controller/internal/mqttc/mqttc.go`)
- Controller MQTT → Controller Metrics: updates counters (evidence: `controller/internal/mqttc/mqttc.go`)
- Controller Metrics → Store Interface: reads device counts (evidence: `controller/internal/metrics/metrics.go`)
- Prometheus → Controller Metrics: scrapes metrics (evidence: `README.md`)
- Device Simulator → Simulation Runtime: runs simulated fleet (evidence: `simulator/cmd/simulator/main.go`)
- Simulation Runtime → REST API: registers and enrolls
- Simulation Runtime → EMQX Broker: simulates MQTT devices
- Load Test → Simulation Runtime: provisions test devices (evidence: `simulator/cmd/load-test/main.go`)
- Load Test → REST API: measures commands (evidence: `simulator/cmd/load-test/main.go`)
