# steviegoneevil/ann-for-ddos-detection architecture

> Architecture diagram of the GitHub repository steviegoneevil/ann-for-ddos-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/steviegoneevil/ann-for-ddos-detection
- Repository: https://github.com/steviegoneevil/ann-for-ddos-detection

## Overview

##### Project type and purpose
- This is a Python-based command-line tool (“ProjectANN.py”) for DDoS detection using an Artificial Neural Network (ANN).
- Core features (per README): packet sniffing, data gathering, dataset viewing, ANN training, live attack detection, and ANN visualization.

##### File structure
- Root script: ProjectANN.py – main CLI driver.
- Data folders:
- CSV Files/ – raw and processed CSV datasets.
- Test Models/ – pre-trained ANN model files (.sav).
- Misc, Previous Versions – history and utilities (not part of core real-time flow).
- Supporting scripts: DrawAnnv2.py – ANN visualizer.
- Artifacts: Model.sav, ModelWeights.txt – saved ANN outputs.
- Config: requirements.txt – Python dependencies (scikit-learn, pandas, matplotlib, pyshark).

##### README for architectural insights
- External dependencies: Python 3.6, Wireshark/Tshark/WinPcap, Visual C++ build tools (for pyshark).
- CLI menu drives six major modules (1–6).
- Data persists on disk as CSVs and .sav model files; logs written to log.txt.

a. Components
- CLI Controller (ProjectANN.py)
- Packet Capture Module (pyshark/Tshark)
- Data Preprocessing & Storage (pandas → CSV Files/)
- ANN Trainer (scikit-learn, numpy)
- Model Repository (Test Models/, Model.sav)
- Live Detection Engine (loads .sav, monitors network)
- Visualization Module (DrawAnnv2.py + matplotlib)
- Data Viewer (pandas CLI tool)
- External Systems: Network Interface, Disk Storage
b. Relationships & data flow
- CLI Controller invokes Packet Capture → streams packets → Data Preprocessor → writes CSV.
- CLI → ANN Trainer reads CSV → trains model → persists .sav → writes ModelWeights.txt.
- CLI → Data Viewer reads CSV → outputs to console.
- CLI → Live Detector loads .sav → captures live packets → classifies → raises alert or logs.
- CLI → Visualizer loads model structure → renders graph.
c. Architectural patterns
- File-based “loose coupling”: modules exchange data via disk (CSV and .sav).
- External library integration (pyshark for capture, scikit-learn for ML).
d. Key technologies
- Python 3.6, PyShark/Tshark, pandas, scikit-learn, numpy, matplotlib, pickle (.sav), CSV.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    subgraph "External Systems"
        NI["Network Interface"]:::external
        TS["Tshark/WinPcap"]:::external
        SK["scikit-learn"]:::external
        PD["pandas"]:::external
        PLT["matplotlib"]:::external
    end

    %% CLI and Modules
    subgraph "CLI Controller"
        CLI["ProjectANN.py"]:::module
        PC["Packet Capture Module"]:::module
        DP["Data Preprocessor"]:::module
        TR["ANN Trainer"]:::module
        DV["Data Viewer"]:::module
        LD["Live Detection Engine"]:::module
        VM["Visualization Module"]:::module
    end

    %% Data Stores
    subgraph "Data Stores"
        CSV["CSV Files/"]:::datastore
        LiveCSV["LiveAnn.csv"]:::datastore
        TM["Test Models/"]:::datastore
        MS["Model.sav"]:::datastore
        MW["ModelWeights.txt"]:::datastore
        TD["TestingData.csv"]:::datastore
        LOG["log.txt"]:::datastore
        REQ["requirements.txt"]:::datastore
    end

    %% User
    User["User"]:::external

    %% Relationships
    User --> CLI
    CLI --> PC
    NI --> TS --> PC
    PC -->|"raw packets"| DP
    DP -->|"processed .csv"| CSV

    CSV --> TR
    TR --> MS
    TR --> MW
    CSV --> DV
    DV --> TD

    CLI --> TR
    CLI --> DV
    CLI --> LD
    CLI --> VM
    CLI --> LOG

    MS --> LD
    LiveCSV --> LD
    PC --> LiveCSV

    VM --> MS

    %% Dependencies
    PC --> TS
    DP --> PD
    TR --> SK
    TR --> PD
    VM --> PLT
    DV --> PD

    %% Click Events
    click CLI "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/ProjectANN.py"
    click CSV "https://github.com/steviegoneevil/ann-for-ddos-detection/tree/master/CSV Files/"
    click TM "https://github.com/steviegoneevil/ann-for-ddos-detection/tree/master/Test Models/"
    click MS "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/Model.sav"
    click MW "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/ModelWeights.txt"
    click LiveCSV "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/CSV Files/LiveAnn.csv"
    click VM "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/DrawAnnv2.py"
    click TD "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/CSV Files/TestingData.csv"
    click LOG "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/log.txt"
    click REQ "https://github.com/steviegoneevil/ann-for-ddos-detection/blob/master/requirements.txt"

    %% Styles
    classDef module fill:#ADD8E6,stroke:#000,color:#000
    classDef datastore fill:#90EE90,stroke:#000,color:#000
    classDef external fill:#FFA500,stroke:#000,color:#000
```
