# sondt1337/ai-based-ics-incident-investigation-system architecture

> Architecture diagram of the GitHub repository sondt1337/ai-based-ics-incident-investigation-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sondt1337/ai-based-ics-incident-investigation-system
- Repository: https://github.com/sondt1337/ai-based-ics-incident-investigation-system

## Overview

##### Main Components
- AI Module – Represented by the “ai” directory, which includes notebooks, scripts for preprocessing (ai/xgboost_preprocess.py), confusion matrix computation, and various tuning scripts (grid, hand, hyperopt). This component handles data analysis, anomaly detection, and training of the XGBoost model.
- Benchmarking Module – Found in the “benchmark” directory, which holds benchmarking scripts for different models (XGBoost, Logistic Regression, SVM, etc.) to compare performance.
- Data Storage / Collection – The “csv” and “pcaps” directories hold the raw datasets and network packets respectively. CSV files include datasets and summary files, while PCAP files provide recorded network traffic captures.
- Frontend/Visualization – The “frontend” directory contains the Dockerfile, docker-compose, and the Python app responsible for presenting the visualization (network topology, infected devices, etc.). It integrates with the AI analysis module to display detection results.
- Demo & Additional Resources – The “demo” folder provides demo videos that can be referenced to understand the user experience and visualization flows.

##### Relationships and Data Flow
- AI Training – From preprocessed data, the AI module (specifically the XGBoost training components) processes the data for both training and evaluation. Note any tuning steps as iterative loops for optimizing parameters.
- Benchmarking – Parallel to the training, the benchmark scripts compare AI model performances to validate performance metrics.
- Visualization Component – The results from the AI analysis (malicious detection outputs, network flows) are then fed into the frontend application which visualizes network topology, lists infected devices, and flags malicious actions.
- Deployment – Include containerization via Docker (seen in the “frontend” Dockerfile and docker-compose), which wraps the frontend service for deployment.

##### Architectural Patterns & Key Design Principles
- Data Flow Pipeline – Reflect a pipeline where raw data (from pcap and csv) is transformed, features are extracted, and then provided as inputs to machine learning algorithms.
- Integration via APIs / Data Sharing – Make clear the connectivity between the AI backend and the frontend visualization layer, likely via REST APIs or direct import.

##### Relevant Technologies and Frameworks
- XGBoost – As the primary AI model used for multi-class classification.
- Python – The underlying language for the AI modules, benchmarks, and frontend app.
- Docker & Docker Compose – For containerizing the frontend (and possibly other components).
- Possibly additional libraries used in preprocessing, tuning (like Hyperopt), and visualization.

##### Final Assembly
- Zoom in on the AI component by further breaking it down into XGBoost tuning, confusion matrix evaluation, and performance benchmarking.
- Lastly, include deployment details showing how Docker configurations (frontend/Dockerfile and docker-compose.yml) enable the system to run as a containerized application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Collection Layer
    subgraph "Data Collection"
        CSV["Data Collection (CSV files)"]:::datastore
        PCAP["Data Collection (PCAP files)"]:::datastore
    end

    %% AI Module Layer
    subgraph "AI Module"
        Preproc["Preprocessing (ai/xgboost_preprocess.py)"]:::ai
        Tuning["Tuning (ai/tuning)"]:::ai
        Analysis["AI Analysis (XGBoost Training)"]:::ai
        Evaluation["Evaluation (ai/confusion_matrix)"]:::ai
    end

    %% Benchmarking Layer
    subgraph "Benchmarking"
        Benchmark["Benchmarking Module (benchmark)"]:::benchmark
    end

    %% Frontend & Deployment Layer
    subgraph "Frontend & Deployment"
        Frontend["Frontend App (app)"]:::frontend
        Dockerfile["Dockerfile (frontend/Dockerfile)"]:::frontend
        DockerCompose["Docker Compose (docker-compose.yml)"]:::frontend
    end

    %% Demo & Resources Layer
    subgraph "Demo & Resources"
        Demo["Demo & Additional Resources"]:::demo
    end

    %% Data Flow Connections
    CSV --> Preproc
    PCAP --> Preproc
    Preproc --> Analysis
    Tuning -.-> Analysis
    Analysis --> Evaluation
    Evaluation -.-> Tuning
    Analysis --> Benchmark
    Analysis --> Frontend
    Benchmark --> Frontend
    Frontend --> Dockerfile
    Frontend --> DockerCompose
    Frontend --> Demo

    %% Click Events
    click Preproc "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/blob/main/ai/xgboost_preprocess.py"
    click Tuning "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/ai/tuning"
    click Evaluation "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/ai/confusion_matrix"
    click Benchmark "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/blob/main/benchmark/benchmark_xgboost.py"
    click CSV "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/csv/"
    click PCAP "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/pcaps/"
    click Frontend "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/blob/main/frontend/app/app.py"
    click Dockerfile "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/frontend/Dockerfile"
    click DockerCompose "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/blob/main/frontend/docker-compose.yml"
    click Demo "https://github.com/sondt1337/ai-based-ics-incident-investigation-system/tree/main/demo/"

    %% Styles
    classDef datastore fill:#AED6F1,stroke:#1F618D,stroke-width:2px,color:#000;
    classDef ai fill:#F9E79F,stroke:#B7950B,stroke-width:2px,color:#000;
    classDef benchmark fill:#F5B7B1,stroke:#C0392B,stroke-width:2px,color:#000;
    classDef frontend fill:#D5F5E3,stroke:#27AE60,stroke-width:2px,color:#000;
    classDef demo fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px,color:#000;
```
