# h0t0/dl-based-waf architecture

> Architecture diagram of the GitHub repository h0t0/dl-based-waf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/h0t0/dl-based-waf
- Repository: https://github.com/h0t0/dl-based-waf

## Overview

##### Project type and purpose
- This is a Python‐based machine‐learning toolkit plus a small web dashboard for a DistilRoBERTa–powered WAF (web application firewall) detection system.
- The “dataset” folder holds input CSV logs; the “models” folder contains scripts to train and serialize a DistilRoBERTa model; the README indicates there is a dashboard (likely Flask/Dash) that visualizes or serves predictions.

##### File structure
- Top‐level:
- README.md, requirements.txt, .gitignore
- __pycache__
- dataset/ (raw and generated log CSVs)
- logs/ (proxy_log.log)
- models/
- models/ substructure:
- dataset_distilroberta_testing.py – test harness on dataset
- distilroberta_model_creation.py – training script
- distilroberta_waf_model/ (serialized model files: config.json, merges.txt, model weights folder)
- No explicit frontend folder—dashboard code is presumably top‐level or within models/ or the root.

##### README for additional insights
- Must install via pip –r requirements.txt
- Dashboard requires a .env file with SECRET_KEY for session/security

##### Final advice
- Be exhaustive: break out data ingestion vs model training vs inference vs UI vs logging
- This approach captures the essence of your DistilRoBERTa dashboard system with clear boundaries, interactions, and tech stack details.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Layer"
        DataIngestion["dataset/ (CSV Logs)"]:::data
        ProxyLogs["proxy_log.log"]:::log
    end

    subgraph "Training Layer"
        Preprocess["distilroberta_model_creation.py"]:::compute
        Evaluate["dataset_distilroberta_testing.py"]:::compute
    end

    subgraph "Model Store"
        ModelArtifacts["models/distilroberta_waf_model/"]:::storage
    end

    subgraph "API & Config Layer"
        Config[".env (SECRET_KEY)"]:::config
        APIService["Flask API Service"]:::api
    end

    subgraph "Dashboard/UI"
        Dashboard["Web Dashboard (Flask/Dash)"]:::ui
        User["User Browser"]:::ui
    end

    DataIngestion -->|"reads CSV"| Preprocess
    Preprocess -->|"trains model"| ModelArtifacts
    Evaluate -->|"tests model"| ModelArtifacts
    User -->|"interacts"| Dashboard
    Dashboard -->|"predict() requests"| APIService
    APIService -->|"loads model"| ModelArtifacts
    Config -->|"loads SECRET_KEY"| APIService
    APIService -->|"serves API & UI"| Dashboard
    APIService -->|"logs events"| ProxyLogs

    click DataIngestion "https://github.com/h0t0/dl-based-waf/tree/main/dataset/"
    click ProxyLogs "https://github.com/h0t0/dl-based-waf/blob/main/logs/proxy_log.log"
    click Preprocess "https://github.com/h0t0/dl-based-waf/blob/main/models/distilroberta_model_creation.py"
    click Evaluate "https://github.com/h0t0/dl-based-waf/blob/main/models/dataset_distilroberta_testing.py"
    click ModelArtifacts "https://github.com/h0t0/dl-based-waf/tree/main/models/distilroberta_waf_model/"

    classDef data fill:#FFD700,stroke:#333,stroke-width:1px
    classDef compute fill:#87CEEB,stroke:#333,stroke-width:1px
    classDef storage fill:#98FB98,stroke:#333,stroke-width:1px
    classDef api fill:#FFA07A,stroke:#333,stroke-width:1px
    classDef ui fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef log fill:#F08080,stroke:#333,stroke-width:1px
    classDef config fill:#ADD8E6,stroke:#333,stroke-width:1px
```
