A sophisticated web application that uses artificial intelligence to intelligently clean and organize your Gmail inbox. Built with modern web technologies and designed for optimal user experience.
- Intelligent Email Classification: Uses Google's Gemini AI to analyze email content and suggest cleanup actions
- Smart Cleanup Suggestions: Automatically identifies emails that can be archived, trashed, or deleted
- Context-Aware Recommendations: Considers email content, sender patterns, and user behavior
- OAuth 2.0 Integration: Secure Google authentication with proper token management
- Session Management: Persistent sessions with automatic token refresh
- Privacy-First: Minimal data collection, focusing only on email metadata
- Real-time Sync: Seamless integration with Gmail API
- Bulk Operations: Process multiple emails simultaneously
- Safe Operations: All actions are reversible and respect Gmail's safety features
- Responsive Design: Works perfectly on desktop and mobile devices
- Intuitive UX: Clean, modern interface with clear action buttons
- Real-time Feedback: Toast notifications and loading states for better user experience
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- React Hooks - Modern state management
- Next.js API Routes - Serverless API endpoints
- Google APIs - Gmail and Calendar integration
- GraphQL Mesh - Unified API layer
- MySQL - Relational database
- NextAuth.js - Authentication framework
- OAuth 2.0 - Google authentication
- JWT Tokens - Secure session management
- bcrypt - Password hashing
- Google Gemini AI - Email content analysis
- Natural Language Processing - Email classification
- Contextual Analysis - Smart recommendation engine
- ESLint - Code linting
- TypeScript - Static type checking
- Turbopack - Fast development builds
src/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β β βββ ai/ # AI-powered endpoints
β β βββ auth/ # Authentication routes
β β βββ lib/ # Core business logic
β βββ auth/ # Authentication pages
β βββ globals.css # Global styles
βββ components/ # Reusable UI components
βββ hooks/ # Custom React hooks
βββ types/ # TypeScript type definitions
- Custom NextAuth adapter for MySQL
- OAuth token management with automatic refresh
- Secure session handling
- Gemini AI integration for email analysis
- Intelligent cleanup suggestion generation
- Context-aware email processing
- Real-time email synchronization
- Safe email operations (archive, trash, delete)
- Bulk processing capabilities
- MySQL with GraphQL Mesh
- Optimized queries for email data
- Proper indexing and relationships
- Node.js 18+
- MySQL 8.0+
- Google Cloud Platform account
- Google OAuth credentials
-
Clone the repository
git clone https://github.com/aminmomin2/emailcleaner.git cd emailcleaner -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Configure the following variables:
# Database DATABASE_URL=mysql://user:password@localhost:3306/emailcleaner # Google OAuth GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret # NextAuth NEXTAUTH_SECRET=your_nextauth_secret NEXTAUTH_URL=http://localhost:3000 # Google AI GOOGLE_AI_API_KEY=your_gemini_api_key
-
Set up the database
# Run the schema file mysql -u root -p emailcleaner < src/app/api/model/schema.sql
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
- Create a Google Cloud Project
- Enable Gmail API and Google Calendar API
- Create OAuth 2.0 credentials
- Configure authorized redirect URIs
- Set up Google AI API key
users- User accounts and authenticationuser_emails- Email metadata and contentuser_calendar_events- Calendar event datauser_credentials- OAuth token storage
- Users have many emails and calendar events
- Emails are linked to Gmail provider IDs
- Calendar events are linked to Google Calendar IDs
POST /api/auth/register- User registrationGET /api/auth/[...nextauth]- NextAuth endpoints
POST /api/sync- Initial Gmail syncGET /api/user/sync-state- Check sync statusPOST /api/user/set-synced- Mark user as synced
GET /api/ai/suggest-cleanups- Get cleanup suggestionsPOST /api/ai/generate-cleanups- Generate new suggestionsPOST /api/ai/execute-cleanup- Execute cleanup actions
# Run linting
npm run lint
# Type checking
npm run build
# Development server
npm run dev- OAuth 2.0 - Secure Google authentication
- Token Encryption - Encrypted storage of OAuth tokens
- Session Management - Secure session handling
- Input Validation - All inputs are validated and sanitized
- Rate Limiting - API rate limiting to prevent abuse
- Connect your GitHub repository to Vercel
- Configure environment variables
- Deploy automatically on push
- Build the application:
npm run build - Start the production server:
npm start - Configure reverse proxy (nginx/Apache)
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google APIs - For Gmail and Calendar integration
- NextAuth.js - For authentication framework
- Tailwind CSS - For styling utilities
- Next.js Team - For the amazing React framework
- GitHub: @aminmomin2
- LinkedIn: Amin Momin
- Email: [email protected]
Built with β€οΈ using Next.js, TypeScript, and Google AI