# johnscotttt/witrn_pd_sniffer architecture

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

- Interactive diagram: https://gitdiagram.com/johnscotttt/witrn_pd_sniffer
- Repository: https://github.com/johnscotttt/witrn_pd_sniffer

## Overview

WITRN K2 PD Sniffer is a desktop host application for capturing and inspecting USB Power Delivery traffic with a WITRN K2, and for working with compatible exported data. Its main workflow is device capture, protocol decoding into timestamped records, GUI inspection and plotting, then optional file export; compatible exports can also be imported. The sampled source is partial and concentrated in one GUI module, so the graph separates responsibilities conceptually while retaining that exact path. Import and device-library wiring beyond the shown excerpts is represented cautiously.

Main entry points: [`witrn_pd_sniffer.py`](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py) (Host application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Device capture"]
  node_host["Host application"]
  node_hid["HID access"]
end

subgraph group_inspect["Decode and inspect"]
  node_decoder["PD decoder"]
  node_records["Capture records"]
  node_detail["Record details"]
  node_plot["Signal plots"]
  node_matplotlib["Matplotlib"]
end

subgraph group_exchange["File exchange"]
  node_importer["Export importer"]
  node_exporter["CSV exporter"]
end

node_operator(("Operator"))
node_k2["WITRN K2"]
node_sourcefile["Compatible export"]
node_csvfile["CSV output"]

node_operator -->|"starts and operates"| node_host
node_host -->|"opens and polls"| node_hid
node_hid -->|"reads PD traffic"| node_k2
node_hid -->|"supplies capture data"| node_decoder
node_decoder -->|"creates records"| node_records
node_host -->|"displays selected record"| node_detail
node_host -->|"updates curves"| node_plot
node_plot -->|"renders with"| node_matplotlib
node_operator -->|"selects input"| node_importer
node_sourcefile -->|"provides exported data"| node_importer
node_importer -->|"loads parsed records"| node_records
node_operator -->|"requests export"| node_exporter
node_exporter -->|"reads capture data"| node_records
node_exporter -->|"writes CSV"| node_csvfile

click node_host "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_hid "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_decoder "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_records "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_detail "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_plot "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_importer "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"
click node_exporter "https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py"

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_host,node_hid toneBlue
class node_decoder,node_records,node_detail,node_plot,node_matplotlib toneAmber
class node_importer,node_exporter toneMint
class node_operator,node_k2,node_sourcefile,node_csvfile toneIndigo
```

## Components

### Device capture

- [Host application](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- [HID access](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`

### Decode and inspect

- [PD decoder](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- [Capture records](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- [Record details](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- [Signal plots](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- **Matplotlib**

### File exchange

- [Export importer](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`
- [CSV exporter](https://github.com/johnscotttt/witrn_pd_sniffer/blob/main/witrn_pd_sniffer.py): `witrn_pd_sniffer.py`

### Other components

- **Operator**
- **WITRN K2**
- **Compatible export**
- **CSV output**

## Connections

- Operator → Host application: starts and operates
- Host application → HID access: opens and polls
- HID access → WITRN K2: reads PD traffic
- HID access → PD decoder: supplies capture data
- PD decoder → Capture records: creates records
- Host application → Record details: displays selected record
- Host application → Signal plots: updates curves
- Signal plots → Matplotlib: renders with
- Operator → Export importer: selects input
- Compatible export → Export importer: provides exported data
- Export importer → Capture records: loads parsed records
- Operator → CSV exporter: requests export
- CSV exporter → Capture records: reads capture data
- CSV exporter → CSV output: writes CSV
