Skip to content

FastAPI-based AI web app for real-time cyberattack detection using machine learning. Predicts network traffic as Benign or Attack with a trained model, scaler, and dynamic feature input via web UI. Ideal for cybersecurity research and intelligent intrusion detection.

License

Notifications You must be signed in to change notification settings

Saeed-dev2/cyberattack-detector-AI

Repository files navigation

🔐 cyberattack-detector-AI

A FastAPI-based AI web application for real-time cyberattack detection using a trained machine learning model. It provides an interactive web interface for users to input network traffic features and receive live predictions on whether the traffic is Benign or an Attack.


🚀 Features

  • ✅ Built with FastAPI for high-speed performance
  • 🔍 Predicts attacks using a trained scikit-learn model
  • 📈 Uses a StandardScaler for input feature normalization
  • 🧠 Dynamic input form generated from features.pkl
  • 💡 User-friendly web interface with Jinja2 templates
  • 🧪 Robust error handling and form validation

📁 Project Structure

cyberattack-detector-AI/
│
├── main.py               # FastAPI backend
├── model.pkl             # Trained ML model
├── scaler.pkl            # Fitted StandardScaler
├── features.pkl          # List of input features
├── templates/
│   └── index.html        # Web form and result display
├── static/               # CSS or image assets (optional)
└── README.md             # This file

⚙️ Installation & Setup

  1. Clone the repository

    git clone https://github.com/your-username/cyberattack-detector-AI.git
    cd cyberattack-detector-AI
  2. Install required packages

    pip install -r requirements.txt
  3. Run the application

    uvicorn main:app --reload
  4. Access the app Open your browser and go to:
    👉 http://127.0.0.1:8000


📊 How It Works

  1. Loads the ML model, scaler, and feature list.
  2. Renders a form with all required feature fields.
  3. On form submission:
    • Values are collected and scaled.
    • The model makes a prediction.
    • The result is displayed as Benign or Attack.

✅ Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • scikit-learn
  • joblib
  • Jinja2

Install all requirements:

pip install fastapi uvicorn scikit-learn joblib jinja2

📷 Screenshot

(Add your UI screenshot here once available)
Example: App Screenshot


📜 License

This project is licensed under the MIT License


👨‍💻 Author

Muhammad Saeed
AI & Machine Learning & IoT Enthusiast

About

FastAPI-based AI web app for real-time cyberattack detection using machine learning. Predicts network traffic as Benign or Attack with a trained model, scaler, and dynamic feature input via web UI. Ideal for cybersecurity research and intelligent intrusion detection.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published