# gravitech-engineer/ais_iot_4g architecture

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

- Interactive diagram: https://gitdiagram.com/gravitech-engineer/ais_iot_4g
- Repository: https://github.com/gravitech-engineer/ais_iot_4g

## Overview

AIS 4G Board Library is an Arduino runtime for an ESP32/SIM7600 board. An Arduino sketch can use the board APIs to acquire sensor or GPS data, communicate over cellular networking or RS485, and store files; MQTT and the Magellan or Azure integrations provide cloud-facing capabilities. The graph also shows the Magellan device core’s supporting configuration, sensor, storage, and OTA layers. The README documents product capabilities, but sampled excerpts do not establish most subsystem call paths, so those links are dashed rather than asserted as verified calls.

Main entry points: [`src/utils/Attribute_MQTT_core.cpp`](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/Attribute_MQTT_core.cpp) (Attribute MQTT Core), [`src/Storage.cpp`](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/Storage.cpp) (Modem File Storage), [`src/GSMClient.cpp`](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMClient.cpp) (TCP Client), [`src/PubSubClient.cpp`](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/PubSubClient.cpp) (MQTT Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_board_io["Board I/O"]
  node_gps["GPS<br/>[GPS.cpp]"]
  node_sht40["Temperature Sensor<br/>[SHT40.cpp]"]
  node_rs485["RS485 / Modbus<br/>[RS485.cpp]"]
  node_board_storage[("Modem File Storage<br/>[Storage.cpp]")]
end

subgraph group_cellular["Cellular Networking"]
  node_sim_base["SIM Command Base<br/>[SIMBase.cpp]"]
  node_sim76xx["SIM7600 Modem<br/>[SIM76xx.cpp]"]
  node_network["Cellular Network<br/>[GSMNetwok.cpp]"]
  node_gsm_client["TCP Client<br/>[GSMClient.cpp]"]
  node_secure_client["Secure Client"]
  node_ssl["TLS Support<br/>[gsm_ssl_client.cpp]"]
end

subgraph group_cloud["Cloud Connectivity"]
  node_mqtt_transport["MQTT Client<br/>[PubSubClient.cpp]"]
  node_azure_hub["Azure IoT Hub<br/>[AzureIoTHub.cpp]"]
  node_azure_central["Azure IoT Central"]
  node_magellan_board["Board Magellan SDK"]
  node_magellan_temp["Magellan Telemetry"]
end

subgraph group_magellan_support["Magellan Support"]
  node_magellan_core["Magellan Device Core"]
  node_attribute_core["Attribute MQTT Core"]
  node_builtin_sensor["Built-in Sensors<br/>[BuiltinSensor.cpp]"]
  node_filesystem[("Filesystem Access<br/>[FileSystem.cpp]")]
  node_memory_storage[("External Memory Storage<br/>[StorageMemory.cpp]")]
  node_ota_config["OTA Configuration"]
  node_api_subscribe["API Subscriptions"]
end

node_sketch(("Arduino Sketch"))
node_magellan_service(("Magellan Platform"))
node_azure_service(("Azure IoT"))
node_external_device(("External RS485 Device"))

node_sketch -.->|"reads position"| node_gps
node_sketch -.->|"reads telemetry"| node_sht40
node_sketch -.->|"communicates via"| node_rs485
node_rs485 -.->|"exchanges data"| node_external_device
node_sketch -.->|"stores files"| node_board_storage
node_board_storage -->|"sends modem commands"| node_sim_base
node_sim_base -.->|"controls modem"| node_sim76xx
node_sim76xx -.->|"provides cellular access"| node_network
node_network -.->|"supports TCP"| node_gsm_client
node_gsm_client -->|"backs secure client"| node_secure_client
node_secure_client -->|"uses TLS functions"| node_ssl
node_sketch -.->|"uses MQTT"| node_mqtt_transport
node_mqtt_transport -.->|"uses client transport"| node_gsm_client
node_sketch -.->|"connects to Hub"| node_azure_hub
node_sketch -.->|"connects to Central"| node_azure_central
node_sketch -.->|"uses board SDK"| node_magellan_board
node_sketch -.->|"reports telemetry"| node_magellan_temp
node_magellan_board -.->|"connects to platform"| node_magellan_service
node_magellan_temp -.->|"reports telemetry"| node_magellan_service
node_azure_hub -.->|"connects to Azure"| node_azure_service
node_azure_central -.->|"connects to Azure"| node_azure_service
node_magellan_core -->|"uses MQTT"| node_mqtt_transport
node_magellan_core -->|"uses attribute core"| node_attribute_core
node_attribute_core -->|"uses sensors"| node_builtin_sensor
node_attribute_core -->|"uses filesystem"| node_filesystem
node_attribute_core -->|"uses memory storage"| node_memory_storage
node_attribute_core -->|"uses OTA configuration"| node_ota_config
node_attribute_core -->|"uses subscriptions"| node_api_subscribe
node_memory_storage -->|"wraps file storage"| node_board_storage

click node_gps "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GPS.cpp"
click node_sht40 "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SHT40.cpp"
click node_rs485 "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/RS485.cpp"
click node_board_storage "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/Storage.cpp"
click node_sim_base "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SIMBase.cpp"
click node_sim76xx "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SIM76xx.cpp"
click node_network "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMNetwok.cpp"
click node_gsm_client "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMClient.cpp"
click node_secure_client "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMClientSecure.cpp"
click node_ssl "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/gsm_ssl_client.cpp"
click node_mqtt_transport "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/PubSubClient.cpp"
click node_azure_hub "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/AzureIoTHub.cpp"
click node_azure_central "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/AzureIoTCentral.cpp"
click node_magellan_board "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/MAGELLAN_MQTT_4G_BOARD.cpp"
click node_magellan_temp "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/MAGELLAN_MQTT_TEMP.cpp"
click node_magellan_core "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/MAGELLAN_MQTT_device_core.cpp"
click node_attribute_core "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/Attribute_MQTT_core.cpp"
click node_builtin_sensor "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/BuiltinSensor.cpp"
click node_filesystem "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/FileSystem.cpp"
click node_memory_storage "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/StorageMemory.cpp"
click node_ota_config "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/manageConfigOTAFile.cpp"
click node_api_subscribe "https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/APISubscribeHandler.h"

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_gps,node_sht40,node_rs485,node_board_storage toneBlue
class node_sim_base,node_sim76xx,node_network,node_gsm_client,node_secure_client,node_ssl toneAmber
class node_mqtt_transport,node_azure_hub,node_azure_central,node_magellan_board,node_magellan_temp toneMint
class node_magellan_core,node_attribute_core,node_builtin_sensor,node_filesystem,node_memory_storage,node_ota_config,node_api_subscribe toneRose
class node_sketch,node_magellan_service,node_azure_service,node_external_device toneIndigo
```

## Components

### Board I/O

- [GPS](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GPS.cpp): `src/GPS.cpp`
- [Temperature Sensor](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SHT40.cpp): `src/SHT40.cpp`
- [RS485 / Modbus](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/RS485.cpp): `src/RS485.cpp`
- [Modem File Storage](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/Storage.cpp): `src/Storage.cpp`

### Cellular Networking

- [SIM Command Base](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SIMBase.cpp): `src/SIMBase.cpp`
- [SIM7600 Modem](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/SIM76xx.cpp): `src/SIM76xx.cpp`
- [Cellular Network](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMNetwok.cpp): `src/GSMNetwok.cpp`
- [TCP Client](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMClient.cpp): `src/GSMClient.cpp`
- [Secure Client](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/GSMClientSecure.cpp): `src/GSMClientSecure.cpp`
- [TLS Support](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/gsm_ssl_client.cpp): `src/gsm_ssl_client.cpp`

### Cloud Connectivity

- [MQTT Client](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/PubSubClient.cpp): `src/PubSubClient.cpp`
- [Azure IoT Hub](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/AzureIoTHub.cpp): `src/AzureIoTHub.cpp`
- [Azure IoT Central](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/AzureIoTCentral.cpp): `src/AzureIoTCentral.cpp`
- [Board Magellan SDK](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/MAGELLAN_MQTT_4G_BOARD.cpp): `src/MAGELLAN_MQTT_4G_BOARD.cpp`
- [Magellan Telemetry](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/MAGELLAN_MQTT_TEMP.cpp): `src/MAGELLAN_MQTT_TEMP.cpp`

### Magellan Support

- [Magellan Device Core](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/MAGELLAN_MQTT_device_core.cpp): `src/utils/MAGELLAN_MQTT_device_core.cpp`
- [Attribute MQTT Core](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/Attribute_MQTT_core.cpp): `src/utils/Attribute_MQTT_core.cpp`
- [Built-in Sensors](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/BuiltinSensor.cpp): `src/utils/BuiltinSensor.cpp`
- [Filesystem Access](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/FileSystem.cpp): `src/utils/FileSystem.cpp`
- [External Memory Storage](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/StorageMemory.cpp): `src/utils/StorageMemory.cpp`
- [OTA Configuration](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/manageConfigOTAFile.cpp): `src/utils/manageConfigOTAFile.cpp`
- [API Subscriptions](https://github.com/gravitech-engineer/ais_iot_4g/blob/main/src/utils/APISubscribeHandler.h): `src/utils/APISubscribeHandler.h`

### Other components

- **Arduino Sketch**
- **Magellan Platform**
- **Azure IoT**
- **External RS485 Device**

## Connections

- Arduino Sketch → GPS: reads position
- Arduino Sketch → Temperature Sensor: reads telemetry
- Arduino Sketch → RS485 / Modbus: communicates via
- RS485 / Modbus → External RS485 Device: exchanges data
- Arduino Sketch → Modem File Storage: stores files
- Modem File Storage → SIM Command Base: sends modem commands (evidence: `src/Storage.cpp`)
- SIM Command Base → SIM7600 Modem: controls modem
- SIM7600 Modem → Cellular Network: provides cellular access
- Cellular Network → TCP Client: supports TCP
- TCP Client → Secure Client: backs secure client
- Secure Client → TLS Support: uses TLS functions
- Arduino Sketch → MQTT Client: uses MQTT
- MQTT Client → TCP Client: uses client transport
- Arduino Sketch → Azure IoT Hub: connects to Hub
- Arduino Sketch → Azure IoT Central: connects to Central
- Arduino Sketch → Board Magellan SDK: uses board SDK
- Arduino Sketch → Magellan Telemetry: reports telemetry
- Board Magellan SDK → Magellan Platform: connects to platform
- Magellan Telemetry → Magellan Platform: reports telemetry
- Azure IoT Hub → Azure IoT: connects to Azure
- Azure IoT Central → Azure IoT: connects to Azure
- Magellan Device Core → MQTT Client: uses MQTT
- Magellan Device Core → Attribute MQTT Core: uses attribute core
- Attribute MQTT Core → Built-in Sensors: uses sensors
- Attribute MQTT Core → Filesystem Access: uses filesystem
- Attribute MQTT Core → External Memory Storage: uses memory storage
- Attribute MQTT Core → OTA Configuration: uses OTA configuration
- Attribute MQTT Core → API Subscriptions: uses subscriptions
- External Memory Storage → Modem File Storage: wraps file storage
