# cynthefer/libcyn architecture

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

- Interactive diagram: https://gitdiagram.com/cynthefer/libcyn
- Repository: https://github.com/cynthefer/libcyn

## Overview

libcyn is a dependency-free C library that collects structured Linux user, system, network, memory, storage, CPU, GPU, and hardware information. A caller creates a context and requests collection; the collector dispatches to independent section readers and fills per-field values and statuses. Callers can also use cached single-field accessors or serialize collected data as JSON. Public-IP lookup and PCI-name resolution are optional capabilities. Some section implementations were not excerpted, so their internal data sources and helper calls are not mapped.

Main entry points: [`src/cyn.c`](https://github.com/cynthefer/libcyn/blob/main/src/cyn.c) (Context & Collector), [`src/network.c`](https://github.com/cynthefer/libcyn/blob/main/src/network.c) (Network Reader), [`include/cyn.h`](https://github.com/cynthefer/libcyn/blob/main/include/cyn.h) (C API), [`src/gpu.c`](https://github.com/cynthefer/libcyn/blob/main/src/gpu.c) (GPU Reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_interface["C API<br/>[cyn.h]"]
end

subgraph group_collection["Collection"]
  node_collector["Context &amp; Collector<br/>[cyn.c]"]
  node_internals["Internal Contracts<br/>[internal.h]"]
  node_helpers["Field &amp; Process Utilities<br/>[util.c]"]
end

subgraph group_readers["System Readers"]
  node_user["User Reader<br/>[user.c]"]
  node_system["System Reader<br/>[system.c]"]
  node_network["Network Reader<br/>[network.c]"]
  node_memory["Memory Reader<br/>[memory.c]"]
  node_storage["Storage Reader<br/>[storage.c]"]
  node_cpu["CPU Reader<br/>[cpu.c]"]
  node_gpu["GPU Reader<br/>[gpu.c]"]
  node_hardware["Hardware Reader<br/>[hardware.c]"]
  node_pci["PCI Name Resolver<br/>[gpu_pci.c]"]
end

subgraph group_format["Output Helpers"]
  node_json["JSON Serializer<br/>[json.c]"]
end

node_caller(("Library Caller"))
node_linux(("Linux System"))
node_curl(("curl / IP Service"))
node_pciids["pci.ids Data<br/>[pci.ids]"]

node_caller -->|"calls"| node_interface
node_interface -->|"exposes"| node_collector
node_collector -->|"collects"| node_user
node_collector -->|"collects"| node_system
node_collector -->|"collects"| node_network
node_collector -->|"collects"| node_memory
node_collector -->|"collects"| node_storage
node_collector -->|"collects"| node_cpu
node_collector -->|"collects"| node_gpu
node_collector -->|"collects"| node_hardware
node_network -.->|"fetches IP"| node_curl
node_gpu -->|"resolves name"| node_pci
node_pci -->|"reads IDs"| node_pciids
node_caller -->|"serializes info"| node_json
node_linux -.->|"provides data"| node_system
node_linux -.->|"provides data"| node_network

click node_interface "https://github.com/cynthefer/libcyn/blob/main/include/cyn.h"
click node_collector "https://github.com/cynthefer/libcyn/blob/main/src/cyn.c"
click node_internals "https://github.com/cynthefer/libcyn/blob/main/src/internal.h"
click node_user "https://github.com/cynthefer/libcyn/blob/main/src/user.c"
click node_system "https://github.com/cynthefer/libcyn/blob/main/src/system.c"
click node_network "https://github.com/cynthefer/libcyn/blob/main/src/network.c"
click node_memory "https://github.com/cynthefer/libcyn/blob/main/src/memory.c"
click node_storage "https://github.com/cynthefer/libcyn/blob/main/src/storage.c"
click node_cpu "https://github.com/cynthefer/libcyn/blob/main/src/cpu.c"
click node_gpu "https://github.com/cynthefer/libcyn/blob/main/src/gpu.c"
click node_hardware "https://github.com/cynthefer/libcyn/blob/main/src/hardware.c"
click node_helpers "https://github.com/cynthefer/libcyn/blob/main/src/util.c"
click node_pci "https://github.com/cynthefer/libcyn/blob/main/src/gpu_pci.c"
click node_json "https://github.com/cynthefer/libcyn/blob/main/src/json.c"
click node_pciids "https://github.com/cynthefer/libcyn/blob/main/data/pci.ids"

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_interface toneBlue
class node_collector,node_internals,node_helpers toneAmber
class node_user,node_system,node_network,node_memory,node_storage,node_cpu,node_gpu,node_hardware,node_pci toneMint
class node_json toneRose
class node_caller,node_linux,node_curl toneIndigo
class node_pciids toneTeal
```

## Components

### Public API

- [C API](https://github.com/cynthefer/libcyn/blob/main/include/cyn.h): `include/cyn.h`

### Collection

- [Context & Collector](https://github.com/cynthefer/libcyn/blob/main/src/cyn.c): `src/cyn.c`
- [Internal Contracts](https://github.com/cynthefer/libcyn/blob/main/src/internal.h): `src/internal.h`
- [Field & Process Utilities](https://github.com/cynthefer/libcyn/blob/main/src/util.c): `src/util.c`

### System Readers

- [User Reader](https://github.com/cynthefer/libcyn/blob/main/src/user.c): `src/user.c`
- [System Reader](https://github.com/cynthefer/libcyn/blob/main/src/system.c): `src/system.c`
- [Network Reader](https://github.com/cynthefer/libcyn/blob/main/src/network.c): `src/network.c`
- [Memory Reader](https://github.com/cynthefer/libcyn/blob/main/src/memory.c): `src/memory.c`
- [Storage Reader](https://github.com/cynthefer/libcyn/blob/main/src/storage.c): `src/storage.c`
- [CPU Reader](https://github.com/cynthefer/libcyn/blob/main/src/cpu.c): `src/cpu.c`
- [GPU Reader](https://github.com/cynthefer/libcyn/blob/main/src/gpu.c): `src/gpu.c`
- [Hardware Reader](https://github.com/cynthefer/libcyn/blob/main/src/hardware.c): `src/hardware.c`
- [PCI Name Resolver](https://github.com/cynthefer/libcyn/blob/main/src/gpu_pci.c): `src/gpu_pci.c`

### Output Helpers

- [JSON Serializer](https://github.com/cynthefer/libcyn/blob/main/src/json.c): `src/json.c`

### Other components

- **Library Caller**
- **Linux System**
- **curl / IP Service**
- [pci.ids Data](https://github.com/cynthefer/libcyn/blob/main/data/pci.ids): `data/pci.ids`

## Connections

- Library Caller → C API: calls (evidence: `README.md`)
- C API → Context & Collector: exposes (evidence: `include/cyn.h`)
- Context & Collector → User Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → System Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → Network Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → Memory Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → Storage Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → CPU Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → GPU Reader: collects (evidence: `src/cyn.c`)
- Context & Collector → Hardware Reader: collects (evidence: `src/cyn.c`)
- Network Reader → curl / IP Service: fetches IP (evidence: `src/network.c`)
- GPU Reader → PCI Name Resolver: resolves name (evidence: `src/gpu.c`)
- PCI Name Resolver → pci.ids Data: reads IDs (evidence: `src/gpu_pci.c`)
- Library Caller → JSON Serializer: serializes info (evidence: `README.md`)
- Linux System → System Reader: provides data
- Linux System → Network Reader: provides data
