# phishing-detection-system/detection-chrome-extension architecture

> Architecture diagram of the GitHub repository phishing-detection-system/detection-chrome-extension, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phishing-detection-system/detection-chrome-extension
- Repository: https://github.com/phishing-detection-system/detection-chrome-extension

## Overview

##### Main Components
a. Data Collection & Storage:
- Main_dataset.csv: the raw dataset acquired from Kaggle.
- Phishing Websites Features.docx: documentation on domain-specific features.
b. Feature Engineering Module:
- featureExtraction.py and feature_extraction.py: scripts that transform raw data into engineered features.
- phishing_feature_engg.csv: the resulting feature dataset.
c. Model Development & Evaluation Module:
- Detecting_phishing_websites.ipynb: the notebook that orchestrates model training, testing, and hyperparameter tuning.
- Visualization_Lux_Phishing_Sites_Detection.ipynb: notebook for data visualization using Lux.
- phishing_classifier.pkl: the saved final XGBoost model.
d. API/Integration & Extension Component:
- api.py: could be used for serving the model or interfacing with external systems.
- Extension folder (manifest.json, popup.html, popup.js, style.css): contains files for a browser extension that can integrate with the classifier to warn users about phishing websites.
e. Environment & Dependencies:
- requirements.txt: lists necessary Python packages.
- .gitignore, __pycache__: standard development files which are less important from an architectural view.

##### Out Relationships and Data Flow
- The output (phishing_feature_engg.csv) is then used by the notebook and/or API scripts for training several ML models.
- After evaluation and tuning (as indicated in the Detecting_phishing_websites.ipynb), the best model (XGBoost) is saved as phishing_classifier.pkl.
- In parallel, the visualization notebook uses the feature set to generate insights and correlation plots.
- The API layer (api.py) and Extension directory indicate a future (or partial) integration where a browser extension may communicate with the back-end model to analyze URLs in real time.

##### Architectural Patterns and Design Principles
- Clearly separate data pre-processing/feature engineering from the model training phase.
- Use a modular design: distinct components for data preparation, training, evaluation, and extension integration.
- That the extension is intended to serve as a client interface – potentially a separate microservice component (accessing the classification model via the API).

##### Relevant Technologies and Frameworks
- Python and Jupyter Notebooks are used for experimentations and model training.
- Libraries such as scikit-learn, numpy, pandas, xgboost and visualization tools (Lux, matplotlib, seaborn) play a role in processing and evaluating data.
- The pickle module is used for persisting the trained model.
- The Extension folder indicates web technologies (HTML, CSS, JavaScript) which may integrate with a browser for real-time detection.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        d1["Main_dataset.csv"]:::data
        d2["Phishing Websites Features.docx"]:::data
    end

    %% Feature Engineering Layer
    subgraph "Feature Engineering"
        fe1["featureExtractor.py"]:::processing
        fe2["feature_extraction.py"]:::processing
        fe3["phishing_feature_engg.csv"]:::data
    end

    %% Model Training & Evaluation Layer
    subgraph "Model Training & Evaluation"
        m1["Detecting_phishing_websites.ipynb"]:::ml
        m2["Visualization_Lux_Phishing_Sites_Detection.ipynb"]:::ml
        m3["phishing_classifier.pkl"]:::data
    end

    %% API / Integration Layer
    subgraph "API / Integration"
        api["api.py"]:::integration
        ext["Browser Extension"]:::integration
    end

    %% Environment & Dependencies
    subgraph "Environment & Dependencies"
        env1["requirements.txt"]:::env
        env2[".gitignore"]:::env
        env3["__pycache__"]:::env
    end

    %% Connections: Data Layer to Feature Engineering
    d1 -->|"raw_data"| fe1
    d2 -->|"raw_data"| fe1
    d1 -->|"raw_data"| fe2
    d2 -->|"raw_data"| fe2
    fe1 -->|"generate_features"| fe3
    fe2 -->|"generate_features"| fe3

    %% Connections: Feature Engineering to Model Training
    fe3 -->|"input_features"| m1
    fe3 -->|"input_features"| m2
    m1 -->|"trained_model"| m3

    %% Connections: Model Serving & Extension
    m3 -->|"served_model"| api
    api -->|"API_calls"| ext

    %% Styling
    classDef data fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef processing fill:#ABEBC6,stroke:#239B56,stroke-width:2px;
    classDef ml fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef integration fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef env fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;

    %% Click Events
    click d1 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/Main_dataset.csv"
    click d2 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/Phishing Websites Features.docx"
    click fe1 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/featureExtractor.py"
    click fe2 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/feature_extraction.py"
    click fe3 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/phishing_feature_engg.csv"
    click m1 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/Detecting_phishing_websites.ipynb"
    click m2 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/Visualization_Lux_Phishing_Sites_Detection.ipynb"
    click m3 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/phishing_classifier.pkl"
    click api "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/api.py"
    click ext "https://github.com/phishing-detection-system/detection-chrome-extension/tree/main/Extension/"
    click env1 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/requirements.txt"
    click env2 "https://github.com/phishing-detection-system/detection-chrome-extension/blob/main/.gitignore"
    click env3 "https://github.com/phishing-detection-system/detection-chrome-extension/tree/main/__pycache__"
```
