# acridgold/netlabs architecture

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

- Interactive diagram: https://gitdiagram.com/acridgold/netlabs
- Repository: https://github.com/acridgold/netlabs

## Overview

This Kotlin application discovers live instances on an IPv4 or IPv6 multicast network. The workflow is: an operator supplies multicast settings, the command-line entry point validates them and selects an interface, then the discovery service sends and receives heartbeats, tracks peers, expires stale entries, and prints changes. Protocol handles heartbeat encoding and decoding; PeerRegistry holds the current peer state. Source excerpts show these runtime calls; no README content was provided.

Main entry points: [`lab1/src/main/kotlin/SelfDiscovery.kt`](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/SelfDiscovery.kt) (Discovery service), [`lab1/src/main/kotlin/AppRunner.kt`](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/AppRunner.kt) (App runner), [`lab1/src/main/kotlin/Main.kt`](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Main.kt) (Program entry), [`lab1/src/main/kotlin/Config.kt`](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Config.kt) (Argument config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and configuration"]
  node_main["Program entry<br/>[Main.kt]"]
  node_runner["App runner<br/>[AppRunner.kt]"]
  node_config["Argument config<br/>[Config.kt]"]
end

subgraph group_discovery["Peer discovery"]
  node_discovery_service["Discovery service<br/>[SelfDiscovery.kt]"]
  node_protocol["Heartbeat protocol<br/>[Protocol.kt]"]
  node_registry[("Peer registry<br/>[PerRegestry.kt]")]
end

node_operator(("Operator"))
node_multicast_network{{"Multicast network"}}
node_peer_instances(("Peer instances"))

node_operator -->|"provides arguments"| node_main
node_main -->|"calls"| node_runner
node_runner -->|"parses settings"| node_config
node_runner -->|"starts"| node_discovery_service
node_discovery_service -->|"formats and parses"| node_protocol
node_discovery_service -->|"updates and prunes"| node_registry
node_discovery_service -->|"sends and receives"| node_multicast_network
node_peer_instances -.->|"exchanges heartbeats"| node_multicast_network

click node_main "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Main.kt"
click node_runner "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/AppRunner.kt"
click node_config "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Config.kt"
click node_discovery_service "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/SelfDiscovery.kt"
click node_protocol "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Protocol.kt"
click node_registry "https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/PerRegestry.kt"

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_main,node_runner,node_config toneBlue
class node_discovery_service,node_protocol,node_registry toneAmber
class node_operator,node_multicast_network,node_peer_instances toneIndigo
```

## Components

### Startup and configuration

- [Program entry](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Main.kt): `lab1/src/main/kotlin/Main.kt`
- [App runner](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/AppRunner.kt): `lab1/src/main/kotlin/AppRunner.kt`
- [Argument config](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Config.kt): `lab1/src/main/kotlin/Config.kt`

### Peer discovery

- [Discovery service](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/SelfDiscovery.kt): `lab1/src/main/kotlin/SelfDiscovery.kt`
- [Heartbeat protocol](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/Protocol.kt): `lab1/src/main/kotlin/Protocol.kt`
- [Peer registry](https://github.com/acridgold/netlabs/blob/main/lab1/src/main/kotlin/PerRegestry.kt): `lab1/src/main/kotlin/PerRegestry.kt`

### Other components

- **Operator**
- **Multicast network**
- **Peer instances**

## Connections

- Operator → Program entry: provides arguments (evidence: `lab1/src/main/kotlin/Main.kt`)
- Program entry → App runner: calls (evidence: `lab1/src/main/kotlin/Main.kt`)
- App runner → Argument config: parses settings (evidence: `lab1/src/main/kotlin/AppRunner.kt`)
- App runner → Discovery service: starts (evidence: `lab1/src/main/kotlin/AppRunner.kt`)
- Discovery service → Heartbeat protocol: formats and parses (evidence: `lab1/src/main/kotlin/SelfDiscovery.kt`)
- Discovery service → Peer registry: updates and prunes (evidence: `lab1/src/main/kotlin/SelfDiscovery.kt`)
- Discovery service → Multicast network: sends and receives (evidence: `lab1/src/main/kotlin/SelfDiscovery.kt`)
- Peer instances → Multicast network: exchanges heartbeats
