# sandeepelayath/capstone_2026_pw25_rmh_01 architecture

> Architecture diagram of the GitHub repository sandeepelayath/capstone_2026_pw25_rmh_01, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sandeepelayath/capstone_2026_pw25_rmh_01
- Repository: https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01

## Overview

##### Project type and purpose
- This is a full-stack SDN (Software-Defined Networking) application with built-in ML-based anomaly detection and a real-time analytics dashboard.
- It simulates traffic in Mininet, uses Ryu as the SDN controller, processes flow data through a trained LSTM (and hybrid LSTM-RANN) model for anomaly detection, then triggers adaptive QoS or honeypot mitigation, and visualizes metrics via a Streamlit dashboard.

##### File structure
- Top-level scripts:
- admin_interface.py (CLI or REST endpoint for on-demand actions)
- analytics_dashboard.py (Streamlit or Flask dashboard)
- demo_attack_simulation.py (drives simulated attack traffic)
- run_dashboard.sh
- controller/
- ryu_controller.py (entry point for Ryu controller)
- process-and-predict.py (ingests flows, invokes ML model)
- flow_classifier.py (abstraction for model inference)
- mitigation_manager.py (QoS or honeypot logic)
- data_processing/
- preprocess_cicids.py (feature-engineering pipeline for CIC-IDS dataset)
- ML_Model_Latest/, lstm_finetuned_ml_model/, lstm_rann_hybrid_finetuned_ml_model/
- CSV storage, model files (.h5, .keras), pickled scaler & feature names
- mininet/
- test_topology.py (defines network topology)
- fix_connectivity.py, mininet-data-collector.py (live flow capture)
- Configuration & environment: requirements.txt, .gitignore, DASHBOARD_README.md

##### README for additional insights
- Describes dependencies (Mininet, Open vSwitch, Python 3.9, Ryu).
- Details setup, data preprocessing, model training, controller launch, topology simulation, and dashboard launch.
- No external database—models and flow data are file-based.

a. Main components
1. Mininet Layer (Simulated switches & hosts)
2. SDN Controller (Ryu)
3. Data Processing & ML Engine (process-and-predict, flow_classifier, mitigation_manager)
4. Storage (local CSV, pickle/keras model files)
5. Analytics Dashboard (Streamlit UI)
6. Admin Interface (optional CLI/REST endpoint)
b. Relationships & interactions
- Mininet test_topology.py spins up virtual network → forwards flow statistics (via OpenFlow) to Ryu controller.
- ryu_controller.py emits PACKET_IN or STATS_REPLY events → process-and-predict.py extracts features.
- flow_classifier applies the LSTM (or LSTM-RANN) model, scaler, and feature_names → outputs anomaly score/class.
- mitigation_manager triggers QoS adjustments via Ryu APIs or redirects suspicious flows to honeypot.
- analytics_dashboard.py polls log files or exposes WebSocket/REST endpoints on controller to display real-time stats.
- admin_interface.py allows manual overrides or policy changes via controller RPC.
c. Architectural patterns & principles
- Layered architecture: data-plane (Mininet), control-plane (Ryu controller), application-plane (ML engine, mitigation logic), presentation-plane (dashboard).
- Modular design: each responsibility (flow capture, preprocessing, classification, mitigation, visualization) is decoupled into separate modules.
- Asynchronous event-driven flow handling within Ryu.
d. Key technologies
- Mininet & OVS for network emulation
- Ryu SDN controller framework (Python, event handlers)
- TensorFlow/Keras LSTM and hybrid LSTM-RANN models
- Scikit-learn for feature scaling
- Streamlit (or equivalent) for dashboard UI
- Python 3.9 environment managed by pip and virtualenv

##### Detail
- Event flows: PACKET_IN → feature extraction → predict() → mitigate().
- Configuration paths (requirements.txt → environment setup).
- Tuning or phase scripts (e.g., LSTM_Phase3 scripts under ML_Model_Latest).
- How demo_attack_simulation.py integrates with Mininet to generate traffic patterns your detection pipeline processes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Plane Layer
    subgraph "Data Plane (Mininet Layer)"
        direction TB
        DemoSim["Demo Attack Simulation"]:::dataPlane
        TestTopo["Test Topology"]:::dataPlane
        FixConn["Fix Connectivity"]:::dataPlane
        DataCollector["Mininet Data Collector"]:::dataPlane
    end

    %% Control Plane Layer
    subgraph "Control Plane (Ryu Controller)"
        direction TB
        RyuController["Ryu Controller"]:::controlPlane
    end

    %% ML Engine Layer
    subgraph "ML Engine (Data Processing & Anomaly Detection)"
        direction TB
        Preprocess["CIC-IDS Preprocessing"]:::ml
        ProcessPredict["Flow Ingestion & Prediction"]:::ml
        FlowClassifier["Model Abstraction & Inference"]:::ml
        MitigationMgr["Mitigation Manager (QoS/Honeypot)"]:::ml
    end

    %% Storage Layer
    subgraph "Local File Storage" 
        direction TB
        MLLatest["ML_Model_Latest"]:::storage
        LSTMFine["LSTM Fine-Tuned Model"]:::storage
        HybridModel["LSTM-RANN Hybrid Model"]:::storage
    end

    %% Presentation Layer
    subgraph "Presentation & Admin"
        direction TB
        Dashboard["Analytics Dashboard"]:::ui
        AdminInterface["Admin Interface"]:::ui
    end

    %% Data Plane to Control Plane
    DemoSim -->|generates traffic| TestTopo
    TestTopo -->|OpenFlow stats| RyuController
    FixConn --> TestTopo
    DataCollector --> TestTopo

    %% Control to ML Engine
    RyuController -->|PACKET_IN / STATS_REPLY| ProcessPredict
    ProcessPredict -->|feature data| FlowClassifier
    Preprocess -->|features| FlowClassifier
    FlowClassifier -->|anomaly score| RyuController
    FlowClassifier -->|uses model| MLLatest
    FlowClassifier -->|uses model| LSTMFine
    FlowClassifier -->|uses model| HybridModel

    %% Mitigation actions
    RyuController -->|invoke| MitigationMgr
    MitigationMgr -->|OpenFlow commands| TestTopo

    %% Presentation interactions
    RyuController -->|REST/WebSocket| Dashboard
    RyuController -->|RPC| AdminInterface

    %% Additional Preprocessing
    DataCollector -->|raw flows| Preprocess
    Preprocess -->|store data| MLLatest

    %% Click Events
    click DemoSim "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/demo_attack_simulation.py"
    click TestTopo "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/mininet/test_topology.py"
    click FixConn "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/mininet/fix_connectivity.py"
    click DataCollector "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/mininet/mininet-data-collector.py"
    click RyuController "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/controller/ryu_controller.py"
    click ProcessPredict "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/controller/process-and_predict.py"
    click FlowClassifier "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/controller/flow_classifier.py"
    click MitigationMgr "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/controller/mitigation_manager.py"
    click Preprocess "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/data_processing/preprocess_cicids.py"
    click MLLatest "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/tree/main/ML_Model_Latest/"
    click LSTMFine "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/tree/main/lstm_finetuned_ml_model/"
    click HybridModel "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/tree/main/lstm_rann_hybrid_finetuned_ml_model/"
    click Dashboard "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/analytics_dashboard.py"
    click AdminInterface "https://github.com/sandeepelayath/capstone_2026_pw25_rmh_01/blob/main/admin_interface.py"

    %% Styles
    classDef dataPlane fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef controlPlane fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#000,stroke-width:1px
    classDef ui fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef storage fill:#FFD700,stroke:#000,stroke-width:1px
```
