How aadilsalimm/network_attack_detection_miniproject works
Project type + purpose (from README + tree)
This is a single-repo Python prototype that performs real-time DoS detection and mitigation by:
• Capturing live network traffic (Scapy-based capture)
• Running ML inference (scikit-learn model persisted as a .joblib)
• Logging events (SQLite DB file database/db/log.db accessed via database/db_ops.py)
• (Optionally) presenting a web UI (Flask app + Jinja templates + static CSS)
The repo structure indicates a modular monolith (not microservices): clear “modules” by folder, wired together by app.py.
Orchestration / Entry point
• app.py
Likely the main Flask app and/or the runtime orchestrator that triggers capture → predict → mitigate → log, and serves pages.
Network capture
• network_capture/capture.py
Responsible for sniffing packets (Scapy), aggregating flows, or extracting raw stats.
ML prediction
• prediction_module/make_prediction.py
• prediction_module/models/rfClassifier#temp.joblib
Loads the trained model, transforms features, outputs “DoS / benign” (and maybe confidence).
Mitigation
• mitigation/mitigate.py
Persistence / logging
• database/db_ops.py
• database/db/log.db (SQLite file)
Responsible for writing and reading detection/mitigation logs.
Web UI
• templates/home.html, templates/log_page.html
• static/styles/*.css
Flask-rendered UI: likely home/dashboard + log viewer.
Dependencies / environment
• requirements.txt
Flask Web App → Admin Browser (HTML)
Purpose: show module-level structure (very grounded in your repo).
Folder as a component with its key file(s):
• network_capture (capture)
• prediction_module (predict + model loading)
• mitigation (actions)
• database (db_ops + sqlite)
• templates/static (presentation)
• app.py (composition/root)
This is where you add “interfaces” (functions or calls) even if informal:
• capture_packets() / extract_features()
• make_prediction(features)
• mitigate(src_ip, attack_type)
• insert_log(event) / fetch_logs()
Data transformations
• Raw packets (Scapy) → Derived features (pandas/numpy) → Model input vector → Prediction label/score
State + storage
• SQLite file as the single durable state (log.db)
Control flow (real-time loop)
An always-on loop:
• sniff → aggregate window → predict → (if attack) mitigate → log → repeat
UI flow
• Browser requests / → renders home.html
• Browser requests /logs (or similar) → DB read → renders log_page.html
External dependencies
“callouts” (small notes) on relevant components:
• Scapy
• Prediction: scikit-learn + joblib model
• Feature processing: pandas/numpy
• Web: Flask + Jinja templates
• DB: SQLite
This gives maximum clarity and separates concerns cleanly while staying faithful to the codebase structure.
• [ ] Every folder in the tree is represented somewhere (at least Level 2)
• [ ] app.py is explicitly the orchestrator and UI entrypoint (if that’s the case)
• [ ] Model artifact (.joblib) is shown as a dependency of prediction
• [ ] SQLite log.db is shown as the persistent store
• [ ] Mitigation affects an external system boundary (OS/network stack)
• [ ] Data flow includes: packets → features → prediction → mitigation/logging
• [ ] UI pages map to templates (home.html, log_page.html)