Deep Learning–Driven Email Cleaner for Gmail
Sweep ’n Spam is a Chrome Extension designed to help users achieve Inbox Zero by automatically identifying and removing low-priority emails such as promotions, newsletters, and spam. Instead of relying on heuristic rules or keyword matching, the system uses a fine-tuned DistilBERT classifier to perform contextual email classification, enabling reliable separation of important and unimportant messages.
This project is a demonstration of how modern NLP deep learning models can be integrated into real-world consumer software through a local, privacy-preserving architecture.
Uses a fine-tuned DistilBERT model to classify emails as Important or Unimportant based on semantic context rather than surface-level keywords.
All model inference runs locally via a Python backend. Email content is never transmitted to external servers, ensuring full user data privacy.
Efficiently scans and classifies large batches of emails, enabling one-click cleanup of inbox clutter.
Delivered through a Chrome Side Panel interface for seamless interaction within Gmail.
Chrome Extension (Manifest V3), HTML5, CSS3, JavaScript
Python 3.x, FastAPI
PyTorch, Hugging Face Transformers (DistilBERT), Scikit-learn
Follow these steps to set up the project locally.
git clone https://github.com/Sattei/Sweep-N-Spam cd sweep-n-spam
The backend is responsible for running the trained classification model and exposing REST endpoints.
-
Navigate to the backend directory: cd backend
-
Install the required libraries: pip install -r requirements.txt
-
IMPORTANT: Download the Model The trained model file is too large for GitHub, so you must download it separately.
- Download Link: https://drive.google.com/drive/folders/1wpnXBwCb4dVeyRNi58EWVOTOJ9_ZyqXy?usp=drive_link
- Download the file (likely named email_classifier_pytorch).
- Place it directly inside the
backend/folder.
-
Start the server: uvicorn app.main:app --reload
You should see a message saying the server is running at http://127.0.0.1:8000.
NOTE: Google client id must be generated from the Google Console and linked with the extension's local id for Google OAuth.
- Open Google Chrome and go to
chrome://extensions. - Enable Developer Mode using the toggle in the top-right corner.
- Click the Load Unpacked button in the top-left.
- Select the
extensionfolder from this repository. - The extension is now installed and ready to use.
- Start the Backend: Ensure your Python server is running (
python app.py). - Open Gmail: Go to your Gmail tab in Chrome.
- Open the Side Panel: Click the extension icon and select "Open Side Panel".
- Login: Click the "Login" button to authorize Gmail access.
- Scan: Click "Scan New (50)" to analyze your latest emails.
- Clean: The AI will check the boxes for junk mail automatically. Review the list, then click "Move Selected to Trash".
sweep-n-spam/
├── backend/ # Python FastAPI Server
│ ├── app.py # API Endpoints
│ ├── model.py # Model Class Definition
│ ├── spam_classifier.pth # Trained Model (download separately)
│ └── requirements.txt # Python dependencies
│
├── extension/ # Chrome Extension Files
│ ├── manifest.json # Config & Permissions
│ ├── sidepanel.html # UI Layout
│ ├── sidepanel.js # Frontend Logic
│ └── icons/ # App Icons
│
└── README.md # Project Documentation