# jelmervos/envoy-reader architecture

> Architecture diagram of the GitHub repository jelmervos/envoy-reader, 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/jelmervos/envoy-reader
- Repository: https://github.com/jelmervos/envoy-reader

## Overview

Envoy Reader is a hosted Enphase Envoy-S monitoring service. Its main cycle checks daylight, reads inverter production and optionally net frequency, then dispatches readings to configured output writers; the hosted service also maintains a healthcheck file. The README is brief, so details of the major integrations come mainly from the source index and sampled code. In particular, PVOutput and healthcheck writer internals were not sampled; their external interactions are shown only where documented or marked unverified.

Main entry points: [`EnvoyReader2/Aggregator/Aggregator.cs`](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Aggregator/Aggregator.cs) (Aggregator), [`EnvoyReader2/Service/EnvoyReaderService.cs`](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Service/EnvoyReaderService.cs) (Polling service), [`EnvoyReader2/Program.cs`](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Program.cs) (CLI host), [`EnvoyReader2/Readers/InputReaders.cs`](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Readers/InputReaders.cs) (Input readers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Hosted runtime"]
  node_cli["CLI host<br/>[Program.cs]"]
  node_service["Polling service"]
  node_wiring["Service wiring"]
end

subgraph group_collection["Collection and timing"]
  node_aggregator["Aggregator<br/>[Aggregator.cs]"]
  node_data["Inverter readings<br/>[InverterData.cs]"]
  node_inputreaders["Input readers<br/>[InputReaders.cs]"]
  node_envoyreader["Envoy reader<br/>[EnvoyReader.cs]"]
  node_clientfactory["Envoy client factory"]
  node_sunlight["Sunrise and sunset<br/>[SunriseSunset.cs]"]
  node_sunriset["Sunrise calculations<br/>[Sunriset.cs]"]
end

subgraph group_integrations["Output integrations"]
  node_ha_reader["Net frequency reader<br/>[HomeAssistant.cs]"]
  node_ha_api["Home Assistant API"]
  node_pvwriter["PVOutput writer<br/>[PvOutputWriter.cs]"]
end

subgraph group_health["Health monitoring"]
  node_healthwriter["Healthcheck writer"]
  node_healthservice["Healthcheck command"]
end

node_operator(("Operator"))
node_homeassistant["Home Assistant"]
node_pvoutput["PVOutput"]
node_healthfile["Healthcheck file"]
node_envoy["Enphase Envoy-S<br/>external system"]

node_operator -->|"starts"| node_cli
node_cli -->|"configures default"| node_service
node_cli -->|"configures command"| node_healthservice
node_wiring -->|"registers"| node_service
node_wiring -->|"registers"| node_aggregator
node_service -->|"runs periodically"| node_aggregator
node_service -->|"updates health"| node_healthwriter
node_aggregator -->|"checks daylight"| node_sunlight
node_aggregator -->|"reads inputs"| node_inputreaders
node_aggregator -->|"dispatches output"| node_pvwriter
node_inputreaders -->|"reads production"| node_envoyreader
node_inputreaders -->|"reads frequency"| node_ha_reader
node_envoyreader -->|"creates client"| node_clientfactory
node_clientfactory -.->|"authenticates and reads"| node_envoy
node_sunlight -->|"uses calculations"| node_sunriset
node_ha_reader -->|"requests state"| node_ha_api
node_ha_api -.->|"queries state"| node_homeassistant
node_pvwriter -.->|"submits readings"| node_pvoutput
node_healthwriter -.->|"writes status"| node_healthfile
node_healthservice -->|"checks freshness"| node_healthfile

click node_cli "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Program.cs"
click node_service "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Service/EnvoyReaderService.cs"
click node_wiring "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs"
click node_aggregator "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Aggregator/Aggregator.cs"
click node_data "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Aggregator/InverterData.cs"
click node_inputreaders "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Readers/InputReaders.cs"
click node_envoyreader "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Envoy/EnvoyReader.cs"
click node_clientfactory "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Envoy/EnvoyClientFactory.cs"
click node_sunlight "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/SunriseSunset/SunriseSunset.cs"
click node_sunriset "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/SunriseSunset/Sunriset.cs"
click node_ha_reader "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/HomeAssistant/HomeAssistant.cs"
click node_ha_api "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/HomeAssistant/IHomeAssistantApi.cs"
click node_pvwriter "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/PvOutput/PvOutputWriter.cs"
click node_healthwriter "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Healthcheck/HealthcheckWriter.cs"
click node_healthservice "https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Healthcheck/HealthcheckService.cs"

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_cli,node_service,node_wiring toneBlue
class node_aggregator,node_data,node_inputreaders,node_envoyreader,node_clientfactory,node_sunlight,node_sunriset toneAmber
class node_ha_reader,node_ha_api,node_pvwriter toneMint
class node_healthwriter,node_healthservice toneRose
class node_operator,node_homeassistant,node_pvoutput,node_healthfile,node_envoy toneIndigo
```

## Components

### Hosted runtime

- [CLI host](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Program.cs): `EnvoyReader2/Program.cs`
- [Polling service](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Service/EnvoyReaderService.cs): `EnvoyReader2/Service/EnvoyReaderService.cs`
- [Service wiring](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs): `EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs`

### Collection and timing

- [Aggregator](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Aggregator/Aggregator.cs): `EnvoyReader2/Aggregator/Aggregator.cs`
- [Inverter readings](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Aggregator/InverterData.cs): `EnvoyReader2/Aggregator/InverterData.cs`
- [Input readers](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Readers/InputReaders.cs): `EnvoyReader2/Readers/InputReaders.cs`
- [Envoy reader](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Envoy/EnvoyReader.cs): `EnvoyReader2/Envoy/EnvoyReader.cs`
- [Envoy client factory](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Envoy/EnvoyClientFactory.cs): `EnvoyReader2/Envoy/EnvoyClientFactory.cs`
- [Sunrise and sunset](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/SunriseSunset/SunriseSunset.cs): `EnvoyReader2/SunriseSunset/SunriseSunset.cs`
- [Sunrise calculations](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/SunriseSunset/Sunriset.cs): `EnvoyReader2/SunriseSunset/Sunriset.cs`

### Output integrations

- [Net frequency reader](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/HomeAssistant/HomeAssistant.cs): `EnvoyReader2/HomeAssistant/HomeAssistant.cs`
- [Home Assistant API](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/HomeAssistant/IHomeAssistantApi.cs): `EnvoyReader2/HomeAssistant/IHomeAssistantApi.cs`
- [PVOutput writer](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/PvOutput/PvOutputWriter.cs): `EnvoyReader2/PvOutput/PvOutputWriter.cs`

### Health monitoring

- [Healthcheck writer](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Healthcheck/HealthcheckWriter.cs): `EnvoyReader2/Healthcheck/HealthcheckWriter.cs`
- [Healthcheck command](https://github.com/jelmervos/envoy-reader/blob/main/EnvoyReader2/Healthcheck/HealthcheckService.cs): `EnvoyReader2/Healthcheck/HealthcheckService.cs`

### Other components

- **Operator**
- **Home Assistant**
- **PVOutput**
- **Healthcheck file**
- **Enphase Envoy-S**: external system

## Connections

- Operator → CLI host: starts (evidence: `EnvoyReader2/Program.cs`)
- CLI host → Polling service: configures default (evidence: `EnvoyReader2/Program.cs`)
- CLI host → Healthcheck command: configures command (evidence: `EnvoyReader2/Program.cs`)
- Service wiring → Polling service: registers (evidence: `EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs`)
- Service wiring → Aggregator: registers (evidence: `EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs`)
- Polling service → Aggregator: runs periodically (evidence: `EnvoyReader2/Service/EnvoyReaderService.cs`)
- Polling service → Healthcheck writer: updates health (evidence: `EnvoyReader2/Service/EnvoyReaderService.cs`)
- Aggregator → Sunrise and sunset: checks daylight (evidence: `EnvoyReader2/Aggregator/Aggregator.cs`)
- Aggregator → Input readers: reads inputs (evidence: `EnvoyReader2/Aggregator/Aggregator.cs`)
- Aggregator → PVOutput writer: dispatches output (evidence: `EnvoyReader2/Aggregator/Aggregator.cs`)
- Input readers → Envoy reader: reads production (evidence: `EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs`)
- Input readers → Net frequency reader: reads frequency (evidence: `EnvoyReader2/Service/EnvoyReaderServiceConfigurator.cs`)
- Envoy reader → Envoy client factory: creates client (evidence: `EnvoyReader2/Envoy/EnvoyReader.cs`)
- Envoy client factory → Enphase Envoy-S: authenticates and reads
- Sunrise and sunset → Sunrise calculations: uses calculations (evidence: `EnvoyReader2/SunriseSunset/SunriseSunset.cs`)
- Net frequency reader → Home Assistant API: requests state (evidence: `EnvoyReader2/HomeAssistant/HomeAssistant.cs`)
- Home Assistant API → Home Assistant: queries state
- PVOutput writer → PVOutput: submits readings
- Healthcheck writer → Healthcheck file: writes status
- Healthcheck command → Healthcheck file: checks freshness (evidence: `EnvoyReader2/Healthcheck/HealthcheckService.cs`)
