# itayshallev/spine architecture

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

- Interactive diagram: https://gitdiagram.com/itayshallev/spine
- Repository: https://github.com/itayshallev/spine

## Overview

1. **Repository shape**  
   SPINE is primarily a Linux-native C++ intrusion-detection and network-enforcement system. Its runtime code is under `src/`. A separate `spine-gui/` directory contains a Vite/React frontend intended to visualize or control the system, but the visible C++ tree does not show an API/server adapter connecting that GUI to the IDS core.

2. **Top-level orchestration**  
   `main.cpp` is the process entry point. Shared application-level concerns are represented by `configuration`, `componentsCommunicator`, `IComponent`, common custom types, and utilities. These form the coordination layer around otherwise distinct detection, defense, persistence, and logging components.

3. **Component boundary model**  
   `IComponent` provides a common abstraction for major backend components. `componentsCommunicator` is the likely in-process messaging/coordination boundary between them, rather than direct coupling among every subsystem. An architecture diagram should show the components connected through this coordinator, with configuration as a shared input.

4. **Traffic interception boundary**  
   The system operates at the Linux packet-processing boundary using `libnetfilter_queue`, as stated in the README. `netfilterCapture` and `netfilterPacket` represent packets received from Netfilter queues; this is the primary ingress for traffic that SPINE can inspect and potentially enforce policy upon. Deployment therefore depends on Linux firewall/Netfilter rules routing packets into the configured queue.

5. **Packet capture implementations**  
   `IPacketCapture` abstracts packet acquisition. Two concrete capture paths exist: `netfilterCapture`, for Netfilter Queue interception/enforcement, and `libpcapCapture`, for packet capture via libpcap. This is an important pluggability boundary: downstream analysis should depend on the capture interface rather than on a specific packet source.

6. **Network-stack normalization and parsing**  
   Captured raw data is converted into the project’s packet model through `packet`, `packetBuilder`, and `packetsQueue`. The protocol-layer subsystem parses Ethernet, ARP, IPv4, IPv6, ICMP, TCP, and UDP headers. This layer isolates low-level byte parsing and protocol metadata extraction from attack-detection logic.

7. **Packet lifecycle and output**  
   Packet capture feeds packet construction/parsing, then packets are queued for downstream consumers. `packetSender` provides the complementary packet-output capability, likely used when intercepted traffic must be forwarded, reinjected, modified, or otherwise given a Netfilter verdict. Show packet ingress from the OS into capture, internal normalization/queueing, and a possible outbound/verdict path back to the network stack.

8. **Attack detection subsystem**  
   `attackDetectionComponent` is the detection-facing component that consumes parsed packet information. `attackDetection` and `packetAnalyzer` provide the general analysis layer, while individual detectors encapsulate specific attack signatures or thresholds: ARP spoofing, generic flooding, ICMP/ping floods, and TCP SYN floods.

9. **Detection data flow**  
   The expected central runtime flow is: Linux/Netfilter or libpcap capture → packet parsing/model → packet analysis → specialized detectors → detection event/result. Detection output should fan out to both logging and defensive response. The detection subsystem should not be drawn as owning raw socket or firewall integration; those remain network-stack and defense responsibilities.

10. **Defense and enforcement subsystem**  
    `defenseComponent` receives or acts on detected threats. `networkRulesManager` is the infrastructure-facing adapter responsible for applying network rules, likely through Linux firewall/Netfilter mechanisms. This separates deciding that traffic is malicious from changing host/network policy to block or mitigate it.

11. **Persistence subsystem**  
    The database component consists of `DBComponent` and `DBManager`. It forms a storage boundary behind a component and manager abstraction. The specific database technology is not identifiable from the provided tree, so it should be shown as an internal persistence adapter connected to an external/local database, not labeled with a particular vendor.

12. **Logging subsystem**  
    `loggingComponent` handles operational and security-event logging as a separate consumer of events from detection, defense, and possibly other components. It should be represented independently from the database subsystem because the repository explicitly distinguishes logging from database management.

13. **Configuration and shared utilities**  
    `configuration` centralizes runtime settings, likely including capture, detector, and component behavior. `customTypes` contains shared domain data structures, while `utils` provides cross-cutting helpers. These are supporting dependencies rather than independently deployed services.

14. **Frontend application**  
    `spine-gui` is a standalone JavaScript frontend built with React, Vite, Tailwind CSS, PostCSS, and ESLint. Its UI is organized into dashboard, block management, defense controls, logs viewing, and settings panels. These correspond conceptually to backend observability and control domains: alerts/metrics, defensive blocks/rules, operational controls, logs, and configuration.

15. **GUI integration caveat**  
    No backend HTTP API, WebSocket server, IPC bridge, or frontend service client is present in the supplied tree. The GUI should therefore be diagrammed as a separate presentation layer with an unspecified future/inferred control-and-observability interface to the C++ service, rather than as a confirmed runtime client of a concrete API.

16. **Deployment view**  
    The core SPINE process runs on Linux alongside Netfilter/libnetfilter_queue and potentially libpcap. It interfaces with live network traffic and firewall/rule infrastructure, and may connect to a database. The React GUI has its own Node/Vite development/build toolchain and produces static frontend assets; its production hosting and connection mechanism are not defined in this repository.

Main entry points: [`src/componentsCommunicator.h`](https://github.com/itayshallev/spine/blob/main/src/componentsCommunicator.h) (Component Coordinator), [`src/configuration.h`](https://github.com/itayshallev/spine/blob/main/src/configuration.h) (Configuration), [`src/network_stack/include/netfilterCapture.h`](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/netfilterCapture.h) (Netfilter Capture), [`src/network_stack/include/IPacketCapture.h`](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/IPacketCapture.h) (Capture Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["SPINE Runtime"]
  node_main["SPINE Entry Point<br/>process bootstrap<br/>[main.cpp]"]
  node_config["Configuration<br/>runtime settings<br/>[configuration.h]"]
  node_communicator{{"Component Coordinator<br/>in-process messaging"}}
  node_component_contract["Component Contract<br/>component interface<br/>[IComponent.h]"]
end

subgraph group_traffic["Traffic Pipeline"]
  node_capture_contract["Capture Interface<br/>acquisition interface<br/>[IPacketCapture.h]"]
  node_netfilter_capture["Netfilter Capture<br/>NFQUEUE capture<br/>[netfilterCapture.h]"]
  node_pcap_capture["libpcap Capture<br/>passive capture<br/>[libpcapCapture.h]"]
  node_packet_builder["Packet Builder<br/>packet normalization<br/>[packetBuilder.h]"]
  node_protocol_layers["Protocol Layers<br/>header parsers"]
  node_packet_queue["Packets Queue<br/>packet buffer<br/>[packetsQueue.h]"]
  node_packet_sender["Packet Sender<br/>packet output<br/>[packetSender.h]"]
end

subgraph group_detection["Detection & Response"]
  node_detection_component["Detection Component<br/>IDS component"]
  node_packet_analyzer["Packet Analyzer<br/>analysis engine<br/>[packetAnalyzer.h]"]
  node_detectors["Attack Detectors<br/>signatures & thresholds<br/>[attackDetection.h]"]
  node_defense_component["Defense Component<br/>response component<br/>[defenseComponent.h]"]
  node_rules_manager["Rules Manager<br/>firewall adapter"]
end

subgraph group_operations["Operations Data"]
  node_logging["Logging Component<br/>event logging<br/>[loggingComponent.h]"]
  node_db_component["Database Component<br/>persistence component<br/>[DBComponent.h]"]
  node_db_manager["Database Manager<br/>persistence adapter<br/>[DBManager.h]"]
end

subgraph group_gui["Frontend"]
  node_gui_app["React UI<br/>Vite frontend<br/>[App.jsx]"]
  node_gui_panels["Control Panels<br/>dashboard views"]
  node_gui_bridge{{"Future Service Bridge<br/>unspecified integration"}}
end

node_linux{{"Linux Network Stack<br/>host integration"}}
node_database[("Database<br/>storage target")]

node_main -->|"loads"| node_config
node_main -->|"starts"| node_communicator
node_communicator -->|"coordinates components via"| node_component_contract
node_config -->|"configures"| node_capture_contract
node_config -->|"configures"| node_detection_component
node_config -->|"configures"| node_defense_component
node_linux -->|"queues intercepted traffic"| node_netfilter_capture
node_linux -->|"exposes live traffic"| node_pcap_capture
node_capture_contract -->|"implemented by"| node_netfilter_capture
node_capture_contract -->|"implemented by"| node_pcap_capture
node_netfilter_capture -->|"raw packets"| node_packet_builder
node_pcap_capture -->|"raw packets"| node_packet_builder
node_packet_builder -->|"parses headers"| node_protocol_layers
node_protocol_layers -->|"normalized packets"| node_packet_queue
node_packet_queue -->|"packets"| node_detection_component
node_detection_component -->|"analyzes"| node_packet_analyzer
node_packet_analyzer -->|"evaluates threats"| node_detectors
node_detectors -->|"detection events"| node_communicator
node_communicator -->|"threat response"| node_defense_component
node_communicator -->|"security events"| node_logging
node_communicator -->|"records data"| node_db_component
node_defense_component -->|"mitigation decisions"| node_rules_manager
node_rules_manager -->|"applies firewall rules"| node_linux
node_netfilter_capture -->|"verdict/output path"| node_packet_sender
node_packet_sender -->|"reinjection or verdict"| node_linux
node_logging -->|"persists logs"| node_db_component
node_db_component -->|"uses"| node_db_manager
node_db_manager -->|"stores"| node_database
node_gui_app -->|"renders"| node_gui_panels
node_gui_panels -.->|"requires control and observability"| node_gui_bridge
node_gui_bridge -.->|"not implemented"| node_communicator

click node_main "https://github.com/itayshallev/spine/blob/main/src/main.cpp"
click node_config "https://github.com/itayshallev/spine/blob/main/src/configuration.h"
click node_communicator "https://github.com/itayshallev/spine/blob/main/src/componentsCommunicator.h"
click node_component_contract "https://github.com/itayshallev/spine/blob/main/src/IComponent.h"
click node_capture_contract "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/IPacketCapture.h"
click node_netfilter_capture "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/netfilterCapture.h"
click node_pcap_capture "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/libpcapCapture.h"
click node_packet_builder "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetBuilder.h"
click node_protocol_layers "https://github.com/itayshallev/spine/tree/main/src/network_stack/network_layers"
click node_packet_queue "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetsQueue.h"
click node_packet_sender "https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetSender.h"
click node_detection_component "https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/attackDetectionComponent.h"
click node_packet_analyzer "https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/packetAnalyzer.h"
click node_detectors "https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/attackDetection.h"
click node_defense_component "https://github.com/itayshallev/spine/blob/main/src/defense_component/include/defenseComponent.h"
click node_rules_manager "https://github.com/itayshallev/spine/blob/main/src/defense_component/include/networkRulesManager.h"
click node_logging "https://github.com/itayshallev/spine/blob/main/src/logging_component/include/loggingComponent.h"
click node_db_component "https://github.com/itayshallev/spine/blob/main/src/database_component/include/DBComponent.h"
click node_db_manager "https://github.com/itayshallev/spine/blob/main/src/database_component/include/DBManager.h"
click node_gui_app "https://github.com/itayshallev/spine/blob/main/spine-gui/src/App.jsx"
click node_gui_panels "https://github.com/itayshallev/spine/tree/main/spine-gui/src/components"

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_main,node_config,node_communicator,node_component_contract toneBlue
class node_capture_contract,node_netfilter_capture,node_pcap_capture,node_packet_builder,node_protocol_layers,node_packet_queue,node_packet_sender toneAmber
class node_detection_component,node_packet_analyzer,node_detectors,node_defense_component,node_rules_manager toneMint
class node_logging,node_db_component,node_db_manager toneRose
class node_gui_app,node_gui_panels,node_gui_bridge toneIndigo
class node_linux,node_database toneNeutral
```

## Components

### SPINE Runtime

C++ application composition and coordination

- [SPINE Entry Point](https://github.com/itayshallev/spine/blob/main/src/main.cpp): process bootstrap · Initializes the Linux-native IDS process · `src/main.cpp`
- [Configuration](https://github.com/itayshallev/spine/blob/main/src/configuration.h): runtime settings · Shared component and capture settings · `src/configuration.h`
- [Component Coordinator](https://github.com/itayshallev/spine/blob/main/src/componentsCommunicator.h): in-process messaging · Coordination boundary for backend components · `src/componentsCommunicator.h`
- [Component Contract](https://github.com/itayshallev/spine/blob/main/src/IComponent.h): component interface · Common abstraction for major backend components · `src/IComponent.h`

### Traffic Pipeline

Packet acquisition, normalization, and enforcement path

- [Capture Interface](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/IPacketCapture.h): acquisition interface · Pluggable packet-source boundary · `src/network_stack/include/IPacketCapture.h`
- [Netfilter Capture](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/netfilterCapture.h): NFQUEUE capture · Intercepts packets from libnetfilter_queue · `src/network_stack/include/netfilterCapture.h`
- [libpcap Capture](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/libpcapCapture.h): passive capture · Alternative packet acquisition implementation · `src/network_stack/include/libpcapCapture.h`
- [Packet Builder](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetBuilder.h): packet normalization · Converts captured data into the packet model · `src/network_stack/include/packetBuilder.h`
- [Protocol Layers](https://github.com/itayshallev/spine/tree/main/src/network_stack/network_layers): header parsers · Ethernet, ARP, IP, ICMP, TCP, and UDP parsing · `src/network_stack/network_layers`
- [Packets Queue](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetsQueue.h): packet buffer · Queues normalized packets for downstream consumers · `src/network_stack/include/packetsQueue.h`
- [Packet Sender](https://github.com/itayshallev/spine/blob/main/src/network_stack/include/packetSender.h): packet output · Reinjects, forwards, or applies packet verdict output · `src/network_stack/include/packetSender.h`

### Detection & Response

Threat analysis and host-policy response

- [Detection Component](https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/attackDetectionComponent.h): IDS component · Consumes packets and coordinates threat detection · `src/attacks_detection_component/include/attackDetectionComponent.h`
- [Packet Analyzer](https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/packetAnalyzer.h): analysis engine · General packet analysis and detection flow · `src/attacks_detection_component/include/packetAnalyzer.h`
- [Attack Detectors](https://github.com/itayshallev/spine/blob/main/src/attacks_detection_component/include/attackDetection.h): signatures & thresholds · ARP spoofing, flooding, ping flood, and SYN flood detection · `src/attacks_detection_component/include/attackDetection.h`
- [Defense Component](https://github.com/itayshallev/spine/blob/main/src/defense_component/include/defenseComponent.h): response component · Acts on detected threats · `src/defense_component/include/defenseComponent.h`
- [Rules Manager](https://github.com/itayshallev/spine/blob/main/src/defense_component/include/networkRulesManager.h): firewall adapter · Applies host network rules and mitigation policy · `src/defense_component/include/networkRulesManager.h`

### Operations Data

Logging and persistence boundaries

- [Logging Component](https://github.com/itayshallev/spine/blob/main/src/logging_component/include/loggingComponent.h): event logging · Operational and security-event log consumer · `src/logging_component/include/loggingComponent.h`
- [Database Component](https://github.com/itayshallev/spine/blob/main/src/database_component/include/DBComponent.h): persistence component · Storage boundary for backend data · `src/database_component/include/DBComponent.h`
- [Database Manager](https://github.com/itayshallev/spine/blob/main/src/database_component/include/DBManager.h): persistence adapter · Manages database access behind the component · `src/database_component/include/DBManager.h`

### Frontend

Standalone React/Vite presentation application

- [React UI](https://github.com/itayshallev/spine/blob/main/spine-gui/src/App.jsx): Vite frontend · Standalone dashboard and control application · `spine-gui/src/App.jsx`
- [Control Panels](https://github.com/itayshallev/spine/tree/main/spine-gui/src/components): dashboard views · Dashboard, blocks, defense controls, logs, and settings · `spine-gui/src/components`
- **Future Service Bridge**: unspecified integration · No API, WebSocket, or IPC adapter is present in the repository

### Other components

- **Linux Network Stack**: host integration · Netfilter queues, firewall rules, and live traffic
- **Database**: storage target · Database technology is unspecified

## Connections

- SPINE Entry Point → Configuration: loads
- SPINE Entry Point → Component Coordinator: starts
- Component Coordinator → Component Contract: coordinates components via
- Configuration → Capture Interface: configures
- Configuration → Detection Component: configures
- Configuration → Defense Component: configures
- Linux Network Stack → Netfilter Capture: queues intercepted traffic
- Linux Network Stack → libpcap Capture: exposes live traffic
- Capture Interface → Netfilter Capture: implemented by
- Capture Interface → libpcap Capture: implemented by
- Netfilter Capture → Packet Builder: raw packets
- libpcap Capture → Packet Builder: raw packets
- Packet Builder → Protocol Layers: parses headers
- Protocol Layers → Packets Queue: normalized packets
- Packets Queue → Detection Component: packets
- Detection Component → Packet Analyzer: analyzes
- Packet Analyzer → Attack Detectors: evaluates threats
- Attack Detectors → Component Coordinator: detection events
- Component Coordinator → Defense Component: threat response
- Component Coordinator → Logging Component: security events
- Component Coordinator → Database Component: records data
- Defense Component → Rules Manager: mitigation decisions
- Rules Manager → Linux Network Stack: applies firewall rules
- Netfilter Capture → Packet Sender: verdict/output path
- Packet Sender → Linux Network Stack: reinjection or verdict
- Logging Component → Database Component: persists logs
- Database Component → Database Manager: uses
- Database Manager → Database: stores
- React UI → Control Panels: renders
- Control Panels → Future Service Bridge: requires control and observability
- Future Service Bridge → Component Coordinator: not implemented · Inferred future integration only
