# paragdhomne/email-spam-classifier architecture

> Architecture diagram of the GitHub repository paragdhomne/email-spam-classifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paragdhomne/email-spam-classifier
- Repository: https://github.com/paragdhomne/email-spam-classifier

## Overview

This repository is an email spam classifier, with a batch model-development workflow and two user-facing inference paths: a REST API and a Streamlit demo. The documented workflow covers EDA, preprocessing, TF-IDF, model comparison and tuning, error analysis, and model serialization. The checked-in serialized model is loaded directly by both applications. Notebook implementation details were not sampled, so their documented stages and links are based on the README rather than inspected notebook code.

Main entry points: [`notebooks/02_model_training.ipynb`](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb) (SVM tuning), [`app/main.py`](https://github.com/paragdhomne/email-spam-classifier/blob/main/app/main.py) (FastAPI endpoint), [`app/streamlit_app.py`](https://github.com/paragdhomne/email-spam-classifier/blob/main/app/streamlit_app.py) (Streamlit classifier), [`models/spam_classifier_svm.joblib`](https://github.com/paragdhomne/email-spam-classifier/blob/main/models/spam_classifier_svm.joblib) (Serialized SVM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_development["Model Development"]
  node_eda["Exploratory analysis<br/>[01_eda.ipynb]"]
  node_preprocess["Text preprocessing"]
  node_tfidf["TF-IDF features"]
  node_comparison["Model comparison"]
  node_tuning["SVM tuning"]
  node_error["Error analysis"]
  node_artifact[("Serialized SVM")]
end

subgraph group_serving["Classification Serving"]
  node_api["FastAPI endpoint<br/>[main.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_streamlit["Streamlit classifier<br/>[streamlit_app.py]"]
end

node_dataset[("Enron dataset")]
node_api_client(("API client"))
node_streamlit_user(("Demo user"))

node_dataset -->|"analyzed in"| node_eda
node_eda -->|"informs training"| node_preprocess
node_preprocess -->|"transformed into"| node_tfidf
node_tfidf -->|"feeds models"| node_comparison
node_comparison -->|"best model tuned"| node_tuning
node_tuning -->|"evaluated by"| node_error
node_tuning -->|"serialized as"| node_artifact
node_api_client -->|"submits email"| node_api
node_api -->|"loads model"| node_artifact
node_api -->|"returns prediction"| node_api_client
node_streamlit_user -->|"enters email"| node_streamlit
node_streamlit -->|"loads model"| node_artifact
node_streamlit -->|"shows prediction"| node_streamlit_user

click node_eda "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/01_eda.ipynb"
click node_preprocess "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb"
click node_tfidf "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb"
click node_comparison "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb"
click node_tuning "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb"
click node_error "https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb"
click node_artifact "https://github.com/paragdhomne/email-spam-classifier/blob/main/models/spam_classifier_svm.joblib"
click node_api "https://github.com/paragdhomne/email-spam-classifier/blob/main/app/main.py"
click node_streamlit "https://github.com/paragdhomne/email-spam-classifier/blob/main/app/streamlit_app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_eda,node_preprocess,node_tfidf,node_comparison,node_tuning,node_error,node_artifact,node_api_client,node_streamlit_user toneBlue
class node_api,node_dataset toneAmber
class node_streamlit toneMint
```

## Components

### Model Development

- [Exploratory analysis](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/01_eda.ipynb): `notebooks/01_eda.ipynb`
- [Text preprocessing](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb): `notebooks/02_model_training.ipynb`
- [TF-IDF features](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb): `notebooks/02_model_training.ipynb`
- [Model comparison](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb): `notebooks/02_model_training.ipynb`
- [SVM tuning](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb): `notebooks/02_model_training.ipynb`
- [Error analysis](https://github.com/paragdhomne/email-spam-classifier/blob/main/notebooks/02_model_training.ipynb): `notebooks/02_model_training.ipynb`
- [Serialized SVM](https://github.com/paragdhomne/email-spam-classifier/blob/main/models/spam_classifier_svm.joblib): `models/spam_classifier_svm.joblib`

### Classification Serving

- [FastAPI endpoint](https://github.com/paragdhomne/email-spam-classifier/blob/main/app/main.py): `app/main.py`

### User Interfaces

- [Streamlit classifier](https://github.com/paragdhomne/email-spam-classifier/blob/main/app/streamlit_app.py): `app/streamlit_app.py`

### Other components

- **Enron dataset**
- **API client**
- **Demo user**

## Connections

- Enron dataset → Exploratory analysis: analyzed in (evidence: `README.md`)
- Exploratory analysis → Text preprocessing: informs training (evidence: `README.md`)
- Text preprocessing → TF-IDF features: transformed into (evidence: `README.md`)
- TF-IDF features → Model comparison: feeds models (evidence: `README.md`)
- Model comparison → SVM tuning: best model tuned (evidence: `README.md`)
- SVM tuning → Error analysis: evaluated by (evidence: `README.md`)
- SVM tuning → Serialized SVM: serialized as (evidence: `README.md`)
- API client → FastAPI endpoint: submits email (evidence: `README.md`)
- FastAPI endpoint → Serialized SVM: loads model (evidence: `app/main.py`)
- FastAPI endpoint → API client: returns prediction (evidence: `app/main.py`)
- Demo user → Streamlit classifier: enters email (evidence: `app/streamlit_app.py`)
- Streamlit classifier → Serialized SVM: loads model (evidence: `app/streamlit_app.py`)
- Streamlit classifier → Demo user: shows prediction (evidence: `app/streamlit_app.py`)
