Skip to content

Cleans up Gmail by unsubscribing and deleting emails in bulk

Notifications You must be signed in to change notification settings

AustinBao/MailSweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

165 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฌ MailSweep - Gmail Inbox Cleanup Made Easy

A smart Gmail assistant that scans your inbox, identifies subscriptions, and helps you bulk unsubscribe or delete emails with a single click.

๐ŸŸข Live at: https://mailsweep.xyz

๐Ÿš€ What MailSweep Does

MailSweep is a full-stack productivity app that gives users control over a cluttered inbox by detecting subscriptions and enabling instant clean-up.

๐Ÿ’ก The Problem It Solves

  • Gmail inboxes are often flooded with unwanted marketing emails and subscriptions
  • Unsubscribing manually is slow and inconsistent across different senders
  • Gmail doesn't provide a good interface to bulk unsubscribe by sender

๐ŸŽฏ The Solution

  • Sender Clustering: Groups emails by sender to simplify decisions

  • Smart Scan Engine: Detects and tracks subscriptions automatically

  • Bulk Delete API: Instantly removes all emails from selected senders

  • Safe Unsubscribe: Marks sender as unsubscribed without triggering links

  • Session Persistence: Resumes scans where you left off


๐ŸŒŸ Key Features

๐Ÿงต Simple Email Parsing

"From: Amazon Deals" โ†’ 340 emails found โ†’ Bulk Delete or Unsubscribe
"From: Newsletter Weekly" โ†’ Unsubscribe link detected

โš™๏ธ Progressive Gmail Scanning

Batch 1: 100 threads
Batch 2: 100 threads
...
  • Fetches Gmail threads in batches to avoid rate limits

๐Ÿ’พ Resume Scan from Last Session

{
  "lastScanTimestamp": "1750614941"
}
  • Stored as Unix timestamp for simplicity, easy comparison, and timezone consistency (always UTC)

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React.js - Component-based UI with state hooks
  • Bootstrap - Responsive layout with prebuilt components
  • Axios โ€“ Handles Gmail API calls and backend communication

Backend

  • Express.js - Lightweight, fast server framework
  • Passport.js - Secure Google OAuth2 authentication
  • Gmail API โ€“ Email reading, deletion, and metadata fetching
  • Supabase โ€“ PostgreSQL storage with RESTful access

๐Ÿ“ Project Structure

๐ŸŽจ Frontend (frontend/)

public/                 # Static assets like images
src/
โ”œโ”€โ”€ components/         # React components (buttons, cards, modals, etc.)
โ”œโ”€โ”€ css/                # Stylesheets and custom CSS files
โ”œโ”€โ”€ App.jsx             # Main React app component with routing
โ”œโ”€โ”€ Home.jsx            # Homepage UI and inbox summary
โ”œโ”€โ”€ Login.jsx           # Login page with Google OAuth
โ”œโ”€โ”€ main.jsx            # React entry point and render logic
โ”œโ”€โ”€ PrivacyPolicy.jsx   # Privacy policy page component
โ”œโ”€โ”€ TermsOfService.jsx  # Terms of service page component

๐Ÿง  Backend (backend/)

config/                 # Configuration files (e.g., DB, OAuth)
routes/
โ”œโ”€โ”€ auth.js             # Authentication routes and logic
โ”œโ”€โ”€ gmail.js            # Gmail API integration and inbox scanning
โ”œโ”€โ”€ mailcounter.js      # Counting emails per sender and tracking stats
โ”œโ”€โ”€ picture.js          # Handling sender favicon or image fetching
โ”œโ”€โ”€ subscriptions.js    # Managing subscription detection and unsubscribes
utils/
โ”œโ”€โ”€ index.js            # Utility functions used throughout backend


๐Ÿ”„ How It Works

1. Login via Google OAuth2

Click โ€œLogin with Googleโ€
    โ†“
Authorize read/delete access to Gmail
    โ†“
Redirect to main page with Cookie

2. Inbox Scan Begins

Fetches email threads using Gmail API
    โ†“
Extracts sender metadata and unsubscribe links
    โ†“
Updates visual dashboard in real time

3. User Takes Action

Click โ€œUnsubscribeโ€ โ†’ updates DB to ignore future emails
    โ†“
Click โ€œDelete Allโ€ โ†’ uses Gmail batchDelete API
    โ†“
Optionally rescan inbox anytime to fetch new emails since last full scan.

๐Ÿ“Š API Endpoints

Core Endpoints

GET /auth/google
// Redirect to Google login

GET /gmail
// Triggers Gmail inbox scan

PATCH /unsub
// Mark sender as unsubscribed in DB

DELETE /delete
// Bulk delete threads by sender

Example API Usage

router.patch('/unsub', async (req, res) => { 
  const email_id = req.body.email_id;
  await db.query(`UPDATE subscriptions SET is_unsubscribed = $1 WHERE id = $2`, 
    [true, email_id]
  );
  res.status(200).json("Successfully updated is_unsubscribed")
});

๐Ÿ”ฎ Future Enhancements

Technical Improvements:

  • Pagination & Lazy Loading โ€“ Improve performance by loading emails in chunks with page navigation instead of rendering all at once (low priority for now)

Summary & Analytics Dashboard

  • Show users total megabytes of inbox space saved
  • Number of emails deleted
  • Number of subscriptions cancelled

Enhanced Email Card Details:

  • Show when the sender first started emailing (e.g., โ€œFirst seen in 2024โ€)
  • Display the date of the most recent email from that sender
  • Add category tags (e.g., Social Media, Food, Education, etc.)
  • Show how many times the user has starred this senderโ€™s emails

๐Ÿ‘จโ€๐Ÿ’ป About

By: Galileo Kim and Austin Bao

Status: Actively maintained & hosted at https://mailsweep.xyz

About

Cleans up Gmail by unsubscribing and deleting emails in bulk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors