# mk555/packet-sniffer architecture

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

- Interactive diagram: https://gitdiagram.com/mk555/packet-sniffer
- Repository: https://github.com/mk555/packet-sniffer

## Overview

Packet-Sniffer is a small root-run TCP packet capture script. The user starts it with an optional verbosity flag; it initializes SQLite, starts Scapy sniffing, and processes each captured packet in a callback that records destination IPs and packet content. The source shows database reads and writes but no schema creation, so the graph does not imply that the script creates its tables. The README and single sampled source file support the relationships shown.

Main entry points: [`main.py`](https://github.com/mk555/packet-sniffer/blob/master/main.py) (Packet callback)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Operator"))
node_entry["CLI and startup<br/>[main.py]"]
node_scapy["Scapy sniffer"]
node_callback["Packet callback<br/>[main.py]"]
node_ip_check["IP presence check<br/>[main.py]"]
node_ip_write["IP recorder<br/>[main.py]"]
node_content_write["Packet recorder<br/>[main.py]"]
node_database[("SQLite database")]

node_user -->|"starts"| node_entry
node_entry -->|"initializes"| node_database
node_entry -->|"starts sniffing"| node_scapy
node_scapy -->|"dispatches packets"| node_callback
node_callback -->|"checks destination"| node_ip_check
node_callback -->|"records new IP"| node_ip_write
node_callback -->|"records content"| node_content_write
node_ip_check -->|"reads"| node_database
node_ip_write -->|"writes"| node_database
node_content_write -->|"writes"| node_database

click node_entry "https://github.com/mk555/packet-sniffer/blob/master/main.py"
click node_callback "https://github.com/mk555/packet-sniffer/blob/master/main.py"
click node_ip_check "https://github.com/mk555/packet-sniffer/blob/master/main.py"
click node_ip_write "https://github.com/mk555/packet-sniffer/blob/master/main.py"
click node_content_write "https://github.com/mk555/packet-sniffer/blob/master/main.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_user,node_scapy toneIndigo
class node_entry,node_callback,node_ip_check,node_ip_write,node_content_write toneTeal
class node_database toneAmber
```

## Components

### Other components

- **Operator**
- [CLI and startup](https://github.com/mk555/packet-sniffer/blob/master/main.py): `main.py`
- **Scapy sniffer**
- [Packet callback](https://github.com/mk555/packet-sniffer/blob/master/main.py): `main.py`
- [IP presence check](https://github.com/mk555/packet-sniffer/blob/master/main.py): `main.py`
- [IP recorder](https://github.com/mk555/packet-sniffer/blob/master/main.py): `main.py`
- [Packet recorder](https://github.com/mk555/packet-sniffer/blob/master/main.py): `main.py`
- **SQLite database**

## Connections

- Operator → CLI and startup: starts (evidence: `README.md`)
- CLI and startup → SQLite database: initializes (evidence: `main.py`)
- CLI and startup → Scapy sniffer: starts sniffing (evidence: `main.py`)
- Scapy sniffer → Packet callback: dispatches packets (evidence: `main.py`)
- Packet callback → IP presence check: checks destination (evidence: `main.py`)
- Packet callback → IP recorder: records new IP (evidence: `main.py`)
- Packet callback → Packet recorder: records content (evidence: `main.py`)
- IP presence check → SQLite database: reads (evidence: `main.py`)
- IP recorder → SQLite database: writes (evidence: `main.py`)
- Packet recorder → SQLite database: writes (evidence: `main.py`)
