# abhishekkushare/spam-detection architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekkushare/spam-detection
- Repository: https://github.com/abhishekkushare/spam-detection

## Overview

This educational Flask app takes Twilio credentials from a visitor, validates them, then fetches recent SMS and classifies each message into spam or ham for the inbox. Separate features support optional account registration, contact feedback, and informational pages. The sampled source confirms route ownership and model calls; the README documents the MySQL and Twilio roles. The model-training script is excluded as an offline development workflow, not runtime architecture.

Main entry points: [`app.py`](https://github.com/abhishekkushare/spam-detection/blob/main/app.py) (Flask routes), [`setup_mysql.sql`](https://github.com/abhishekkushare/spam-detection/blob/main/setup_mysql.sql) (User records), [`templates`](https://github.com/abhishekkushare/spam-detection/tree/main/templates) (Pages and inbox), [`model.py`](https://github.com/abhishekkushare/spam-detection/blob/main/model.py) (Text preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_web_routes["Flask routes<br/>[app.py]"]
  node_web_pages["Pages and inbox"]
end

subgraph group_messaging["SMS workflow"]
  node_account_auth["Twilio sign-in<br/>[app.py]"]
  node_twilio["Twilio API"]
  node_message_fetch["Recent message fetch<br/>[app.py]"]
end

subgraph group_persistence["MySQL persistence"]
  node_user_lookup["Account lookup<br/>[app.py]"]
  node_user_store[("User records<br/>[setup_mysql.sql]")]
  node_registration["Registration<br/>[app.py]"]
  node_feedback["Contact feedback<br/>[app.py]"]
  node_feedback_store[("Feedback records<br/>[setup_mysql.sql]")]
end

subgraph group_classification["Spam classification"]
  node_sms_classifier["Message classification<br/>[app.py]"]
  node_text_prep["Text preprocessing<br/>[model.py]"]
  node_keras_model["Saved Keras model"]
end

node_visitor(("Visitor"))

node_visitor -->|"submits requests"| node_web_routes
node_web_routes -->|"renders pages"| node_web_pages
node_web_routes -->|"routes sign-in"| node_account_auth
node_account_auth -->|"looks up SID"| node_user_lookup
node_user_lookup -->|"reads user"| node_user_store
node_account_auth -->|"validates credentials"| node_twilio
node_account_auth -->|"redirects to inbox"| node_web_routes
node_web_routes -->|"requests inbox messages"| node_message_fetch
node_message_fetch -->|"streams messages"| node_twilio
node_message_fetch -->|"classifies each body"| node_sms_classifier
node_sms_classifier -->|"preprocesses text"| node_text_prep
node_sms_classifier -->|"predicts spam score"| node_keras_model
node_web_routes -->|"routes registration"| node_registration
node_registration -->|"writes user"| node_user_store
node_web_routes -->|"routes contact form"| node_feedback
node_feedback -->|"writes feedback"| node_feedback_store

click node_web_routes "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_web_pages "https://github.com/abhishekkushare/spam-detection/tree/main/templates"
click node_account_auth "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_message_fetch "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_sms_classifier "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_text_prep "https://github.com/abhishekkushare/spam-detection/blob/main/model.py"
click node_keras_model "https://github.com/abhishekkushare/spam-detection/tree/main/spam_model"
click node_user_lookup "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_user_store "https://github.com/abhishekkushare/spam-detection/blob/main/setup_mysql.sql"
click node_registration "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_feedback "https://github.com/abhishekkushare/spam-detection/blob/main/app.py"
click node_feedback_store "https://github.com/abhishekkushare/spam-detection/blob/main/setup_mysql.sql"

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_web_routes,node_web_pages toneBlue
class node_account_auth,node_twilio,node_message_fetch toneAmber
class node_user_lookup,node_user_store,node_registration,node_feedback,node_feedback_store toneMint
class node_sms_classifier,node_text_prep,node_keras_model toneRose
class node_visitor toneIndigo
```

## Components

### Web experience

- [Flask routes](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- [Pages and inbox](https://github.com/abhishekkushare/spam-detection/tree/main/templates): `templates`

### SMS workflow

- [Twilio sign-in](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- **Twilio API**
- [Recent message fetch](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`

### MySQL persistence

- [Account lookup](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- [User records](https://github.com/abhishekkushare/spam-detection/blob/main/setup_mysql.sql): `setup_mysql.sql`
- [Registration](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- [Contact feedback](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- [Feedback records](https://github.com/abhishekkushare/spam-detection/blob/main/setup_mysql.sql): `setup_mysql.sql`

### Spam classification

- [Message classification](https://github.com/abhishekkushare/spam-detection/blob/main/app.py): `app.py`
- [Text preprocessing](https://github.com/abhishekkushare/spam-detection/blob/main/model.py): `model.py`
- [Saved Keras model](https://github.com/abhishekkushare/spam-detection/tree/main/spam_model): `spam_model`

### Other components

- **Visitor**

## Connections

- Visitor → Flask routes: submits requests (evidence: `README.md`)
- Flask routes → Pages and inbox: renders pages (evidence: `app.py`)
- Flask routes → Twilio sign-in: routes sign-in (evidence: `app.py`)
- Twilio sign-in → Account lookup: looks up SID (evidence: `app.py`)
- Account lookup → User records: reads user (evidence: `README.md`)
- Twilio sign-in → Twilio API: validates credentials (evidence: `app.py`)
- Twilio sign-in → Flask routes: redirects to inbox (evidence: `app.py`)
- Flask routes → Recent message fetch: requests inbox messages (evidence: `app.py`)
- Recent message fetch → Twilio API: streams messages (evidence: `app.py`)
- Recent message fetch → Message classification: classifies each body (evidence: `app.py`)
- Message classification → Text preprocessing: preprocesses text (evidence: `app.py`)
- Message classification → Saved Keras model: predicts spam score (evidence: `app.py`)
- Flask routes → Registration: routes registration (evidence: `app.py`)
- Registration → User records: writes user (evidence: `README.md`)
- Flask routes → Contact feedback: routes contact form (evidence: `app.py`)
- Contact feedback → Feedback records: writes feedback (evidence: `README.md`)
