# sudiptomaity2005/deep-packet-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/sudiptomaity2005/deep-packet-analyzer
- Repository: https://github.com/sudiptomaity2005/deep-packet-analyzer

## Overview

DPI Engine is a PCAP-based deep packet inspection and threat-defense application. Its principal path reads captures, parses packets, dispatches flows across load-balancer and fast-path workers, extracts application metadata, applies policy and anomaly checks, tracks connections, and writes permitted traffic to PCAP output. Distinct capabilities include multi-capture chronological merge/QoS, sharded output, security intelligence, and a live TUI. Calls are connected only where README or supplied excerpts/source-index references support them; some internal runtime wiring is unsampled.

Main entry points: [`src/core/dpi_engine.cpp`](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/dpi_engine.cpp) (DPI Engine), [`src/core/fast_path.cpp`](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/fast_path.cpp) (Fast-Path Workers), [`src/ui/tui_dashboard.cpp`](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/ui/tui_dashboard.cpp) (Live TUI Dashboard), [`src/security/rule_manager.cpp`](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/rule_manager.cpp) (Policy Rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Capture and Parsing"]
  node_pcap["PCAP Capture<br/>[pcap_reader.cpp]"]
  node_parser["Packet Parser<br/>[packet_parser.cpp]"]
  node_sni["Protocol Extraction<br/>[sni_extractor.cpp]"]
end

subgraph group_engine["DPI Processing"]
  node_app["DPI Entrypoints<br/>[main_dpi.cpp]"]
  node_enginecore["DPI Engine<br/>[dpi_engine.cpp]"]
  node_lb["Flow Load Balancing<br/>[load_balancer.cpp]"]
  node_fastpath["Fast-Path Workers<br/>[fast_path.cpp]"]
  node_flows[("Connection Tracking")]
end

subgraph group_security["Security Intelligence"]
  node_rules["Policy Rules<br/>[rule_manager.cpp]"]
  node_signatures["NIDS Signatures<br/>[aho_corasick.cpp]"]
  node_threats["Threat Analysis"]
end

subgraph group_traffic["Traffic and Output"]
  node_orchestrator["Capture Orchestrator"]
  node_shaper["QoS Shaping<br/>[traffic_shaper.cpp]"]
  node_writer[("Sharded PCAP Output")]
  node_result["Filtered PCAP"]
end

subgraph group_observability["Operations"]
  node_tui["Live TUI Dashboard<br/>[tui_dashboard.cpp]"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_app
node_app -->|"starts"| node_enginecore
node_enginecore -->|"reads captures"| node_pcap
node_pcap -->|"supplies packets"| node_parser
node_enginecore -->|"parses packets"| node_parser
node_enginecore -->|"dispatches flows"| node_lb
node_lb -->|"routes packets"| node_fastpath
node_fastpath -->|"extracts metadata"| node_sni
node_fastpath -->|"checks policy"| node_rules
node_rules -->|"matches payloads"| node_signatures
node_rules -->|"checks anomalies"| node_threats
node_fastpath -->|"tracks connections"| node_flows
node_enginecore -->|"merges captures"| node_orchestrator
node_orchestrator -->|"applies QoS"| node_shaper
node_orchestrator -->|"dispatches workload"| node_lb
node_fastpath -.->|"forwards packets"| node_writer
node_writer -->|"writes PCAP"| node_result
node_enginecore -->|"renders status"| node_tui
node_tui -->|"reads flow stats"| node_flows
node_tui -->|"reads telemetry"| node_orchestrator
node_tui -->|"reads policy stats"| node_rules

click node_pcap "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/pcap_reader.cpp"
click node_parser "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/packet_parser.cpp"
click node_sni "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/sni_extractor.cpp"
click node_app "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/app/main_dpi.cpp"
click node_enginecore "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/dpi_engine.cpp"
click node_lb "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/load_balancer.cpp"
click node_fastpath "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/fast_path.cpp"
click node_flows "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/connection_tracker.cpp"
click node_rules "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/rule_manager.cpp"
click node_signatures "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/aho_corasick.cpp"
click node_threats "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/security_analyzer.cpp"
click node_orchestrator "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/traffic_orchestrator.cpp"
click node_shaper "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/traffic_shaper.cpp"
click node_writer "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/multiqueue_pcap_writer.cpp"
click node_tui "https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/ui/tui_dashboard.cpp"

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_pcap,node_parser,node_sni toneBlue
class node_app,node_enginecore,node_lb,node_fastpath,node_flows toneAmber
class node_rules,node_signatures,node_threats toneMint
class node_orchestrator,node_shaper,node_writer,node_result toneRose
class node_tui,node_operator toneIndigo
```

## Components

### Capture and Parsing

- [PCAP Capture](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/pcap_reader.cpp): `src/protocol/pcap_reader.cpp`
- [Packet Parser](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/packet_parser.cpp): `src/protocol/packet_parser.cpp`
- [Protocol Extraction](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/protocol/sni_extractor.cpp): `src/protocol/sni_extractor.cpp`

### DPI Processing

- [DPI Entrypoints](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/app/main_dpi.cpp): `src/app/main_dpi.cpp`
- [DPI Engine](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/dpi_engine.cpp): `src/core/dpi_engine.cpp`
- [Flow Load Balancing](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/load_balancer.cpp): `src/core/load_balancer.cpp`
- [Fast-Path Workers](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/fast_path.cpp): `src/core/fast_path.cpp`
- [Connection Tracking](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/core/connection_tracker.cpp): `src/core/connection_tracker.cpp`

### Security Intelligence

- [Policy Rules](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/rule_manager.cpp): `src/security/rule_manager.cpp`
- [NIDS Signatures](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/aho_corasick.cpp): `src/security/aho_corasick.cpp`
- [Threat Analysis](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/security/security_analyzer.cpp): `src/security/security_analyzer.cpp`

### Traffic and Output

- [Capture Orchestrator](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/traffic_orchestrator.cpp): `src/traffic/traffic_orchestrator.cpp`
- [QoS Shaping](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/traffic_shaper.cpp): `src/traffic/traffic_shaper.cpp`
- [Sharded PCAP Output](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/traffic/multiqueue_pcap_writer.cpp): `src/traffic/multiqueue_pcap_writer.cpp`
- **Filtered PCAP**

### Operations

- [Live TUI Dashboard](https://github.com/sudiptomaity2005/deep-packet-analyzer/blob/main/src/ui/tui_dashboard.cpp): `src/ui/tui_dashboard.cpp`

### Other components

- **Operator**

## Connections

- Operator → DPI Entrypoints: runs (evidence: `README.md`)
- DPI Entrypoints → DPI Engine: starts (evidence: `src/app/main_dpi.cpp`)
- DPI Engine → PCAP Capture: reads captures
- PCAP Capture → Packet Parser: supplies packets
- DPI Engine → Packet Parser: parses packets
- DPI Engine → Flow Load Balancing: dispatches flows
- Flow Load Balancing → Fast-Path Workers: routes packets
- Fast-Path Workers → Protocol Extraction: extracts metadata
- Fast-Path Workers → Policy Rules: checks policy
- Policy Rules → NIDS Signatures: matches payloads
- Policy Rules → Threat Analysis: checks anomalies
- Fast-Path Workers → Connection Tracking: tracks connections
- DPI Engine → Capture Orchestrator: merges captures
- Capture Orchestrator → QoS Shaping: applies QoS
- Capture Orchestrator → Flow Load Balancing: dispatches workload
- Fast-Path Workers → Sharded PCAP Output: forwards packets
- Sharded PCAP Output → Filtered PCAP: writes PCAP (evidence: `README.md`)
- DPI Engine → Live TUI Dashboard: renders status (evidence: `src/core/dpi_engine.cpp`)
- Live TUI Dashboard → Connection Tracking: reads flow stats
- Live TUI Dashboard → Capture Orchestrator: reads telemetry
- Live TUI Dashboard → Policy Rules: reads policy stats
