No description
| prisma | ||
| src | ||
| .env.example | ||
| .gitignore | ||
| CHANGELOG.md | ||
| next.config.js | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.js | ||
| README.md | ||
| tailwind.config.js | ||
| tsconfig.json | ||
GmailHunt
A production-minded Gmail inbox cleanup SaaS for people with overloaded inboxes.
Features
- Secure Google OAuth - Sign in with your Google account
- Gmail API Integration - Connect and manage your Gmail inbox via official API
- IMAP Fallback - Also supports IMAP connection with App Passwords
- Cleanup Rules - Pre-built rules for newsletters, promotions, receipts, old emails, bills, travel, social media, and shipping
- Preview Mode - See exactly what will happen before any changes
- Bulk Actions - Archive, label, mark read, or move to trash
- Run History - Track all cleanup operations with detailed logs
- Safe by Default - No permanent deletes, trash is disabled by default
Tech Stack
- Next.js 15 with App Router
- TypeScript
- Tailwind CSS
- Prisma ORM
- PostgreSQL
- NextAuth.js with Google OAuth
- Gmail API (googleapis)
Getting Started
Prerequisites
- Node.js 18+
- PostgreSQL database
- Google Cloud Console project with Gmail API enabled (for OAuth)
- Gmail IMAP enabled (for IMAP fallback)
1. Clone and Install
cd gmailhunt
npm install
2. Set Up Environment Variables
Copy .env.example to .env and fill in your values:
cp .env.example .env
Required variables:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_SECRET- Generate withopenssl rand -base64 32NEXTAUTH_URL- http://localhost:3000 (or your production URL)GOOGLE_CLIENT_ID- From Google Cloud ConsoleGOOGLE_CLIENT_SECRET- From Google Cloud Console
3. Set Up Google OAuth
- Go to Google Cloud Console
- Create a new project
- Enable Gmail API
- Configure OAuth consent screen
- Create OAuth credentials (Web application)
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Add authorized JavaScript origins:
http://localhost:3000
For testing, add your test user's email to the OAuth test users list.
4. Set Up Database
# Generate Prisma client
npm run db:generate
# Push schema to database
npm run db:push
5. Run Development Server
npm run dev
Development Login
For local testing without Google OAuth, use the test login at /test-login with any email address that exists in your database.
Project Structure
gmailhunt/
├── prisma/
│ └── schema.prisma # Database schema
├── src/
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── dashboard/ # Authenticated pages
│ │ ├── layout.tsx # Root layout
│ │ ├── page.tsx # Landing page
│ │ └── test-login/ # Dev test login
│ ├── components/ # React components
│ ├── hooks/ # Custom React hooks
│ ├── lib/
│ │ ├── auth.ts # NextAuth config
│ │ ├── db.ts # Prisma client
│ │ ├── gmail.ts # Gmail API service
│ │ └── imap.ts # IMAP fallback service
│ └── types/ # TypeScript types
├── .env.example
├── package.json
├── tailwind.config.js
├── tsconfig.json
└── README.md
Preset Cleanup Rules
The app includes these preset cleanup rules:
- Newsletters - Archives newsletters with "Newsletters" label
- Promotions - Archives promotional emails with "Promotions" label
- Receipts - Labels receipts with "Receipts" label
- Old Inbox (6 months) - Archives emails older than 6 months
- Bills & Statements - Labels bills and financial statements
- Travel Confirmations - Labels travel bookings and reservations
- Social Media Updates - Archives social media notifications
- Shipping Notifications - Labels shipping and delivery updates
Safety Features
- Preview First - Always preview changes before applying
- Archive Only - Default action is archive (removes INBOX label), not delete
- Trash Disabled - Trash must be explicitly enabled in settings
- Action Logging - All actions are logged in the database
- Safe Mode - Configurable safe mode to block destructive actions
- Run History - Full audit trail of all cleanup operations
API Routes
Rules
GET /api/rules- Get user's cleanup rulesGET /api/rules/[id]- Get specific rulePOST /api/rules- Create rulePOST /api/preset-rules- Add preset rule
Runs
GET /api/runs- Get cleanup run historyPOST /api/preview- Preview rule executionPOST /api/apply- Apply rule execution
Connection
GET /api/connection- Get connection statusPOST /api/imap- Connect via IMAPDELETE /api/imap- Disconnect IMAP
Utilities
GET /api/inbox-count- Get current inbox countGET /api/preset-rules- Get available preset rules
Production Deployment
- Set up a PostgreSQL database (e.g., Supabase, Neon, Railway)
- Update
DATABASE_URLin environment - Set
NEXTAUTH_URLto your production domain - Configure Google OAuth with production URLs
- Build and start:
npm run build && npm run start
License
MIT