# anujs-27/spectregate architecture

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

- Interactive diagram: https://gitdiagram.com/anujs-27/spectregate
- Repository: https://github.com/anujs-27/spectregate

## Overview

SpectreGate authorizes a client by sending an encrypted, fixed-size UDP knock to a daemon that passively captures raw Ethernet traffic; after validating freshness and replay status, the daemon adds the sender and requested port to an nftables set. The client, shared packet/crypto library, and daemon are the main runtime components. The README documents packet sizing, replay protection, and temporary firewall access; the graph’s implementation relationships are limited to the sampled Rust source and those documented flows.

Main entry points: [`spectregate-daemon/src/main.rs`](https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs) (Knock Validation), [`spectregate-client/src/main.rs`](https://github.com/anujs-27/spectregate/blob/main/spectregate-client/src/main.rs) (Client CLI), [`spectregate-core/src/lib.rs`](https://github.com/anujs-27/spectregate/blob/main/spectregate-core/src/lib.rs) (Packet Crypto)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Knock Client"]
  node_client_cli["Client CLI<br/>[main.rs]"]
end

subgraph group_core["Packet Security"]
  node_packet_crypto["Packet Crypto<br/>[lib.rs]"]
end

subgraph group_daemon["Daemon Processing"]
  node_capture["Raw Capture<br/>[main.rs]"]
  node_validation["Knock Validation<br/>[main.rs]"]
  node_nonce_cache[("Nonce Cache<br/>[main.rs]")]
end

subgraph group_firewall["Firewall Gate"]
  node_firewall_update["Firewall Update<br/>[main.rs]"]
end

node_operator(("Operator"))
node_key_file["Shared Key File"]
node_wire["UDP Knock"]
node_network["Network"]
node_nftables[("nftables Set")]

node_operator -->|"runs with parameters"| node_client_cli
node_client_cli -->|"reads key"| node_key_file
node_operator -->|"provides shared key"| node_key_file
node_client_cli -->|"encrypts payload"| node_packet_crypto
node_packet_crypto -->|"produces packet"| node_wire
node_client_cli -->|"sends UDP"| node_wire
node_wire -->|"travels over"| node_network
node_network -->|"delivers knock"| node_capture
node_capture -->|"dispatches payload"| node_validation
node_validation -->|"reads key"| node_key_file
node_validation -->|"decrypts payload"| node_packet_crypto
node_validation -->|"checks and records nonce"| node_nonce_cache
node_validation -->|"triggers on valid knock"| node_firewall_update
node_firewall_update -->|"adds timed element"| node_nftables

click node_client_cli "https://github.com/anujs-27/spectregate/blob/main/spectregate-client/src/main.rs"
click node_packet_crypto "https://github.com/anujs-27/spectregate/blob/main/spectregate-core/src/lib.rs"
click node_capture "https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs"
click node_validation "https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs"
click node_nonce_cache "https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs"
click node_firewall_update "https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs"

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_client_cli toneBlue
class node_packet_crypto,node_nftables toneAmber
class node_capture,node_validation,node_nonce_cache toneMint
class node_firewall_update toneRose
class node_operator,node_key_file,node_wire,node_network toneIndigo
```

## Components

### Knock Client

- [Client CLI](https://github.com/anujs-27/spectregate/blob/main/spectregate-client/src/main.rs): `spectregate-client/src/main.rs`

### Packet Security

- [Packet Crypto](https://github.com/anujs-27/spectregate/blob/main/spectregate-core/src/lib.rs): `spectregate-core/src/lib.rs`

### Daemon Processing

- [Raw Capture](https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs): `spectregate-daemon/src/main.rs`
- [Knock Validation](https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs): `spectregate-daemon/src/main.rs`
- [Nonce Cache](https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs): `spectregate-daemon/src/main.rs`

### Firewall Gate

- [Firewall Update](https://github.com/anujs-27/spectregate/blob/main/spectregate-daemon/src/main.rs): `spectregate-daemon/src/main.rs`

### Other components

- **Operator**
- **Shared Key File**
- **UDP Knock**
- **Network**
- **nftables Set**

## Connections

- Operator → Client CLI: runs with parameters (evidence: `README.md`)
- Client CLI → Shared Key File: reads key (evidence: `spectregate-client/src/main.rs`)
- Operator → Shared Key File: provides shared key (evidence: `README.md`)
- Client CLI → Packet Crypto: encrypts payload (evidence: `spectregate-client/src/main.rs`)
- Packet Crypto → UDP Knock: produces packet (evidence: `spectregate-core/src/lib.rs`)
- Client CLI → UDP Knock: sends UDP (evidence: `spectregate-client/src/main.rs`)
- UDP Knock → Network: travels over (evidence: `README.md`)
- Network → Raw Capture: delivers knock (evidence: `README.md`)
- Raw Capture → Knock Validation: dispatches payload (evidence: `spectregate-daemon/src/main.rs`)
- Knock Validation → Shared Key File: reads key (evidence: `spectregate-daemon/src/main.rs`)
- Knock Validation → Packet Crypto: decrypts payload (evidence: `spectregate-daemon/src/main.rs`)
- Knock Validation → Nonce Cache: checks and records nonce (evidence: `spectregate-daemon/src/main.rs`)
- Knock Validation → Firewall Update: triggers on valid knock (evidence: `spectregate-daemon/src/main.rs`)
- Firewall Update → nftables Set: adds timed element (evidence: `spectregate-daemon/src/main.rs`)
