# abhiraj-hub/light_ids architecture

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

- Interactive diagram: https://gitdiagram.com/abhiraj-hub/light_ids
- Repository: https://github.com/abhiraj-hub/light_ids

## Overview

Lightweight IDS captures live or replayed IPv4 traffic, parses packets, evaluates signatures and sliding-window anomalies, then logs findings and dispatches configured alerts. The main control path is visible in main and packet_processor excerpts; alert-channel details are partially sampled, with README documentation supporting the broader capabilities. State and output are process-local except for JSON-lines logs and network alert delivery.

Main entry points: [`src/alert_sender.c`](https://github.com/abhiraj-hub/light_ids/blob/main/src/alert_sender.c) (Alert Dispatch and Limits), [`src/main.c`](https://github.com/abhiraj-hub/light_ids/blob/main/src/main.c) (IDS Entrypoint), [`src/packet_processor.c`](https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c) (Packet Analysis and Alerting), [`src/event_logger.c`](https://github.com/abhiraj-hub/light_ids/blob/main/src/event_logger.c) (Event Logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Capture and Parsing"]
  node_ids_main["IDS Entrypoint<br/>[main.c]"]
  node_live_capture["Live Capture<br/>[packet_processor.c]"]
  node_pcap_replay["PCAP Replay<br/>[packet_processor.c]"]
  node_packet_parse["IPv4 Packet Parsing<br/>[packet_processor.c]"]
  node_packet_model["Parsed Packet<br/>[packet_types.h]"]
  node_packet_orchestration["Packet Analysis and Alerting<br/>[packet_processor.c]"]
end

subgraph group_detect["Detection"]
  node_signature_detection["Signature Matching"]
  node_anomaly_detection["Anomaly Detection<br/>[anomaly_detector.c]"]
end

subgraph group_notify["Logging and Alerts"]
  node_alert_sender["Alert Dispatch and Limits<br/>[alert_sender.c]"]
  node_email_service["SMTP Relay"]
  node_slack_service["Slack Webhook"]
  node_webhook_service["Webhook Endpoint"]
  node_event_logger["Event Logger<br/>[event_logger.c]"]
  node_event_log[("JSON-lines Log")]
end

subgraph group_support["Configuration and Data"]
  node_rules["Signature Rules<br/>[rules.json]"]
  node_alert_config["Alert Configuration<br/>[alerting.json]"]
  node_json_parser["JSON Parser<br/>[json.c]"]
  node_utility_encoding["JSON and Base64 Encoding<br/>[util.c]"]
end

node_operator(("Operator"))
node_network_input(("Monitored Network"))
node_pcap_input["PCAP File"]

node_operator -->|"starts"| node_ids_main
node_ids_main -->|"starts capture"| node_live_capture
node_ids_main -->|"starts replay"| node_pcap_replay
node_network_input -.->|"provides packets"| node_live_capture
node_pcap_input -.->|"provides packets"| node_pcap_replay
node_live_capture -->|"dispatches packets"| node_packet_parse
node_pcap_replay -->|"dispatches packets"| node_packet_parse
node_packet_parse -->|"populates"| node_packet_model
node_packet_parse -.->|"passes packet"| node_packet_orchestration
node_packet_orchestration -->|"inspects packet"| node_signature_detection
node_packet_orchestration -->|"analyzes packet"| node_anomaly_detection
node_ids_main -->|"loads rules"| node_rules
node_ids_main -->|"loads config"| node_alert_config
node_signature_detection -.->|"parses rules"| node_rules
node_packet_orchestration -->|"logs findings"| node_event_logger
node_packet_orchestration -->|"dispatches alerts"| node_alert_sender
node_ids_main -->|"initializes logger"| node_event_logger
node_alert_sender -->|"parses config"| node_json_parser
node_alert_sender -.->|"reads config"| node_alert_config
node_alert_sender -.->|"sends email"| node_email_service
node_alert_sender -->|"posts alert"| node_slack_service
node_alert_sender -->|"posts alert"| node_webhook_service
node_alert_sender -->|"encodes payloads"| node_utility_encoding
node_event_logger -.->|"writes JSON-lines"| node_event_log

click node_ids_main "https://github.com/abhiraj-hub/light_ids/blob/main/src/main.c"
click node_live_capture "https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c"
click node_pcap_replay "https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c"
click node_packet_parse "https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c"
click node_packet_model "https://github.com/abhiraj-hub/light_ids/blob/main/include/packet_types.h"
click node_signature_detection "https://github.com/abhiraj-hub/light_ids/blob/main/src/signature_detector.c"
click node_anomaly_detection "https://github.com/abhiraj-hub/light_ids/blob/main/src/anomaly_detector.c"
click node_rules "https://github.com/abhiraj-hub/light_ids/blob/main/config/rules.json"
click node_alert_config "https://github.com/abhiraj-hub/light_ids/blob/main/config/alerting.json"
click node_packet_orchestration "https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c"
click node_alert_sender "https://github.com/abhiraj-hub/light_ids/blob/main/src/alert_sender.c"
click node_event_logger "https://github.com/abhiraj-hub/light_ids/blob/main/src/event_logger.c"
click node_json_parser "https://github.com/abhiraj-hub/light_ids/blob/main/src/json.c"
click node_utility_encoding "https://github.com/abhiraj-hub/light_ids/blob/main/src/util.c"

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_ids_main,node_live_capture,node_pcap_replay,node_packet_parse,node_packet_model,node_packet_orchestration toneBlue
class node_signature_detection,node_anomaly_detection toneAmber
class node_alert_sender,node_email_service,node_slack_service,node_webhook_service,node_event_logger,node_event_log toneMint
class node_rules,node_alert_config,node_json_parser,node_utility_encoding toneRose
class node_operator,node_network_input,node_pcap_input toneIndigo
```

## Components

### Capture and Parsing

- [IDS Entrypoint](https://github.com/abhiraj-hub/light_ids/blob/main/src/main.c): `src/main.c`
- [Live Capture](https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c): `src/packet_processor.c`
- [PCAP Replay](https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c): `src/packet_processor.c`
- [IPv4 Packet Parsing](https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c): `src/packet_processor.c`
- [Parsed Packet](https://github.com/abhiraj-hub/light_ids/blob/main/include/packet_types.h): `include/packet_types.h`
- [Packet Analysis and Alerting](https://github.com/abhiraj-hub/light_ids/blob/main/src/packet_processor.c): `src/packet_processor.c`

### Detection

- [Signature Matching](https://github.com/abhiraj-hub/light_ids/blob/main/src/signature_detector.c): `src/signature_detector.c`
- [Anomaly Detection](https://github.com/abhiraj-hub/light_ids/blob/main/src/anomaly_detector.c): `src/anomaly_detector.c`

### Logging and Alerts

- [Alert Dispatch and Limits](https://github.com/abhiraj-hub/light_ids/blob/main/src/alert_sender.c): `src/alert_sender.c`
- **SMTP Relay**
- **Slack Webhook**
- **Webhook Endpoint**
- [Event Logger](https://github.com/abhiraj-hub/light_ids/blob/main/src/event_logger.c): `src/event_logger.c`
- **JSON-lines Log**

### Configuration and Data

- [Signature Rules](https://github.com/abhiraj-hub/light_ids/blob/main/config/rules.json): `config/rules.json`
- [Alert Configuration](https://github.com/abhiraj-hub/light_ids/blob/main/config/alerting.json): `config/alerting.json`
- [JSON Parser](https://github.com/abhiraj-hub/light_ids/blob/main/src/json.c): `src/json.c`
- [JSON and Base64 Encoding](https://github.com/abhiraj-hub/light_ids/blob/main/src/util.c): `src/util.c`

### Other components

- **Operator**
- **Monitored Network**
- **PCAP File**

## Connections

- Operator → IDS Entrypoint: starts (evidence: `src/main.c`)
- IDS Entrypoint → Live Capture: starts capture (evidence: `src/main.c`)
- IDS Entrypoint → PCAP Replay: starts replay (evidence: `src/main.c`)
- Monitored Network → Live Capture: provides packets (evidence: `README.md`)
- PCAP File → PCAP Replay: provides packets (evidence: `README.md`)
- Live Capture → IPv4 Packet Parsing: dispatches packets (evidence: `src/packet_processor.c`)
- PCAP Replay → IPv4 Packet Parsing: dispatches packets (evidence: `src/packet_processor.c`)
- IPv4 Packet Parsing → Parsed Packet: populates (evidence: `src/packet_processor.c`)
- IPv4 Packet Parsing → Packet Analysis and Alerting: passes packet (evidence: `src/packet_processor.c`)
- Packet Analysis and Alerting → Signature Matching: inspects packet (evidence: `src/packet_processor.c`)
- Packet Analysis and Alerting → Anomaly Detection: analyzes packet (evidence: `src/packet_processor.c`)
- IDS Entrypoint → Signature Rules: loads rules (evidence: `src/main.c`)
- IDS Entrypoint → Alert Configuration: loads config (evidence: `src/main.c`)
- Signature Matching → Signature Rules: parses rules
- Packet Analysis and Alerting → Event Logger: logs findings (evidence: `src/packet_processor.c`)
- Packet Analysis and Alerting → Alert Dispatch and Limits: dispatches alerts (evidence: `src/packet_processor.c`)
- IDS Entrypoint → Event Logger: initializes logger (evidence: `src/main.c`)
- Alert Dispatch and Limits → JSON Parser: parses config (evidence: `src/alert_sender.c`)
- Alert Dispatch and Limits → Alert Configuration: reads config
- Alert Dispatch and Limits → SMTP Relay: sends email (evidence: `README.md`)
- Alert Dispatch and Limits → Slack Webhook: posts alert (evidence: `src/alert_sender.c`)
- Alert Dispatch and Limits → Webhook Endpoint: posts alert (evidence: `src/alert_sender.c`)
- Alert Dispatch and Limits → JSON and Base64 Encoding: encodes payloads (evidence: `src/alert_sender.c`)
- Event Logger → JSON-lines Log: writes JSON-lines (evidence: `README.md`)
