# hawkyvan/anti-spam_model_project architecture

> Architecture diagram of the GitHub repository hawkyvan/anti-spam_model_project, 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/hawkyvan/anti-spam_model_project
- Repository: https://github.com/hawkyvan/anti-spam_model_project

## Overview

This project is a data science and machine learning pipeline focused on anti-spam email classification. The core purpose is to parse .eml files, extract relevant email data (sender, recipient, date, text, and spam/ham labels), store the data in a CSV file, perform exploratory data analysis, and train/test several classification models (Logistic Regression, SVM, Neural Network, Bernoulli Naive Bayes).

##### Main components
- Data Sources: The raw email files organized in the “data” directory (with subfolders “ham” and “spam”). These are your unprocessed .eml files.
- Parser Module: Represented by the single file “parser.py”. This module is responsible for scanning the directories, extracting information (sender, recipient, date, text, spam label), and converting the emails into a structured format.
- Data Storage: The output CSV file (eml_dataset.csv) that stores the parsed data. It serves as the central repository for downstream analysis.
- Data Analysis Module: Illustrated by “analysis.ipynb”. This notebook uses the CSV file for performing descriptive statistics, visualizations (for sender frequencies, temporal distributions, etc.), and key insights.
- Machine Learning Module: Depicted by “models.ipynb”. This module contains experiments for training multiple classifiers. It reads the CSV data, performs preprocessing (e.g., vectorization), splits the data into training/testing subsets, tunes hyperparameters, and evaluates model performance.
- Dependency Management: “requirements.txt” can be noted as a configuration artifact indicating the libraries used (e.g., scikit-learn, pandas, numpy, matplotlib, etc.).

##### Relationships and data flow between components
- Optionally, include data feedback loops if subsequent refined datasets are generated from analysis steps.

##### Architectural patterns and technologies
- Use a pipeline (ETL) pattern: Extract (raw .eml files), Transform (parsing and cleaning), and Load (CSV file).
- Modular separation between data preprocessing, exploratory analysis, and model training. Although not a full-stack web application, the separation of concerns is clear from the different notebooks and scripts.
- Labels for the classification models implemented – mention Logistic Regression, SVM, Neural Network (MLP), and Bernoulli Naive Bayes.
- Optionally, reference standard libraries (like scikit-learn for ML, Pandas for data manipulation, and Matplotlib/Seaborn for visualization) near the respective modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Raw Email Data Sources"
        A["Data Sources: ham emails"] 
        B["Data Sources: spam emails"]
    end

    subgraph "ETL Pipeline"
        C["Parser Module (parser.py)"]
        D(("CSV Data Store (eml_dataset.csv)"))
    end

    subgraph "Downstream Analysis"
        E["Exploratory Data Analysis (analysis.ipynb)"]
        F["Machine Learning Module (models.ipynb)"]
    end

    G["Dependencies (requirements.txt)"]

    A -->|"Extract&Parse"| C
    B -->|"Extract&Parse"| C
    C -->|"OutputCSV"| D
    D -->|"DataFlow:EDA"| E
    D -->|"DataFlow:ML"| F
    G -->|"Configures"| C
    G -->|"Configures"| E
    G -->|"Configures"| F

    class A,B source
    class C module
    class D store
    class E,F notebook
    class G config

    classDef source fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef module fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef store fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef notebook fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;

    click A "https://github.com/hawkyvan/anti-spam_model_project/tree/main/data/ham/"
    click B "https://github.com/hawkyvan/anti-spam_model_project/tree/main/data/spam/"
    click C "https://github.com/hawkyvan/anti-spam_model_project/blob/main/parser.py"
    click D "https://github.com/hawkyvan/anti-spam_model_project/blob/main/data/eml_dataset.csv"
    click E "https://github.com/hawkyvan/anti-spam_model_project/blob/main/analysis.ipynb"
    click F "https://github.com/hawkyvan/anti-spam_model_project/blob/main/models.ipynb"
    click G "https://github.com/hawkyvan/anti-spam_model_project/blob/main/requirements.txt"
```
