# bhargav813-hub/sms_spam_detection architecture

> Architecture diagram of the GitHub repository bhargav813-hub/sms_spam_detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhargav813-hub/sms_spam_detection
- Repository: https://github.com/bhargav813-hub/sms_spam_detection

## Overview

This is an SMS spam-classification product with a Streamlit dashboard and a reusable prediction API. The principal workflow accepts a message, preprocesses it, transforms it with the fitted TF-IDF vectorizer, and classifies it with the selected model, returning a label and confidence. A separate training workflow cleans the dataset, benchmarks two classifiers, evaluates them, and persists artifacts; the dashboard also supports retraining, evaluation views, and dataset EDA. Training details and dashboard capabilities follow the README; some dashboard internals were not included in the sampled source.

Main entry points: [`app.py`](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py) (Live Classification), [`src/predict.py`](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/predict.py) (Prediction API), [`src/train_model.py`](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py) (Training Pipeline), [`models`](https://github.com/bhargav813-hub/sms_spam_detection/tree/main/models) (Serialized Artifacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User Interface"]
  node_dashboard["Streamlit Dashboard<br/>[app.py]"]
  node_live_infer["Live Classification<br/>[app.py]"]
  node_eval_view["Evaluation Dashboard<br/>[app.py]"]
  node_eda_view["Dataset EDA<br/>[app.py]"]
  node_retrain["Retraining Control<br/>[app.py]"]
end

subgraph group_inference["Inference"]
  node_predictor["Prediction API<br/>[predict.py]"]
  node_preprocess["NLP Preprocessing<br/>[preprocessing.py]"]
end

subgraph group_training["Training"]
  node_dataset[("SMS Dataset<br/>[spam.csv]")]
  node_clean["Data Cleaning<br/>[train_model.py]"]
  node_training_flow["Training Pipeline<br/>[train_model.py]"]
  node_benchmark["Model Evaluation<br/>[train_model.py]"]
end

subgraph group_artifacts["Model Artifacts"]
  node_artifact_store[("Serialized Artifacts")]
  node_vectorizer["TF-IDF Vectorizer"]
  node_classifier["Selected Classifier"]
  node_metrics["Metrics Bundle<br/>[model_metrics.pkl]"]
end

node_user(("Dashboard User"))
node_sms["SMS Message"]

node_user -->|"uses"| node_dashboard
node_sms -->|"submits"| node_live_infer
node_dashboard -->|"dispatches"| node_live_infer
node_live_infer -->|"cleans text"| node_preprocess
node_live_infer -->|"transforms with"| node_vectorizer
node_live_infer -->|"classifies with"| node_classifier
node_live_infer -->|"returns result"| node_user
node_predictor -->|"cleans text"| node_preprocess
node_predictor -->|"transforms with"| node_vectorizer
node_predictor -->|"classifies with"| node_classifier
node_predictor -->|"loads"| node_metrics
node_dashboard -->|"displays"| node_eval_view
node_dashboard -->|"displays"| node_eda_view
node_eval_view -->|"reads"| node_metrics
node_eda_view -->|"reads"| node_metrics
node_dashboard -->|"dispatches"| node_retrain
node_retrain -->|"invokes"| node_training_flow
node_dataset -->|"provides rows"| node_clean
node_training_flow -->|"calls"| node_clean
node_training_flow -->|"preprocesses messages"| node_preprocess
node_training_flow -->|"evaluates candidates"| node_benchmark
node_benchmark -->|"writes artifacts"| node_artifact_store
node_artifact_store -->|"stores"| node_vectorizer
node_artifact_store -->|"stores"| node_classifier
node_artifact_store -->|"stores"| node_metrics

click node_dashboard "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py"
click node_live_infer "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py"
click node_eval_view "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py"
click node_eda_view "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py"
click node_retrain "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py"
click node_predictor "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/predict.py"
click node_preprocess "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/preprocessing.py"
click node_dataset "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/data/spam.csv"
click node_clean "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py"
click node_training_flow "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py"
click node_benchmark "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py"
click node_artifact_store "https://github.com/bhargav813-hub/sms_spam_detection/tree/main/models"
click node_vectorizer "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/tfidf_vectorizer.pkl"
click node_classifier "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/spam_classifier.pkl"
click node_metrics "https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/model_metrics.pkl"

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_dashboard,node_live_infer,node_eval_view,node_eda_view,node_retrain,node_user toneBlue
class node_predictor,node_preprocess toneAmber
class node_dataset,node_clean,node_training_flow,node_benchmark toneMint
class node_artifact_store,node_vectorizer,node_classifier,node_metrics toneRose
class node_sms toneIndigo
```

## Components

### User Interface

- [Streamlit Dashboard](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py): `app.py`
- [Live Classification](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py): `app.py`
- [Evaluation Dashboard](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py): `app.py`
- [Dataset EDA](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py): `app.py`
- [Retraining Control](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/app.py): `app.py`

### Inference

- [Prediction API](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/predict.py): `src/predict.py`
- [NLP Preprocessing](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/preprocessing.py): `src/preprocessing.py`

### Training

- [SMS Dataset](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/data/spam.csv): `data/spam.csv`
- [Data Cleaning](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py): `src/train_model.py`
- [Training Pipeline](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py): `src/train_model.py`
- [Model Evaluation](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/src/train_model.py): `src/train_model.py`

### Model Artifacts

- [Serialized Artifacts](https://github.com/bhargav813-hub/sms_spam_detection/tree/main/models): `models`
- [TF-IDF Vectorizer](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/tfidf_vectorizer.pkl): `models/tfidf_vectorizer.pkl`
- [Selected Classifier](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/spam_classifier.pkl): `models/spam_classifier.pkl`
- [Metrics Bundle](https://github.com/bhargav813-hub/sms_spam_detection/blob/main/models/model_metrics.pkl): `models/model_metrics.pkl`

### Other components

- **Dashboard User**
- **SMS Message**

## Connections

- Dashboard User → Streamlit Dashboard: uses
- SMS Message → Live Classification: submits
- Streamlit Dashboard → Live Classification: dispatches
- Live Classification → NLP Preprocessing: cleans text
- Live Classification → TF-IDF Vectorizer: transforms with
- Live Classification → Selected Classifier: classifies with
- Live Classification → Dashboard User: returns result
- Prediction API → NLP Preprocessing: cleans text
- Prediction API → TF-IDF Vectorizer: transforms with
- Prediction API → Selected Classifier: classifies with
- Prediction API → Metrics Bundle: loads
- Streamlit Dashboard → Evaluation Dashboard: displays
- Streamlit Dashboard → Dataset EDA: displays
- Evaluation Dashboard → Metrics Bundle: reads
- Dataset EDA → Metrics Bundle: reads
- Streamlit Dashboard → Retraining Control: dispatches
- Retraining Control → Training Pipeline: invokes
- SMS Dataset → Data Cleaning: provides rows
- Training Pipeline → Data Cleaning: calls
- Training Pipeline → NLP Preprocessing: preprocesses messages
- Training Pipeline → Model Evaluation: evaluates candidates
- Model Evaluation → Serialized Artifacts: writes artifacts
- Serialized Artifacts → TF-IDF Vectorizer: stores
- Serialized Artifacts → Selected Classifier: stores
- Serialized Artifacts → Metrics Bundle: stores
