Skip to content

Latest commit

Β 

History

44 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gmail Cleaner

A powerful Node.js application for cleaning and organizing Gmail inboxes through automated rules and batch operations.

License: MIT Node.js Version Gmail API

πŸš€ Features

  • Smart Email Filtering: Advanced query building with Gmail search operators
  • Batch Operations: Archive, delete, or label multiple emails efficiently
  • OAuth2 Authentication: Secure Google account integration
  • Rule-Based Automation: Create custom rules for automatic email management
  • Real-time Dashboard: Monitor email statistics and operations
  • Production Ready: Comprehensive error handling, monitoring, and rate limiting
  • RESTful API: Full API access for programmatic control

πŸ“‹ Table of Contents

⚑ Quick Start

  1. Clone and Install

    git clone https://github.com/NicolasFares/gmail-cleaner
    cd gmail-cleaner
    npm install
  2. Setup Google OAuth

    # Follow the OAuth setup guide
    cp .env.example .env
    # Add your Google OAuth credentials to .env
  3. Run the Application

    npm run dev
  4. Access the Dashboard Open http://localhost:3000 and sign in with your Google account.

πŸ›  Requirements

  • Node.js: v18.0.0 or higher
  • npm: v8.0.0 or higher
  • Google Cloud Account: For Gmail API access
  • Modern Browser: Chrome, Firefox, Safari, or Edge

πŸ“¦ Installation

1. Clone Repository

git clone <repository-url>
cd gmail-cleaner

2. Install Dependencies

npm install

3. Setup Environment

cp .env.example .env

4. Configure Google OAuth

Follow our Google OAuth Setup Guide to:

  • Create a Google Cloud project
  • Enable Gmail API
  • Configure OAuth consent screen
  • Create OAuth 2.0 credentials

5. Generate Session Secret

npm run generate-secret

βš™οΈ Configuration

Environment Variables

Variable Description Example
NODE_ENV Environment mode development
PORT Server port 3000
GOOGLE_CLIENT_ID OAuth client ID your-client-id
GOOGLE_CLIENT_SECRET OAuth client secret your-client-secret
GOOGLE_REDIRECT_URI OAuth redirect URI http://localhost:3000/auth/google/callback
SESSION_SECRET Session encryption key generated-secret
DATABASE_PATH SQLite database path ./data/gmail_cleaner.db
LOG_LEVEL Logging level debug

See .env.example for all available options.

🎯 Usage

Web Interface

  1. Authentication: Sign in with your Google account
  2. Dashboard: View email statistics and system health
  3. Search & Filter: Use advanced Gmail search operators
  4. Batch Operations: Select and apply actions to multiple emails
  5. Rule Management: Create automated rules for email organization

API Access

The application provides a RESTful API for programmatic access:

# Get email statistics
curl http://localhost:3000/api/dashboard/stats

# Search emails
curl http://localhost:3000/api/emails/search?query=from:example.com

# Archive emails
curl -X POST http://localhost:3000/api/emails/archive \
  -H "Content-Type: application/json" \
  -d '{"messageIds": ["id1", "id2"]}'

Command Line Scripts

# Development server with hot reload
npm run dev

# Production server
npm start

# Run tests
npm test

# Code quality checks
npm run lint
npm run format

πŸ“Š Monitoring & Health

The application includes comprehensive monitoring capabilities:

  • Health Checks: /health, /health/detailed, /health/ready, /health/live
  • Metrics: Prometheus-compatible metrics at /health/metrics
  • Alerts: Real-time alerting for system issues
  • Circuit Breakers: Protection for external API calls
  • Rate Limiting: Configurable request limiting

πŸ— Architecture

src/
β”œβ”€β”€ api/                    # API layer
β”‚   β”œβ”€β”€ routes/            # Express route handlers
β”‚   β”œβ”€β”€ middleware/        # Authentication, error handling, monitoring
β”‚   └── schemas/           # Input validation schemas
β”œβ”€β”€ services/              # Business logic
β”‚   β”œβ”€β”€ gmail.service.js   # Gmail API interactions
β”‚   β”œβ”€β”€ auth.service.js    # OAuth authentication
β”‚   β”œβ”€β”€ rules.service.js   # Email filtering rules
β”‚   β”œβ”€β”€ metrics.service.js # Performance monitoring
β”‚   └── alert.service.js   # Alerting system
β”œβ”€β”€ models/                # Data models
β”œβ”€β”€ utils/                 # Utilities (logger, constants)
β”œβ”€β”€ config/                # Configuration files
β”œβ”€β”€ app.js                 # Express app setup
└── index.js              # Server entry point

πŸ”§ Development

Setup Development Environment

# Install dependencies
npm install

# Setup environment
cp .env.example .env
# Configure your .env file

# Start development server
npm run dev

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run specific test suite
npm test -- --testPathPattern=gmail.service

Code Quality

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

# Check formatting
npm run format:check

🚒 Deployment

Production Deployment

  1. Environment Setup

    export NODE_ENV=production
    export PORT=3000
    # Set production environment variables
  2. Database Migration

    # Setup production database (PostgreSQL recommended)
    npm run migrate
  3. Start Application

    npm start

Docker Deployment

# Build image
docker build -t gmail-cleaner .

# Run container
docker run -p 3000:3000 --env-file .env gmail-cleaner

Production Checklist

  • Set NODE_ENV=production
  • Configure production database
  • Update OAuth redirect URIs
  • Enable HTTPS
  • Configure monitoring
  • Set up log rotation
  • Configure backup strategy
  • Review security settings

πŸ“š Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contributing Steps

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ›‘ Security

  • OAuth2: Secure Google account authentication
  • Session Management: Encrypted session storage
  • Input Validation: Comprehensive request validation
  • Rate Limiting: Protection against abuse
  • Audit Logging: Security event tracking
  • Error Handling: Secure error responses

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™‹β€β™‚οΈ Support

πŸ”— Related Resources


Gmail Cleaner - Efficient Gmail inbox management
Made with ❀️ for productive email management

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages