Skip to content

kashiraza01/Email-Cleanup-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“§ Email Deleter β€” because your inbox is a war zone and you're finally winning

okay so I built this thing because I was getting like 200 promo emails a day and I was NOT about to manually unsubscribe from all of them like some kind of animal. so yeah, this is a full-stack Gmail automation service with a cyberpunk dashboard, encrypted backups, and a cron job that silently deletes your digital trash every night while you sleep. you're welcome.

built with: Next.js 19 + React 19 (yes, the new one) Β· Express 5 Β· PostgreSQL Β· Docker Β· Gmail API Β· AES-256-GCM encryption Β· and a concerning amount of caffeine


πŸ“Έ Screenshots

Dashboard Rules Management
Dashboard Rules
Reports Auth Flow
Reports Auth Page

✨ what it does

  • Rule Engine β€” define rules by keyword, sender, or email age. set it and forget it.
  • Cyberpunk Dashboard β€” drag-and-drop rule management, live metrics, the whole vibe
  • Encrypted Reports β€” every deletion run saves an XLSX report encrypted with AES-256-GCM. your data, your keys.
  • Daily Cron β€” runs at midnight by default. your inbox wakes up clean every morning.
  • Secure by default β€” helmet, rate limiting, session hardening, encrypted token storage. not just vibes.

πŸ›‘οΈ Security & Encryption

This project is built with a security-first mindset. Because it handles your Gmail access, I've implemented multiple layers of protection:

  • AES-256-GCM Encryption: All generated reports are encrypted before they hit the disk. I use PBKDF2 with 100,000 iterations for key derivation.
  • Encrypted Local Backups: Your data, your keys. Even if someone gains access to your server files, your email backups are unreadable without your ENCRYPTION_KEY.
  • OAuth 2.0: I used Google's official OAuth flow. Your Google password never touches my servers.
  • Hardened API: Protected by helmet, express-rate-limit, and CSRF protection (where applicable).

πŸ”‘ Step 0 β€” Google OAuth Setup (do this first, trust me)

you need a Google Cloud project with the Gmail API enabled. takes like 5 minutes.

  1. go to console.cloud.google.com and create a new project
  2. navigate to APIs & Services β†’ Library, search for Gmail API, and enable it
  3. go to APIs & Services β†’ OAuth consent screen
    • choose External, fill in the app name + your email
    • add the scope: https://www.googleapis.com/auth/gmail.modify
    • add your own Google account as a Test User (required while in testing mode)
  4. go to APIs & Services β†’ Credentials β†’ Create Credentials β†’ OAuth 2.0 Client ID
    • Application type: Web application
    • Authorized redirect URIs: http://localhost:5555/api/auth/google/callback
  5. copy your Client ID and Client Secret β€” you'll need them in the next step

βš™οΈ Environment Setup

cp .env.example .env

then fill in your .env β€” here's what everything means:

# Google OAuth β€” from Step 0 above
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
GOOGLE_REDIRECT_URI=http://localhost:5555/api/auth/google/callback

# Session β€” just a random string, make it weird
SESSION_SECRET=some_long_random_string_here

# Database
DB_HOST=localhost          # use "db" if running via Docker
DB_PORT=5432
DB_NAME=email_deleter
DB_USER=postgres
DB_PASSWORD=your_password_here

# Encryption Key β€” MUST be exactly 64 hex characters
# generate one: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
ENCRYPTION_KEY=your_64_char_hex_key_here

# URLs
FRONTEND_URL=http://localhost:3067
NEXT_PUBLIC_API_URL=http://localhost:5555/api

# Cron (default: midnight daily β€” change if you're a night owl)
CRON_SCHEDULE="0 0 * * *"

⚠️ lose your ENCRYPTION_KEY and all stored tokens become unreadable. back it up somewhere safe. no, a sticky note doesn't count.


🐳 Option A β€” Docker (recommended, aka the "it works on my machine AND yours" path)

make sure you have Docker + Docker Compose installed, then:

# 1. build and start everything (db + backend + frontend)
make deploy

# 2. seed the database with default rules
make seed

that's it. seriously. Docker handles postgres, migrations, everything.

Service URL
Frontend UI http://localhost:3067
Backend API http://localhost:5555

other useful Docker commands

make up        # start containers (after first build)
make down      # stop containers
make restart   # restart all containers
make logs      # tail logs in real-time
make migrate   # run DB migrations manually
make clean     # nuclear option β€” wipes containers + volumes

or if you're allergic to Makefiles and prefer raw Docker:

docker-compose build --no-cache
docker-compose up -d
docker-compose logs -f
docker-compose down
docker-compose down -v   # also removes the database volume

πŸ’» Option B β€” Local Dev Setup (for contributors / tinkerers)

prerequisites: Node.js 20+, PostgreSQL 15+, npm

Backend

cd backend
npm install

# make sure your .env has DB_HOST=localhost
npm run db:migrate
npm run db:seed
npm dev              # starts with nodemon on port 5555

Frontend

cd frontend
npm install
npm run dev          # starts Next.js on port 3067

Running tests

cd backend
npm test             # jest with coverage
npm run test:watch   # watch mode for when you're in the zone

Linting

npm run lint         # check
npm run lint:fix     # fix (the coward's way, but also the smart way)

πŸ“‚ Project Structure

.
β”œβ”€β”€ backend/          # Express 5 API β€” rules, cron, Gmail integration
β”‚   └── src/
β”‚       β”œβ”€β”€ controllers/
β”‚       β”œβ”€β”€ services/     # the actual brains
β”‚       β”œβ”€β”€ models/       # Sequelize + PostgreSQL
β”‚       └── routes/
β”œβ”€β”€ frontend/         # Next.js 19 + React 19 dashboard
β”‚   └── src/
β”‚       β”œβ”€β”€ app/
β”‚       β”œβ”€β”€ components/
β”‚       └── store/        # Zustand (because Redux is a lot)
β”œβ”€β”€ docs/             # deeper dives if you're into that
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Makefile
└── .env.example

πŸ“š Docs (for when you want the full lore)


🀝 Contributing

PRs welcome! if you find a bug, open an issue. if you fix a bug, you're a legend.

please don't commit your .env file. I'm begging you.


πŸ“„ License

This project is licensed under the MIT License. You are free to use, modify, and fork this code, but please give credit to Kashif Raza by keeping the copyright notice intact in all copies or substantial portions of the software.


built because I was tired of my inbox. now it's someone else's problem too (yours, if you clone this).

About

A full-stack, secure-by-default Gmail automation service with a cyberpunk UI

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors