# justinwkwan/netsentinel architecture

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

- Interactive diagram: https://gitdiagram.com/justinwkwan/netsentinel
- Repository: https://github.com/justinwkwan/netsentinel

## Overview

NetSentinel ingests PCAP or live-captured packets, assembles bidirectional flows, flags anomalous flows, then investigates each flag with a ReAct agent and threat-intelligence retrieval to produce structured reports. CLI and web/API interfaces expose the workflow; the dashboard also supports capture, browsing, and run history. Evaluation and detector metrics are separate product capabilities. Some relationships below rely on README descriptions or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`netsentinel/detection/lstm.py`](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/detection/lstm.py) (LSTM detector), [`web/src/App.tsx`](https://github.com/justinwkwan/netsentinel/blob/main/web/src/App.tsx) (Dashboard shell), [`netsentinel/ingestion/sources.py`](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/ingestion/sources.py) (Packet sources), [`web/src/api.ts`](https://github.com/justinwkwan/netsentinel/blob/main/web/src/api.ts) (Web API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest_detect["Ingestion and detection"]
  node_packet_source["Packet sources<br/>[sources.py]"]
  node_flow_records["Flow assembly<br/>[flows.py]"]
  node_detector_contract["Detector interface<br/>[base.py]"]
  node_lstm["LSTM detector<br/>[lstm.py]"]
  node_training["Model training<br/>[train_lstm.py]"]
end

subgraph group_investigate["Agent and intelligence"]
  node_agent_scheduler["Investigation scheduler<br/>[scheduler.py]"]
  node_agent_graph["ReAct investigation<br/>[graph.py]"]
  node_agent_timing["Investigation timing<br/>[timing.py]"]
  node_agent_report["Threat report parsing<br/>[report.py]"]
  node_agent_tools["Threat lookup tools<br/>[tools.py]"]
  node_rag_store[("Threat intelligence store<br/>[store.py]")]
  node_rag_builder["Threat data indexing<br/>[build_store.py]"]
end

subgraph group_interfaces["CLI and dashboard"]
  node_cli["Command-line runner<br/>[cli.py]"]
  node_dashboard["Dashboard shell<br/>[App.tsx]"]
  node_web_controls["PCAP and run controls<br/>[PcapSelector.tsx]"]
  node_local_browser["Local PCAP browser<br/>[LocalBrowser.tsx]"]
  node_live_panel["Live capture panel"]
  node_run_views["Run status and reports<br/>[RunStatusPanel.tsx]"]
  node_run_history["Run history<br/>[RunHistory.tsx]"]
  node_web_api["Web API client<br/>[api.ts]"]
end

subgraph group_capture_api["API and capture"]
  node_api_main["HTTP API<br/>[main.py]"]
  node_api_jobs["Run jobs and history<br/>[jobs.py]"]
  node_api_models["API data models<br/>[models.py]"]
  node_capture_manager["Live capture manager<br/>[capture.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_harness["Report evaluation<br/>[harness.py]"]
  node_eval_judge["LLM report judge<br/>[judge.py]"]
  node_eval_dataset["Labeled evaluation data<br/>[dataset.py]"]
  node_attack_traffic["Synthetic attack traffic<br/>[attack_traffic.py]"]
  node_detector_metrics["Detector metrics"]
end

node_user(("Security analyst"))
node_pcap["PCAP or live traffic"]
node_llm["LLM provider<br/>[llm.py]"]
node_config["Runtime configuration<br/>[config.py]"]

node_user -->|"runs analysis"| node_cli
node_user -->|"uses dashboard"| node_dashboard
node_pcap -->|"provides packets"| node_packet_source
node_packet_source -->|"assembles flows"| node_flow_records
node_flow_records -->|"scores flows"| node_lstm
node_lstm -->|"implements"| node_detector_contract
node_training -->|"reads captures"| node_packet_source
node_training -->|"trains on flows"| node_flow_records
node_training -->|"saves model"| node_lstm
node_cli -->|"reads input"| node_packet_source
node_cli -->|"detects anomalies"| node_lstm
node_cli -->|"investigates flags"| node_agent_scheduler
node_agent_scheduler -->|"dispatches investigations"| node_agent_graph
node_agent_graph -->|"invokes tools"| node_agent_tools
node_agent_graph -->|"queries model"| node_llm
node_agent_tools -->|"retrieves intelligence"| node_rag_store
node_rag_builder -->|"builds index"| node_rag_store
node_agent_scheduler -->|"records timings"| node_agent_timing
node_agent_graph -->|"parses reports"| node_agent_report
node_api_main -->|"submits and polls"| node_api_jobs
node_api_main -->|"controls capture"| node_capture_manager
node_api_main -->|"uses response models"| node_api_models
node_api_jobs -->|"reads captures"| node_packet_source
node_api_jobs -->|"assembles flows"| node_flow_records
node_api_jobs -->|"detects anomalies"| node_lstm
node_api_jobs -->|"investigates flags"| node_agent_scheduler
node_dashboard -->|"renders controls"| node_web_controls
node_dashboard -->|"renders browser"| node_local_browser
node_dashboard -->|"renders capture"| node_live_panel
node_dashboard -->|"renders status"| node_run_views
node_dashboard -->|"renders history"| node_run_history
node_web_controls -->|"requests runs"| node_web_api
node_local_browser -->|"browses folders"| node_web_api
node_live_panel -->|"controls capture"| node_web_api
node_run_views -->|"polls run details"| node_web_api
node_run_history -->|"loads history"| node_web_api
node_web_api -->|"calls endpoints"| node_api_main
node_eval_harness -->|"loads cases"| node_eval_dataset
node_eval_harness -->|"scores reports"| node_eval_judge
node_detector_metrics -->|"measures attacks"| node_attack_traffic
node_detector_metrics -->|"scores detector"| node_lstm
node_detector_metrics -->|"ingests test captures"| node_packet_source
node_config -->|"configures detector"| node_lstm
node_config -->|"sets iteration cap"| node_agent_graph

click node_packet_source "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/ingestion/sources.py"
click node_flow_records "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/ingestion/flows.py"
click node_detector_contract "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/detection/base.py"
click node_lstm "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/detection/lstm.py"
click node_training "https://github.com/justinwkwan/netsentinel/blob/main/scripts/train_lstm.py"
click node_agent_scheduler "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/scheduler.py"
click node_agent_graph "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/graph.py"
click node_agent_timing "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/timing.py"
click node_agent_report "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/report.py"
click node_agent_tools "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/tools.py"
click node_rag_store "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/rag/store.py"
click node_rag_builder "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/rag/build_store.py"
click node_llm "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/llm.py"
click node_cli "https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/cli.py"
click node_api_main "https://github.com/justinwkwan/netsentinel/blob/main/api/main.py"
click node_api_jobs "https://github.com/justinwkwan/netsentinel/blob/main/api/jobs.py"
click node_api_models "https://github.com/justinwkwan/netsentinel/blob/main/api/models.py"
click node_capture_manager "https://github.com/justinwkwan/netsentinel/blob/main/api/capture.py"
click node_dashboard "https://github.com/justinwkwan/netsentinel/blob/main/web/src/App.tsx"
click node_web_controls "https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/PcapSelector.tsx"
click node_local_browser "https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/LocalBrowser.tsx"
click node_live_panel "https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/LiveCapturePanel.tsx"
click node_run_views "https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/RunStatusPanel.tsx"
click node_run_history "https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/RunHistory.tsx"
click node_web_api "https://github.com/justinwkwan/netsentinel/blob/main/web/src/api.ts"
click node_eval_harness "https://github.com/justinwkwan/netsentinel/blob/main/eval/harness.py"
click node_eval_judge "https://github.com/justinwkwan/netsentinel/blob/main/eval/judge.py"
click node_eval_dataset "https://github.com/justinwkwan/netsentinel/blob/main/eval/dataset.py"
click node_attack_traffic "https://github.com/justinwkwan/netsentinel/blob/main/eval/attack_traffic.py"
click node_detector_metrics "https://github.com/justinwkwan/netsentinel/blob/main/eval/detector_metrics.py"
click node_config "https://github.com/justinwkwan/netsentinel/blob/main/config.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_packet_source,node_flow_records,node_detector_contract,node_lstm,node_training toneBlue
class node_agent_scheduler,node_agent_graph,node_agent_timing,node_agent_report,node_agent_tools,node_rag_store,node_rag_builder toneAmber
class node_cli,node_dashboard,node_web_controls,node_local_browser,node_live_panel,node_run_views,node_run_history,node_web_api toneMint
class node_api_main,node_api_jobs,node_api_models,node_capture_manager toneRose
class node_eval_harness,node_eval_judge,node_eval_dataset,node_attack_traffic,node_detector_metrics,node_user,node_pcap,node_llm toneIndigo
class node_config toneTeal
```

## Components

### Ingestion and detection

- [Packet sources](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/ingestion/sources.py): `netsentinel/ingestion/sources.py`
- [Flow assembly](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/ingestion/flows.py): `netsentinel/ingestion/flows.py`
- [Detector interface](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/detection/base.py): `netsentinel/detection/base.py`
- [LSTM detector](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/detection/lstm.py): `netsentinel/detection/lstm.py`
- [Model training](https://github.com/justinwkwan/netsentinel/blob/main/scripts/train_lstm.py): `scripts/train_lstm.py`

### Agent and intelligence

- [Investigation scheduler](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/scheduler.py): `netsentinel/agent/scheduler.py`
- [ReAct investigation](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/graph.py): `netsentinel/agent/graph.py`
- [Investigation timing](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/timing.py): `netsentinel/agent/timing.py`
- [Threat report parsing](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/report.py): `netsentinel/agent/report.py`
- [Threat lookup tools](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/agent/tools.py): `netsentinel/agent/tools.py`
- [Threat intelligence store](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/rag/store.py): `netsentinel/rag/store.py`
- [Threat data indexing](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/rag/build_store.py): `netsentinel/rag/build_store.py`

### CLI and dashboard

- [Command-line runner](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/cli.py): `netsentinel/cli.py`
- [Dashboard shell](https://github.com/justinwkwan/netsentinel/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [PCAP and run controls](https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/PcapSelector.tsx): `web/src/components/PcapSelector.tsx`
- [Local PCAP browser](https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/LocalBrowser.tsx): `web/src/components/LocalBrowser.tsx`
- [Live capture panel](https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/LiveCapturePanel.tsx): `web/src/components/LiveCapturePanel.tsx`
- [Run status and reports](https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/RunStatusPanel.tsx): `web/src/components/RunStatusPanel.tsx`
- [Run history](https://github.com/justinwkwan/netsentinel/blob/main/web/src/components/RunHistory.tsx): `web/src/components/RunHistory.tsx`
- [Web API client](https://github.com/justinwkwan/netsentinel/blob/main/web/src/api.ts): `web/src/api.ts`

### API and capture

- [HTTP API](https://github.com/justinwkwan/netsentinel/blob/main/api/main.py): `api/main.py`
- [Run jobs and history](https://github.com/justinwkwan/netsentinel/blob/main/api/jobs.py): `api/jobs.py`
- [API data models](https://github.com/justinwkwan/netsentinel/blob/main/api/models.py): `api/models.py`
- [Live capture manager](https://github.com/justinwkwan/netsentinel/blob/main/api/capture.py): `api/capture.py`

### Evaluation

- [Report evaluation](https://github.com/justinwkwan/netsentinel/blob/main/eval/harness.py): `eval/harness.py`
- [LLM report judge](https://github.com/justinwkwan/netsentinel/blob/main/eval/judge.py): `eval/judge.py`
- [Labeled evaluation data](https://github.com/justinwkwan/netsentinel/blob/main/eval/dataset.py): `eval/dataset.py`
- [Synthetic attack traffic](https://github.com/justinwkwan/netsentinel/blob/main/eval/attack_traffic.py): `eval/attack_traffic.py`
- [Detector metrics](https://github.com/justinwkwan/netsentinel/blob/main/eval/detector_metrics.py): `eval/detector_metrics.py`

### Other components

- **Security analyst**
- **PCAP or live traffic**
- [LLM provider](https://github.com/justinwkwan/netsentinel/blob/main/netsentinel/llm.py): `netsentinel/llm.py`
- [Runtime configuration](https://github.com/justinwkwan/netsentinel/blob/main/config.py): `config.py`

## Connections

- Security analyst → Command-line runner: runs analysis
- Security analyst → Dashboard shell: uses dashboard
- PCAP or live traffic → Packet sources: provides packets
- Packet sources → Flow assembly: assembles flows (evidence: `netsentinel/ingestion/sources.py`)
- Flow assembly → LSTM detector: scores flows (evidence: `netsentinel/detection/lstm.py`)
- LSTM detector → Detector interface: implements (evidence: `netsentinel/detection/lstm.py`)
- Model training → Packet sources: reads captures (evidence: `scripts/train_lstm.py`)
- Model training → Flow assembly: trains on flows (evidence: `scripts/train_lstm.py`)
- Model training → LSTM detector: saves model (evidence: `scripts/train_lstm.py`)
- Command-line runner → Packet sources: reads input (evidence: `netsentinel/cli.py`)
- Command-line runner → LSTM detector: detects anomalies (evidence: `netsentinel/cli.py`)
- Command-line runner → Investigation scheduler: investigates flags (evidence: `netsentinel/cli.py`)
- Investigation scheduler → ReAct investigation: dispatches investigations (evidence: `netsentinel/agent/scheduler.py`)
- ReAct investigation → Threat lookup tools: invokes tools (evidence: `netsentinel/agent/graph.py`)
- ReAct investigation → LLM provider: queries model (evidence: `netsentinel/agent/graph.py`)
- Threat lookup tools → Threat intelligence store: retrieves intelligence (evidence: `netsentinel/agent/tools.py`)
- Threat data indexing → Threat intelligence store: builds index (evidence: `netsentinel/rag/build_store.py`)
- Investigation scheduler → Investigation timing: records timings (evidence: `netsentinel/agent/scheduler.py`)
- ReAct investigation → Threat report parsing: parses reports (evidence: `netsentinel/agent/graph.py`)
- HTTP API → Run jobs and history: submits and polls (evidence: `api/main.py`)
- HTTP API → Live capture manager: controls capture (evidence: `api/main.py`)
- HTTP API → API data models: uses response models (evidence: `api/main.py`)
- Run jobs and history → Packet sources: reads captures (evidence: `api/jobs.py`)
- Run jobs and history → Flow assembly: assembles flows (evidence: `api/jobs.py`)
- Run jobs and history → LSTM detector: detects anomalies (evidence: `api/jobs.py`)
- Run jobs and history → Investigation scheduler: investigates flags (evidence: `api/jobs.py`)
- Dashboard shell → PCAP and run controls: renders controls (evidence: `web/src/App.tsx`)
- Dashboard shell → Local PCAP browser: renders browser (evidence: `web/src/App.tsx`)
- Dashboard shell → Live capture panel: renders capture (evidence: `web/src/App.tsx`)
- Dashboard shell → Run status and reports: renders status (evidence: `web/src/App.tsx`)
- Dashboard shell → Run history: renders history (evidence: `web/src/App.tsx`)
- PCAP and run controls → Web API client: requests runs (evidence: `web/src/components/PcapSelector.tsx`)
- Local PCAP browser → Web API client: browses folders (evidence: `web/src/components/LocalBrowser.tsx`)
- Live capture panel → Web API client: controls capture (evidence: `web/src/components/LiveCapturePanel.tsx`)
- Run status and reports → Web API client: polls run details (evidence: `web/src/components/RunStatusPanel.tsx`)
- Run history → Web API client: loads history (evidence: `web/src/components/RunHistory.tsx`)
- Web API client → HTTP API: calls endpoints
- Report evaluation → Labeled evaluation data: loads cases
- Report evaluation → LLM report judge: scores reports
- Detector metrics → Synthetic attack traffic: measures attacks (evidence: `eval/detector_metrics.py`)
- Detector metrics → LSTM detector: scores detector (evidence: `eval/detector_metrics.py`)
- Detector metrics → Packet sources: ingests test captures (evidence: `eval/detector_metrics.py`)
- Runtime configuration → LSTM detector: configures detector (evidence: `netsentinel/detection/lstm.py`)
- Runtime configuration → ReAct investigation: sets iteration cap (evidence: `netsentinel/agent/graph.py`)
