# manishreddykovvuri/phishing-guard architecture

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

- Interactive diagram: https://gitdiagram.com/manishreddykovvuri/phishing-guard
- Repository: https://github.com/manishreddykovvuri/phishing-guard

## Overview

##### Main Components
- Email Intake: Although there’s no full web framework visible, the file “mail.py” suggests that emails are received or processed here. This component is responsible for handling the incoming email data.
- URL Extraction: The “GetUrls.py” script indicates that URLs are extracted from the email content.
- Phishing Detection Engine: The “detection.py” script uses a machine learning model (stored in “data/model.pkl”) to classify URLs as malicious or benign.
- Utility and Helper Modules: The “helpers” directory includes a set of specialized modules:
- API Authentication (api_auth.py): Likely for validating API requests if the tool is accessed over a network.
- SSL Certificate Helper (get_ssl_certificate.py): Helps in retrieving SSL certificate details.
- Logger (logger.py): Manages logging of application events.
- Models Utility (models.py): Possibly handles model loading, preprocessing, or other related functions.
- Selenium-based URL Redirection (selenium_redirected_url.py): Manages scenarios where URLs may redirect.
- General URL helper functions (url_helper.py): For parsing and validating URLs.
- Data Storage: The “data” directory holds the actual detection model (model.pkl) and an __init__.py to mark it as a package.
- Configuration & Deployment: The existence of “requirements.txt”, “LICENSE”, and “README.md” indicates clear documentation and dependency management, even though deployment scripts are not explicitly shown.

##### Relationships and Data Flows
- The Email Intake component (mail.py) receives or processes email content.
- Next, the GetUrls.py (or similar mechanism embedded within mail.py) extracts any URLs from that content.
- The extracted URLs are then sent to the Detection Engine (detection.py), which utilizes the machine learning model (data/model.pkl) to determine phishing likelihood.
- During detection, various helper modules are employed:
- URL helpers and Selenium functions ensure that URLs are fully resolved before analysis.
- SSL certificate functionalities could be used to cross-check URL security.
- API auth might be used if this detection tool is offered as a service (as hinted by the Cloud-Based mention in the README).
- Logger is used at nearly every stage to record the operation and help with troubleshooting.

##### Architecturally Important Patterns and Principles
- Modular Design: The project is split into distinct Python modules (scripts and helper libraries) each having a defined responsibility.
- Separation of Concerns: Extraction, detection, and auxiliary functionality (logging, API auth, utility functions) are clearly isolated.
- Extendibility: With distinct helper modules, it’s easier to add new features or integrations such as additional threat intelligence sources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Processing Components
    subgraph "Core Processing"
        EI("Email Intake (mail.py)"):::core
        UE("URL Extraction (GetUrls.py)"):::core
        PDE("Phishing Detection Engine (detection.py)"):::core
        ML("ML Model (model.pkl)"):::data
        EI -->|"processes"| UE
        UE -->|"extracts"| PDE
        PDE -->|"loads"| ML
    end

    %% Helper Modules Group
    subgraph "Helper Modules"
        API("API Authentication Helper"):::helper
        SSL("SSL Certificate Helper"):::helper
        LOG("Logging Utility"):::helper
        MU("Models Utility"):::helper
        SEL("Selenium-based URL Redirection Helper"):::helper
        UH("URL Helper Functions"):::helper
    end

    %% Relationships between Detection Engine and Helpers
    PDE -->|"calls"| API
    PDE -->|"verifies"| SSL
    PDE -->|"logs_via"| LOG
    PDE -->|"invokes"| MU
    PDE -->|"handles_redirects"| SEL
    PDE -->|"validates"| UH

    %% Click Events
    click EI "https://github.com/manishreddykovvuri/phishing-guard/blob/main/mail.py"
    click UE "https://github.com/manishreddykovvuri/phishing-guard/blob/main/GetUrls.py"
    click PDE "https://github.com/manishreddykovvuri/phishing-guard/blob/main/detection.py"
    click ML "https://github.com/manishreddykovvuri/phishing-guard/blob/main/data/model.pkl"
    click API "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/api_auth.py"
    click SSL "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/get_ssl_certificate.py"
    click LOG "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/logger.py"
    click MU "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/models.py"
    click SEL "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/selenium_redirected_url.py"
    click UH "https://github.com/manishreddykovvuri/phishing-guard/blob/main/helpers/url_helper.py"

    %% Styling Classes
    classDef core fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef helper fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef data fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
```
