# sandertammesoo/ec2icp architecture

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

- Interactive diagram: https://gitdiagram.com/sandertammesoo/ec2icp
- Repository: https://github.com/sandertammesoo/ec2icp
- Video tour (about a minute): https://gitdiagram.com/sandertammesoo/ec2icp/video

## Overview

ec2icp combines an ICP packet/link protocol with MQTT-based simulator and tester applications. The visible workflow is tester commands published over MQTT, simulator-side ICP initialization and updates, and ICP output encoded and sent as MQTT payload bytes. The README is only a project title, and source excerpts are partial; application callback and subscription wiring beyond the shown code is represented conservatively.

Main entry points: [`subsystem_simulator/source/main.c`](https://github.com/sandertammesoo/ec2icp/blob/master/subsystem_simulator/source/main.c) (Subsystem simulator), [`tester/source/main.c`](https://github.com/sandertammesoo/ec2icp/blob/master/tester/source/main.c) (Interactive tester), [`icp/include/icp.h`](https://github.com/sandertammesoo/ec2icp/blob/master/icp/include/icp.h) (ICP API), [`mqtt/source/MQTTClient.c`](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTClient.c) (Client operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Applications"]
  node_tester["Interactive tester<br/>[main.c]"]
  node_sim["Subsystem simulator<br/>[main.c]"]
end

subgraph group_icp["ICP Protocol"]
  node_icp_api["ICP API<br/>[icp.h]"]
  node_icp_core["Framing and state<br/>[icp.c]"]
  node_icp_config["ICP configuration<br/>[icp_config.c]"]
end

subgraph group_mqtt["MQTT Client"]
  node_mqtt_async["Async client API<br/>[MQTTAsync.c]"]
  node_mqtt_client["Client operations<br/>[MQTTClient.c]"]
  node_mqtt_protocol["Protocol exchange"]
  node_mqtt_packets["Packet encoding<br/>[MQTTPacket.c]"]
  node_mqtt_socket["Socket transport<br/>[Socket.c]"]
  node_mqtt_persist[("Message persistence")]
end

node_user(("Operator"))
node_broker(("MQTT broker"))
node_topics["Topic definitions<br/>[topics.h]"]

node_user -->|"enters commands"| node_tester
node_tester -->|"selects topics"| node_topics
node_tester -->|"publishes commands"| node_mqtt_async
node_sim -->|"uses topics"| node_topics
node_sim -->|"connects and sends"| node_mqtt_async
node_sim -->|"configures and updates"| node_icp_api
node_icp_api -->|"initializes configuration"| node_icp_config
node_icp_api -->|"invokes protocol"| node_icp_core
node_icp_core -->|"calls configured callbacks"| node_sim
node_mqtt_async -->|"delegates operations"| node_mqtt_client
node_mqtt_client -->|"starts protocol exchange"| node_mqtt_protocol
node_mqtt_protocol -->|"encodes and handles"| node_mqtt_packets
node_mqtt_client -.->|"persists queued messages"| node_mqtt_persist
node_mqtt_packets -->|"transfers packets"| node_mqtt_socket
node_mqtt_socket -->|"exchanges MQTT data"| node_broker
node_broker -->|"delivers subscribed messages"| node_sim

click node_tester "https://github.com/sandertammesoo/ec2icp/blob/master/tester/source/main.c"
click node_sim "https://github.com/sandertammesoo/ec2icp/blob/master/subsystem_simulator/source/main.c"
click node_topics "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/include/topics.h"
click node_icp_api "https://github.com/sandertammesoo/ec2icp/blob/master/icp/include/icp.h"
click node_icp_core "https://github.com/sandertammesoo/ec2icp/blob/master/icp/source/icp.c"
click node_icp_config "https://github.com/sandertammesoo/ec2icp/blob/master/icp/source/icp_config.c"
click node_mqtt_async "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTAsync.c"
click node_mqtt_client "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTClient.c"
click node_mqtt_protocol "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTProtocolClient.c"
click node_mqtt_packets "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTPacket.c"
click node_mqtt_socket "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/Socket.c"
click node_mqtt_persist "https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTPersistenceDefault.c"

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_tester,node_sim toneBlue
class node_icp_api,node_icp_core,node_icp_config toneAmber
class node_mqtt_async,node_mqtt_client,node_mqtt_protocol,node_mqtt_packets,node_mqtt_socket,node_mqtt_persist toneMint
class node_user,node_broker toneIndigo
class node_topics toneTeal
```

## Components

### Applications

- [Interactive tester](https://github.com/sandertammesoo/ec2icp/blob/master/tester/source/main.c): `tester/source/main.c`
- [Subsystem simulator](https://github.com/sandertammesoo/ec2icp/blob/master/subsystem_simulator/source/main.c): `subsystem_simulator/source/main.c`

### ICP Protocol

- [ICP API](https://github.com/sandertammesoo/ec2icp/blob/master/icp/include/icp.h): `icp/include/icp.h`
- [Framing and state](https://github.com/sandertammesoo/ec2icp/blob/master/icp/source/icp.c): `icp/source/icp.c`
- [ICP configuration](https://github.com/sandertammesoo/ec2icp/blob/master/icp/source/icp_config.c): `icp/source/icp_config.c`

### MQTT Client

- [Async client API](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTAsync.c): `mqtt/source/MQTTAsync.c`
- [Client operations](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTClient.c): `mqtt/source/MQTTClient.c`
- [Protocol exchange](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTProtocolClient.c): `mqtt/source/MQTTProtocolClient.c`
- [Packet encoding](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTPacket.c): `mqtt/source/MQTTPacket.c`
- [Socket transport](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/Socket.c): `mqtt/source/Socket.c`
- [Message persistence](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/source/MQTTPersistenceDefault.c): `mqtt/source/MQTTPersistenceDefault.c`

### Other components

- **Operator**
- **MQTT broker**
- [Topic definitions](https://github.com/sandertammesoo/ec2icp/blob/master/mqtt/include/topics.h): `mqtt/include/topics.h`

## Connections

- Operator → Interactive tester: enters commands
- Interactive tester → Topic definitions: selects topics
- Interactive tester → Async client API: publishes commands
- Subsystem simulator → Topic definitions: uses topics
- Subsystem simulator → Async client API: connects and sends
- Subsystem simulator → ICP API: configures and updates
- ICP API → ICP configuration: initializes configuration
- ICP API → Framing and state: invokes protocol
- Framing and state → Subsystem simulator: calls configured callbacks
- Async client API → Client operations: delegates operations
- Client operations → Protocol exchange: starts protocol exchange
- Protocol exchange → Packet encoding: encodes and handles
- Client operations → Message persistence: persists queued messages
- Packet encoding → Socket transport: transfers packets
- Socket transport → MQTT broker: exchanges MQTT data
- MQTT broker → Subsystem simulator: delivers subscribed messages
