How sourabhr23/spam_sms_detector works
Project type and purpose
• This is a full-stack web application (“Spam SMS Detector”) built in Python using Flask.
• It exposes a UI for end users to submit SMS messages and returns a classification (“spam” vs. “ham”) by invoking a pre-trained NLP model.
File structure
Top-level files and directories:
• Procfile – For Heroku deployment, launches a Gunicorn (WSGI) server pointing at app.py.
• app.py – The Flask application entry point: defines routes, orchestrates request handling.
• preprocessing.py – Houses text‐cleanup and feature‐extraction logic (e.g., tokenization, stopword removal).
• cv-transform.pkl, mnb-model-spam-analysis.pkl – Serialized sklearn artifacts: CountVectorizer and the trained Multinomial Naive Bayes classifier.
• requirements.txt – Lists Python dependencies (Flask, NLTK, sklearn, Gunicorn, etc.).
• static/ – CSS (styles5.css), JavaScript, images for the front end.
• templates/ – Jinja2 HTML templates (layout.html, home.html, result.html).
README for additional insights
• Confirms use of Flask, NLTK, Python 3.6, deployment on Heroku.
• No external databases or message queues—entire state and models are in-memory and on-disk.
a. Main components
1. Client Browser (UI)
2. Heroku Load Balancer (HTTPS endpoint)
3. Gunicorn WSGI Server (Heroku Dyno)
4. Flask Application (app.py)
5. Preprocessing Module (preprocessing.py)
6. Model Artifacts (cv-transform.pkl, mnb-model-spam-analysis.pkl)
7. Templates & Static Assets (templates/, static/)
b. Relationships & data flow
1. Client → (HTTPS) → Heroku Load Balancer
2. Load Balancer → Gunicorn → Flask app route “/” or “/predict”
3. Flask route handler → invoke preprocessing module
4. Preprocessing → transform raw text via CountVectorizer (.pkl)
5. Transformed features → MultinomialNB (.pkl) → classification label
6. Flask → render result.html with label → response back to client
c. Architectural patterns & principles
• Monolithic service with MVC-style separation:
• Model (pretrained .pkl files)
• View (Jinja templates + static CSS)
• Controller (Flask route handlers in app.py)
• Twelve-factor compliance for deployment (Procfile, requirements.txt)
• External dependency injection via pre-serialized artifacts
d. Key technologies & libraries
• Flask + Jinja2 (web framework, templating)
• Gunicorn (WSGI production server)
• scikit-learn (CountVectorizer, MultinomialNB)
• NLTK (text preprocessing)
• Heroku (deployment PaaS, dyno orchestration)
Detail without overcomplication
• Static/templates grouped under a “Frontend assets” boundary.
• You do not need to illustrate every CSS rule—focus on architectural boundaries and data flows.