# karan90687/sensor_hub architecture

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

- Interactive diagram: https://gitdiagram.com/karan90687/sensor_hub
- Repository: https://github.com/karan90687/sensor_hub

## Overview

This is a small C packet-format example: one executable serializes a 13-byte frame, while another reads bytes, builds a packet, validates it, and prints it. The shared protocol code defines the packet and checks length, sync byte, checksum, and unused flag bits. The generator writes to `tests/data/edge.bin`, but the analyzer reads a different hard-coded absolute path, so the graph does not imply that the generator’s output feeds the analyzer. The README documents the byte layout; source excerpts establish the runtime calls.

Main entry points: [`host/main.c`](https://github.com/karan90687/sensor_hub/blob/main/host/main.c) (Buffer Analyzer), [`host/gen.c`](https://github.com/karan90687/sensor_hub/blob/main/host/gen.c) (Frame Generator), [`common/protocol.h`](https://github.com/karan90687/sensor_hub/blob/main/common/protocol.h) (Packet Definition), [`common/protocol.c`](https://github.com/karan90687/sensor_hub/blob/main/common/protocol.c) (Packet Validator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_format["Packet Format"]
  node_packet["Packet Definition<br/>[protocol.h]"]
  node_decoder["Packet Validator<br/>[protocol.c]"]
end

subgraph group_generation["Frame Generation"]
  node_generator["Frame Generator<br/>[gen.c]"]
  node_generated_file["Generated Buffer"]
end

subgraph group_analysis["Buffer Analysis"]
  node_input_file["Analysis Input"]
  node_analyzer["Buffer Analyzer<br/>[main.c]"]
  node_formatter["Packet Printer<br/>[format.c]"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_generator
node_generator -->|"populates"| node_packet
node_generator -->|"writes bytes"| node_generated_file
node_operator -->|"runs"| node_analyzer
node_analyzer -->|"reads bytes"| node_input_file
node_analyzer -->|"builds frame"| node_packet
node_analyzer -->|"validates"| node_decoder
node_decoder -->|"checks fields"| node_packet
node_analyzer -->|"prints valid frame"| node_formatter

click node_packet "https://github.com/karan90687/sensor_hub/blob/main/common/protocol.h"
click node_generator "https://github.com/karan90687/sensor_hub/blob/main/host/gen.c"
click node_analyzer "https://github.com/karan90687/sensor_hub/blob/main/host/main.c"
click node_decoder "https://github.com/karan90687/sensor_hub/blob/main/common/protocol.c"
click node_formatter "https://github.com/karan90687/sensor_hub/blob/main/host/format.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_packet,node_decoder toneBlue
class node_generator,node_generated_file toneAmber
class node_input_file,node_analyzer,node_formatter toneMint
class node_operator toneIndigo
```

## Components

### Packet Format

- [Packet Definition](https://github.com/karan90687/sensor_hub/blob/main/common/protocol.h): `common/protocol.h`
- [Packet Validator](https://github.com/karan90687/sensor_hub/blob/main/common/protocol.c): `common/protocol.c`

### Frame Generation

- [Frame Generator](https://github.com/karan90687/sensor_hub/blob/main/host/gen.c): `host/gen.c`
- **Generated Buffer**

### Buffer Analysis

- **Analysis Input**
- [Buffer Analyzer](https://github.com/karan90687/sensor_hub/blob/main/host/main.c): `host/main.c`
- [Packet Printer](https://github.com/karan90687/sensor_hub/blob/main/host/format.c): `host/format.c`

### Other components

- **Operator**

## Connections

- Operator → Frame Generator: runs (evidence: `host/gen.c`)
- Frame Generator → Packet Definition: populates (evidence: `host/gen.c`)
- Frame Generator → Generated Buffer: writes bytes (evidence: `host/gen.c`)
- Operator → Buffer Analyzer: runs (evidence: `host/main.c`)
- Buffer Analyzer → Analysis Input: reads bytes (evidence: `host/main.c`)
- Buffer Analyzer → Packet Definition: builds frame (evidence: `host/main.c`)
- Buffer Analyzer → Packet Validator: validates (evidence: `host/main.c`)
- Packet Validator → Packet Definition: checks fields (evidence: `common/protocol.c`)
- Buffer Analyzer → Packet Printer: prints valid frame (evidence: `host/main.c`)
