# dineswarkumar/spam_message_detector architecture

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

- Interactive diagram: https://gitdiagram.com/dineswarkumar/spam_message_detector
- Repository: https://github.com/dineswarkumar/spam_message_detector

## Overview

Spam Shield is a prototype message-classification web app and API. A user submits a message through the served frontend; the FastAPI endpoint invokes the predictor, which returns a three-class verdict, confidence, and separately reported rule signals. The frontend also presents safety guidance and Indian fraud-reporting channels. The repository includes an offline corpus-assembly and model-training branch. The runtime calls are supported by excerpts; frontend guidance and reporting capabilities are documented in the README, while their implementation details were not sampled.

Main entry points: [`design/index.html`](https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html) (Web app), [`backend/predictor.py`](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/predictor.py) (Inference predictor), [`backend/main.py`](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/main.py) (FastAPI endpoints), [`backend/guards.py`](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/guards.py) (Context guards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Web app<br/>[index.html]"]
  node_safety["Safety guidance<br/>[index.html]"]
  node_reporting["Fraud reporting channels<br/>[index.html]"]
end

subgraph group_service["Prediction service"]
  node_api["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_model["Model and rules"]
  node_predictor["Inference predictor<br/>[predictor.py]"]
  node_classifier["Trained classifier<br/>[model.joblib]"]
  node_rules["Fraud rule signals<br/>[predictor.py]"]
  node_guards["Context guards<br/>[guards.py]"]
  node_metadata["Model metadata<br/>[metadata.json]"]
end

subgraph group_offline["Corpus and training"]
  node_corpus["Corpus assembly<br/>[build_corpus.py]"]
  node_training["Model training<br/>[train.py]"]
end

node_user(("Message checker user"))

node_user -->|"submits message"| node_frontend
node_frontend -->|"requests prediction"| node_api
node_api -->|"invokes"| node_predictor
node_predictor -->|"loads and predicts"| node_classifier
node_predictor -->|"uses guards"| node_guards
node_predictor -.->|"loads metadata"| node_metadata
node_frontend -->|"presents"| node_safety
node_frontend -->|"presents"| node_reporting
node_corpus -->|"uses guards"| node_guards

click node_frontend "https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html"
click node_safety "https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html"
click node_reporting "https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html"
click node_api "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/main.py"
click node_predictor "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/predictor.py"
click node_classifier "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/artifacts/model.joblib"
click node_rules "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/predictor.py"
click node_guards "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/guards.py"
click node_metadata "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/artifacts/metadata.json"
click node_corpus "https://github.com/dineswarkumar/spam_message_detector/blob/main/scripts/build_corpus.py"
click node_training "https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/train.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_frontend,node_safety,node_reporting,node_user toneBlue
class node_api toneAmber
class node_predictor,node_classifier,node_rules,node_guards,node_metadata toneMint
class node_corpus,node_training toneRose
```

## Components

### Web experience

- [Web app](https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html): `design/index.html`
- [Safety guidance](https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html): `design/index.html`
- [Fraud reporting channels](https://github.com/dineswarkumar/spam_message_detector/blob/main/design/index.html): `design/index.html`

### Prediction service

- [FastAPI endpoints](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/main.py): `backend/main.py`

### Model and rules

- [Inference predictor](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/predictor.py): `backend/predictor.py`
- [Trained classifier](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/artifacts/model.joblib): `backend/artifacts/model.joblib`
- [Fraud rule signals](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/predictor.py): `backend/predictor.py`
- [Context guards](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/guards.py): `backend/guards.py`
- [Model metadata](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/artifacts/metadata.json): `backend/artifacts/metadata.json`

### Corpus and training

- [Corpus assembly](https://github.com/dineswarkumar/spam_message_detector/blob/main/scripts/build_corpus.py): `scripts/build_corpus.py`
- [Model training](https://github.com/dineswarkumar/spam_message_detector/blob/main/backend/train.py): `backend/train.py`

### Other components

- **Message checker user**

## Connections

- Message checker user → Web app: submits message (evidence: `README.md`)
- Web app → FastAPI endpoints: requests prediction (evidence: `backend/main.py`)
- FastAPI endpoints → Inference predictor: invokes (evidence: `backend/main.py`)
- Inference predictor → Trained classifier: loads and predicts (evidence: `backend/predictor.py`)
- Inference predictor → Context guards: uses guards (evidence: `backend/predictor.py`)
- Inference predictor → Model metadata: loads metadata
- Web app → Safety guidance: presents (evidence: `README.md`)
- Web app → Fraud reporting channels: presents (evidence: `README.md`)
- Corpus assembly → Context guards: uses guards (evidence: `backend/guards.py`)
