# alcodes808/can-bus-sentinel-ids architecture

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

- Interactive diagram: https://gitdiagram.com/alcodes808/can-bus-sentinel-ids
- Repository: https://github.com/alcodes808/can-bus-sentinel-ids

## Overview

CAN Sentinel simulates automotive CAN traffic, injects attacks, and analyzes received frames with rule-based and ML detectors. The principal workflow is orchestrated by the C simulation: ECUs transmit frames over a virtual bus, scheduled attacks add malicious traffic, IDS checks frames, and logging/export supports review and model training. The repository also includes browser dashboards for bus, threat, overview, and ML views. Some dashboard data wiring and unsampled subsystem details are documented only at a high level, so those relationships are left unverified.

Main entry points: [`src/main.c`](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/main.c) (Simulation Orchestrator), [`src/json_logger.c`](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/json_logger.c) (JSON Logger), [`src/can_bus.c`](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/can_bus.c) (Virtual CAN Bus), [`src/ids_detector.c`](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ids_detector.c) (Rule-Based IDS)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["CAN Simulation"]
  node_runtime["Simulation Orchestrator<br/>[main.c]"]
  node_frames["CAN Frames<br/>[can_frame.c]"]
  node_bus["Virtual CAN Bus<br/>[can_bus.c]"]
  node_ecus["ECU Nodes<br/>[ecu_node.c]"]
  node_dtc[("Diagnostic Trouble Codes<br/>[dtc_manager.c]")]
end

subgraph group_security["Threat Simulation"]
  node_attacks["Attack Injector<br/>[attack_injector.c]"]
end

subgraph group_detection["Intrusion Detection"]
  node_ids["Rule-Based IDS<br/>[ids_detector.c]"]
end

subgraph group_ml["Machine Learning"]
  node_ml_detector["ML Anomaly Detector<br/>[ml_detector.c]"]
  node_model_params["Model Parameters<br/>[ml_model_params.h]"]
  node_exporter["Feature Exporter<br/>[ml_exporter.c]"]
  node_trainer["Model Trainer<br/>[ml_trainer.py]"]
end

subgraph group_visibility["Monitoring &amp; Diagnostics"]
  node_logger["JSON Logger<br/>[json_logger.c]"]
  node_dashboard["Security Overview<br/>[overview.js]"]
  node_bus_monitor["Bus Traffic Monitor<br/>[bus-monitor.js]"]
  node_threat_view["Threat Detection View<br/>[ids-detection.js]"]
  node_ml_view["ML Analysis View<br/>[ml-analysis.js]"]
end

node_operator(("Operator"))

node_operator -->|"runs simulation"| node_runtime
node_runtime -->|"initializes and uses"| node_bus
node_runtime -->|"initializes and sends"| node_ecus
node_runtime -->|"schedules and executes"| node_attacks
node_runtime -->|"learns and analyzes"| node_ids
node_runtime -->|"records faults"| node_dtc
node_runtime -->|"logs frames"| node_logger
node_runtime -->|"exports samples"| node_exporter
node_ecus -->|"transmits frames"| node_bus
node_attacks -->|"injects frames"| node_bus
node_bus -->|"supplies received frames"| node_ids
node_ids -->|"checks anomalies"| node_ml_detector
node_ml_detector -->|"uses parameters"| node_model_params
node_exporter -->|"exports training data"| node_trainer
node_trainer -->|"exports model parameters"| node_model_params
node_logger -.->|"provides monitoring data"| node_dashboard
node_logger -.->|"provides traffic data"| node_bus_monitor
node_logger -.->|"provides alert data"| node_threat_view
node_logger -.->|"provides ML metrics"| node_ml_view

click node_runtime "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/main.c"
click node_frames "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/can_frame.c"
click node_bus "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/can_bus.c"
click node_ecus "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ecu_node.c"
click node_attacks "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/attack_injector.c"
click node_ids "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ids_detector.c"
click node_ml_detector "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ml_detector.c"
click node_model_params "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/include/ml_model_params.h"
click node_exporter "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ml_exporter.c"
click node_trainer "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/ml_trainer.py"
click node_dtc "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/dtc_manager.c"
click node_logger "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/json_logger.c"
click node_dashboard "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/overview.js"
click node_bus_monitor "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/bus-monitor.js"
click node_threat_view "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/ids-detection.js"
click node_ml_view "https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/ml-analysis.js"

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_runtime,node_frames,node_bus,node_ecus,node_dtc toneBlue
class node_attacks toneAmber
class node_ids toneMint
class node_ml_detector,node_model_params,node_exporter,node_trainer toneRose
class node_logger,node_dashboard,node_bus_monitor,node_threat_view,node_ml_view,node_operator toneIndigo
```

## Components

### CAN Simulation

- [Simulation Orchestrator](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/main.c): `src/main.c`
- [CAN Frames](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/can_frame.c): `src/can_frame.c`
- [Virtual CAN Bus](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/can_bus.c): `src/can_bus.c`
- [ECU Nodes](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ecu_node.c): `src/ecu_node.c`
- [Diagnostic Trouble Codes](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/dtc_manager.c): `src/dtc_manager.c`

### Threat Simulation

- [Attack Injector](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/attack_injector.c): `src/attack_injector.c`

### Intrusion Detection

- [Rule-Based IDS](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ids_detector.c): `src/ids_detector.c`

### Machine Learning

- [ML Anomaly Detector](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ml_detector.c): `src/ml_detector.c`
- [Model Parameters](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/include/ml_model_params.h): `include/ml_model_params.h`
- [Feature Exporter](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/ml_exporter.c): `src/ml_exporter.c`
- [Model Trainer](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/ml_trainer.py): `ml_trainer.py`

### Monitoring & Diagnostics

- [JSON Logger](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/src/json_logger.c): `src/json_logger.c`
- [Security Overview](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/overview.js): `dashboard/js/overview.js`
- [Bus Traffic Monitor](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/bus-monitor.js): `dashboard/js/bus-monitor.js`
- [Threat Detection View](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/ids-detection.js): `dashboard/js/ids-detection.js`
- [ML Analysis View](https://github.com/alcodes808/can-bus-sentinel-ids/blob/main/dashboard/js/ml-analysis.js): `dashboard/js/ml-analysis.js`

### Other components

- **Operator**

## Connections

- Operator → Simulation Orchestrator: runs simulation (evidence: `src/main.c`)
- Simulation Orchestrator → Virtual CAN Bus: initializes and uses (evidence: `src/main.c`)
- Simulation Orchestrator → ECU Nodes: initializes and sends (evidence: `src/main.c`)
- Simulation Orchestrator → Attack Injector: schedules and executes (evidence: `src/main.c`)
- Simulation Orchestrator → Rule-Based IDS: learns and analyzes (evidence: `src/main.c`)
- Simulation Orchestrator → Diagnostic Trouble Codes: records faults (evidence: `src/main.c`)
- Simulation Orchestrator → JSON Logger: logs frames (evidence: `src/main.c`)
- Simulation Orchestrator → Feature Exporter: exports samples (evidence: `src/main.c`)
- ECU Nodes → Virtual CAN Bus: transmits frames
- Attack Injector → Virtual CAN Bus: injects frames
- Virtual CAN Bus → Rule-Based IDS: supplies received frames
- Rule-Based IDS → ML Anomaly Detector: checks anomalies (evidence: `src/ids_detector.c`)
- ML Anomaly Detector → Model Parameters: uses parameters
- Feature Exporter → Model Trainer: exports training data (evidence: `README.md`)
- Model Trainer → Model Parameters: exports model parameters (evidence: `README.md`)
- JSON Logger → Security Overview: provides monitoring data
- JSON Logger → Bus Traffic Monitor: provides traffic data
- JSON Logger → Threat Detection View: provides alert data
- JSON Logger → ML Analysis View: provides ML metrics
