# flagmansec/flagmanids architecture

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

- Interactive diagram: https://gitdiagram.com/flagmansec/flagmanids
- Repository: https://github.com/flagmansec/flagmanids

## Overview

Flagman is a local, rule-based network IDS. Live packets or a capture replay enter the sensor pipeline, become flows and detector alerts, are grouped into incidents, and are stored for the dashboard. The dashboard supports overview, incident and flow views, health and configuration. The README documents Suricata signature support and replay; source excerpts show pipeline ownership but do not expose all runtime wiring, so uncertain subsystem links are omitted or marked unverified. The separate research code is represented as a benchmark branch, not part of the sensor runtime.

Main entry points: [`product/core/crates/flagman-core/src/engine.rs`](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/engine.rs) (Analysis engine), [`product/core/crates/flagmand/src/pipeline.rs`](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/pipeline.rs) (Capture pipeline), [`src/data.py`](https://github.com/flagmansec/flagmanids/blob/main/src/data.py) (Dataset loading), [`product/ui/src/App.svelte`](https://github.com/flagmansec/flagmanids/blob/main/product/ui/src/App.svelte) (Dashboard application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensor["Sensor runtime"]
  node_capture["Live and file capture"]
  node_suricata["Suricata reader"]
  node_daemon["flagmand service<br/>[main.rs]"]
  node_pipeline["Capture pipeline<br/>[pipeline.rs]"]
  node_replay["Capture replay<br/>[replay.rs]"]
end

subgraph group_analysis["Detection and incidents"]
  node_packet["Packet decoding<br/>[decode.rs]"]
  node_flow["Flow tracking<br/>[table.rs]"]
  node_engine["Analysis engine<br/>[engine.rs]"]
  node_detectors["Rule detectors"]
  node_alerts["Alert records<br/>[alert.rs]"]
  node_incidents["Incident grouping<br/>[engine.rs]"]
end

subgraph group_persistence["Storage and API"]
  node_writer["Batch writer<br/>[writer.rs]"]
  node_database[("Local database<br/>[schema.rs]")]
  node_queries["Dashboard queries<br/>[query_dashboard.rs]"]
  node_api["HTTP API"]
end

subgraph group_dashboard["Dashboard"]
  node_webapp["Dashboard application<br/>[App.svelte]"]
  node_pages["Dashboard views"]
  node_flowsview["Flow browser<br/>[Flows.svelte]"]
end

subgraph group_research["Research benchmark"]
  node_researchdata["Dataset loading<br/>[data.py]"]
  node_researchprep["Feature preprocessing<br/>[preprocessing.py]"]
  node_researchmodels["IDS models<br/>[models.py]"]
  node_researcheval["Model evaluation<br/>[evaluation.py]"]
  node_researchplots["Results analysis<br/>[plotting.py]"]
end

node_operator(("Local operator"))
node_network(("Observed network"))

node_operator -->|"opens dashboard"| node_webapp
node_network -->|"supplies packets"| node_capture
node_daemon -->|"starts"| node_pipeline
node_pipeline -->|"reads frames"| node_capture
node_pipeline -->|"processes frames"| node_engine
node_pipeline -->|"sends batches"| node_writer
node_pipeline -.->|"receives rule hits"| node_suricata
node_replay -->|"reuses loop"| node_pipeline
node_engine -->|"decodes frames"| node_packet
node_engine -->|"tracks flows"| node_flow
node_engine -->|"dispatches events"| node_detectors
node_detectors -->|"produces alerts"| node_alerts
node_engine -->|"groups alerts"| node_incidents
node_engine -->|"publishes findings"| node_alerts
node_writer -.->|"writes batches"| node_database
node_api -.->|"loads dashboard data"| node_queries
node_queries -.->|"reads aggregates"| node_database
node_webapp -.->|"requests data"| node_api
node_webapp -->|"renders views"| node_pages
node_pages -.->|"includes flow view"| node_flowsview
node_researchdata -.->|"provides features"| node_researchprep
node_researchdata -->|"loads benchmark data"| node_researcheval
node_researchdata -->|"provides dataset context"| node_researchplots

click node_capture "https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-capture/src"
click node_suricata "https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-suricata/src"
click node_daemon "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/main.rs"
click node_pipeline "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/pipeline.rs"
click node_replay "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/replay.rs"
click node_packet "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/packet/decode.rs"
click node_flow "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/flow/table.rs"
click node_engine "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/engine.rs"
click node_detectors "https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-core/src/detect"
click node_alerts "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/alert.rs"
click node_incidents "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/incident/engine.rs"
click node_writer "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/writer.rs"
click node_database "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-store/src/schema.rs"
click node_queries "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-store/src/query_dashboard.rs"
click node_api "https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-api/src/routes_dashboard.rs"
click node_webapp "https://github.com/flagmansec/flagmanids/blob/main/product/ui/src/App.svelte"
click node_pages "https://github.com/flagmansec/flagmanids/tree/main/product/ui/src/pages"
click node_flowsview "https://github.com/flagmansec/flagmanids/blob/main/product/ui/src/pages/Flows.svelte"
click node_researchdata "https://github.com/flagmansec/flagmanids/blob/main/src/data.py"
click node_researchprep "https://github.com/flagmansec/flagmanids/blob/main/src/preprocessing.py"
click node_researchmodels "https://github.com/flagmansec/flagmanids/blob/main/src/models.py"
click node_researcheval "https://github.com/flagmansec/flagmanids/blob/main/src/evaluation.py"
click node_researchplots "https://github.com/flagmansec/flagmanids/blob/main/src/plotting.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_capture,node_suricata,node_daemon,node_pipeline,node_replay toneBlue
class node_packet,node_flow,node_engine,node_detectors,node_alerts,node_incidents toneAmber
class node_writer,node_database,node_queries,node_api toneMint
class node_webapp,node_pages,node_flowsview toneRose
class node_researchdata,node_researchprep,node_researchmodels,node_researcheval,node_researchplots,node_operator,node_network toneIndigo
```

## Components

### Sensor runtime

- [Live and file capture](https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-capture/src): `product/core/crates/flagman-capture/src`
- [Suricata reader](https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-suricata/src): `product/core/crates/flagman-suricata/src`
- [flagmand service](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/main.rs): `product/core/crates/flagmand/src/main.rs`
- [Capture pipeline](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/pipeline.rs): `product/core/crates/flagmand/src/pipeline.rs`
- [Capture replay](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/replay.rs): `product/core/crates/flagmand/src/replay.rs`

### Detection and incidents

- [Packet decoding](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/packet/decode.rs): `product/core/crates/flagman-core/src/packet/decode.rs`
- [Flow tracking](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/flow/table.rs): `product/core/crates/flagman-core/src/flow/table.rs`
- [Analysis engine](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/engine.rs): `product/core/crates/flagman-core/src/engine.rs`
- [Rule detectors](https://github.com/flagmansec/flagmanids/tree/main/product/core/crates/flagman-core/src/detect): `product/core/crates/flagman-core/src/detect`
- [Alert records](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/alert.rs): `product/core/crates/flagman-core/src/alert.rs`
- [Incident grouping](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-core/src/incident/engine.rs): `product/core/crates/flagman-core/src/incident/engine.rs`

### Storage and API

- [Batch writer](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagmand/src/writer.rs): `product/core/crates/flagmand/src/writer.rs`
- [Local database](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-store/src/schema.rs): `product/core/crates/flagman-store/src/schema.rs`
- [Dashboard queries](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-store/src/query_dashboard.rs): `product/core/crates/flagman-store/src/query_dashboard.rs`
- [HTTP API](https://github.com/flagmansec/flagmanids/blob/main/product/core/crates/flagman-api/src/routes_dashboard.rs): `product/core/crates/flagman-api/src/routes_dashboard.rs`

### Dashboard

- [Dashboard application](https://github.com/flagmansec/flagmanids/blob/main/product/ui/src/App.svelte): `product/ui/src/App.svelte`
- [Dashboard views](https://github.com/flagmansec/flagmanids/tree/main/product/ui/src/pages): `product/ui/src/pages`
- [Flow browser](https://github.com/flagmansec/flagmanids/blob/main/product/ui/src/pages/Flows.svelte): `product/ui/src/pages/Flows.svelte`

### Research benchmark

- [Dataset loading](https://github.com/flagmansec/flagmanids/blob/main/src/data.py): `src/data.py`
- [Feature preprocessing](https://github.com/flagmansec/flagmanids/blob/main/src/preprocessing.py): `src/preprocessing.py`
- [IDS models](https://github.com/flagmansec/flagmanids/blob/main/src/models.py): `src/models.py`
- [Model evaluation](https://github.com/flagmansec/flagmanids/blob/main/src/evaluation.py): `src/evaluation.py`
- [Results analysis](https://github.com/flagmansec/flagmanids/blob/main/src/plotting.py): `src/plotting.py`

### Other components

- **Local operator**
- **Observed network**

## Connections

- Local operator → Dashboard application: opens dashboard (evidence: `README.md`)
- Observed network → Live and file capture: supplies packets (evidence: `README.md`)
- flagmand service → Capture pipeline: starts (evidence: `product/core/crates/flagmand/src/main.rs`)
- Capture pipeline → Live and file capture: reads frames (evidence: `product/core/crates/flagmand/src/pipeline.rs`)
- Capture pipeline → Analysis engine: processes frames (evidence: `product/core/crates/flagmand/src/pipeline.rs`)
- Capture pipeline → Batch writer: sends batches (evidence: `product/core/crates/flagmand/src/pipeline.rs`)
- Capture pipeline → Suricata reader: receives rule hits
- Capture replay → Capture pipeline: reuses loop (evidence: `product/core/crates/flagmand/src/pipeline.rs`)
- Analysis engine → Packet decoding: decodes frames (evidence: `product/core/crates/flagman-core/src/engine.rs`)
- Analysis engine → Flow tracking: tracks flows (evidence: `product/core/crates/flagman-core/src/engine.rs`)
- Analysis engine → Rule detectors: dispatches events (evidence: `product/core/crates/flagman-core/src/engine.rs`)
- Rule detectors → Alert records: produces alerts (evidence: `product/core/crates/flagman-core/src/detect/mod.rs`)
- Analysis engine → Incident grouping: groups alerts (evidence: `product/core/crates/flagman-core/src/engine.rs`)
- Analysis engine → Alert records: publishes findings (evidence: `product/core/crates/flagman-core/src/engine.rs`)
- Batch writer → Local database: writes batches
- HTTP API → Dashboard queries: loads dashboard data
- Dashboard queries → Local database: reads aggregates
- Dashboard application → HTTP API: requests data
- Dashboard application → Dashboard views: renders views (evidence: `product/ui/src/App.svelte`)
- Dashboard views → Flow browser: includes flow view
- Dataset loading → Feature preprocessing: provides features
- Dataset loading → Model evaluation: loads benchmark data (evidence: `src/evaluation.py`)
- Dataset loading → Results analysis: provides dataset context (evidence: `src/plotting.py`)
