How aditipatil38/scamdetekt works
Project Type and Purpose
• ScamDetekt is a full-stack data science web application for real-time spam email classification.
• Frontend: simple HTML/CSS (Jinja2 templates).
• Backend: Python Flask server that loads a pickled SVM model and TF-IDF vectorizer for inference.
• Offline pipeline: Jupyter notebooks and a training script to preprocess data, engineer features, train models, and serialize artifacts.
File Structure
• Top-level:
• Notebooks/ — EDA and model comparison experiments
• train_model.py — standalone training script
• requirements.txt, README.md, LICENSE
• app/ directory:
• app.py — Flask application and route definitions
• model/ — serialized artifacts (svm_model.pkl, vectorizer.pkl)
• templates/ — index.html, result.html (Jinja2 views)
• static/ — style.css, images (UI assets)
• scamdetekt/ — UI screenshot examples
Extract Architectural Insights from README
• Text preprocessing: lowercase, punctuation removal, NLTK stopwords
• Feature engineering: TF-IDF unigrams + bigrams (top 3000 features)
• Classification: Support Vector Machine (best balanced performance)
• Persistence: model and vectorizer stored as .pkl files
Main Components
a. User Interface (Browser)
b. Flask Application Server
• HTTP Request Handler (routes in app.py)
• Preprocessing Module (text cleaning)
• Feature Extraction Module (TF-IDF vectorizer)
• Inference Module (SVM model prediction)
c. Model Artifact Store (Pickle files on disk)
d. Offline Training Pipeline
• Data Source (email_spams.csv)
• Preprocessing & Feature Engineering
• Model Trainer (scikit-learn, NLTK)
• Serialization (vectorizer.pkl, svm_model.pkl)
e. (Optional) Development Notebooks
Relationships and Data Flows
• Browser → HTTP POST /predict → Flask Server
• Flask Server → Preprocessing → Cleaned Text
• Cleaned Text → TF-IDF Vectorizer → Feature Vector
• Feature Vector → SVM Model → Prediction
• Prediction → Render result.html → Browser
• Offline: CSV → train_model.py / Notebooks → serialized artifacts → model/
Architectural Patterns and Design Principles
• MVC (Model-View-Controller):
• Model: pickled ML artifacts
• View: Jinja2 templates (HTML/CSS)
• Controller: Flask route handlers
• Separation of Concerns: training vs. inference code is modular
• Single Responsibility: distinct modules for preprocessing, vectorization, and inference