# chinmayee421/network_intrusion_detection_ml architecture

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

- Interactive diagram: https://gitdiagram.com/chinmayee421/network_intrusion_detection_ml
- Repository: https://github.com/chinmayee421/network_intrusion_detection_ml

## Overview

##### Project type and purpose
- This is a machine-learning-powered web application (full-stack ML app) for Network Intrusion Detection (NIDS).
- It ingests user-provided network traffic features via a Streamlit UI, applies a pre-trained Random Forest model, and returns “normal” vs. “malicious” predictions.
- The offline training pipeline (EDA, preprocessing, feature selection with RFE, model training in a Jupyter notebook) produces a serialized model artifact (random_forest_model.pkl).

##### File structure
- Top level:
- .github/workflows/main_team6.yml (CI/CD pipeline)
- PROJECT_TEAM_6_FINAL.ipynb (training, EDA, model development)
- nids.py (serving code that loads the model and makes predictions)
- random_forest_model.pkl (serialized model)
- requirements.txt
- README.md
- No separate “src” or “frontend” folder because Streamlit code lives alongside the serve script.

##### README for additional insights
- Tech stack: Python, Pandas/NumPy, Scikit-learn, Matplotlib/Seaborn, Streamlit UI, Azure Web App, GitHub Actions.
- Deployment targets: Azure Web App Services for hosting; GitHub for version control and CI/CD.

##### Putting it all together
- At the center: Azure Web App Hosting
- Contains a container or environment running Streamlit + nids.py
- On the left: End User (Browser)
- Sends HTTP requests to the Streamlit front-end
- On the right: Model artifact store
- random_forest_model.pkl loaded by nids.py
- Above or below: CI/CD pipeline
- GitHub → GitHub Actions → Azure Web App
- Optionally, show the offline training pipeline (Jupyter notebook → Pickle) as a separate branch

## Diagram (Mermaid)

```mermaid
graph TB
    %% User layer
    subgraph "User Layer"
        Browser["User Web Browser"]:::external
    end

    %% Cloud hosting environment
    subgraph "Azure Web App Services" 
        Azure["Azure Web App"]:::cloud
        subgraph "App Container"
            Streamlit["Streamlit App UI"]:::frontend
            Inference["Inference Backend (nids.py)"]:::backend
            ModelFile["Random Forest Model (random_forest_model.pkl)"]:::data
        end
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GitHub["GitHub Repository"]:::external
        subgraph "Repository Code"
            RepoCode["nids.py"]:::backend
            Req["requirements.txt"]:::data
            Readme["README.md"]:::doc
        end
        Actions["GitHub Actions Workflow"]:::ci
    end

    %% Offline training pipeline
    subgraph "Offline Training Pipeline (Batch)"
        Notebook["PROJECT_TEAM_6_FINAL.ipynb"]:::data
        Artifact["random_forest_model.pkl"]:::data
    end

    %% Main flow interactions
    Browser -->|"HTTP Request"| Streamlit
    Streamlit -->|"calls"| Inference
    Inference -->|"loads model"| ModelFile
    Inference -->|"returns prediction"| Streamlit
    Streamlit -->|"renders result"| Browser

    %% CI/CD flow
    GitHub -->|"source code"| RepoCode
    RepoCode --> Actions
    Req --> Actions
    Readme --> Actions
    Actions -->|"deploys"| Azure

    %% Offline training flow
    Notebook -- "serializes model"---> Artifact
    Artifact -- "artifact for inference" ---> ModelFile

    %% Click events
    click RepoCode "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/nids.py"
    click Req "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/requirements.txt"
    click Readme "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/README.md"
    click Actions "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/.github/workflows/main_team6.yml"
    click Notebook "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/PROJECT_TEAM_6_FINAL.ipynb"
    click ModelFile "https://github.com/chinmayee421/network_intrusion_detection_ml/blob/main/random_forest_model.pkl"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef frontend fill:#ccf,stroke:#333,stroke-width:1px
    classDef backend fill:#cfc,stroke:#333,stroke-width:1px
    classDef cloud fill:#cff,stroke:#333,stroke-width:1px
    classDef data fill:#fcf,stroke:#333,stroke-width:1px
    classDef ci fill:#fcc,stroke:#333,stroke-width:1px
    classDef doc fill:#ffc,stroke:#333,stroke-width:1px
```
