Skip to content

PRITAM-TU/AI-Based-Email-Scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AI-Based Email Scheduler 🚀

A comprehensive MERN stack application with AI-powered email scheduling and optimization. Schedule emails, improve content with AI, and track performance analytics.

📋 Project Overview

The AI Email Scheduler is a full-stack web application that allows users to:

  • 📧 Schedule emails for future delivery
  • 🤖 AI-powered text improvement with grammar correction and tone adjustment
  • 📊 Excel contact management for bulk email operations
  • 📈 Analytics dashboard to track email performance
  • Real-time scheduling with automatic email delivery

🏗️ System Architecture

┌─────────────────┐    ┌──────────────────┐    ┌──────────────────┐
│   React.js      │    │   Node.js        │    │   Python Flask   │
│   Frontend      │◄──►│   Backend API    │◄──►│   AI Service     │
│   (Vite)        │    │   (Express.js)   │    │   (Transformers) │
└─────────────────┘    └──────────────────┘    └──────────────────┘
         │                       │
         │                       │
         ▼                       ▼
┌─────────────────┐    ┌──────────────────┐
│   MongoDB       │    │   Nodemailer     │
│   Database      │    │   Email Service  │
└─────────────────┘    └──────────────────┘

🛠️ Tech Stack

Frontend

  • React.js 18 with Vite
  • Tailwind CSS for styling
  • React Router DOM for navigation
  • Axios for API calls
  • React Toastify for notifications
  • SheetJS for Excel file processing

Backend

  • Node.js with Express.js
  • MongoDB with Mongoose ODM
  • JWT for authentication
  • bcryptjs for password hashing
  • Nodemailer for email delivery
  • node-cron for job scheduling

AI Service

  • Python Flask API
  • Hugging Face Transformers
  • PyTorch for model inference
  • Grammar correction and tone optimization

🚀 Quick Start

Prerequisites

  • Node.js 16+
  • Python 3.8+
  • MongoDB
  • Git

1. Clone the Repository

git clone <repository-url>
cd "AI-Based Email Scheduler"

2. Frontend Setup

# Navigate to frontend
cd client

# Install dependencies
npm install

# Start development server
npm run dev

Frontend will run on http://localhost:3000

3. Backend Setup

# Navigate to backend (new terminal)
cd server

# Install dependencies
npm install

# Create .env file and configure
cp .env.example .env

# Start backend server
npm run dev

Backend will run on http://localhost:5000

4. AI Service Setup

# Navigate to AI service (new terminal)
cd ai-email-service

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Start AI service
python run.py

AI Service will run on http://localhost:5001

⚙️ Environment Configuration

Backend (.env)

NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/email_scheduler
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRE=7d

# Email Configuration (Gmail example)
EMAIL_SERVICE=gmail
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=[email protected]
EMAIL_PASS=your_app_password

FRONTEND_URL=http://localhost:3000
AI_SERVICE_URL=http://localhost:5001/api

AI Service (.env)

FLASK_ENV=development
PORT=5001
HOST=0.0.0.0
MODEL_CACHE_DIR=./model_cache
CORS_ORIGINS=http://localhost:3000
RATE_LIMIT=100 per day

📧 Email Configuration

Gmail Setup

  1. Enable 2-factor authentication
  2. Generate App Password:
    • Go to Google Account → Security
    • Enable 2-Step Verification
    • Generate App Password
    • Use the 16-character password in EMAIL_PASS

Other Email Providers

Update the email configuration in backend .env:

EMAIL_SERVICE=outlook
EMAIL_HOST=smtp.office365.com
EMAIL_PORT=587

🎯 Features

🔐 Authentication

  • User registration and login
  • JWT-based authentication
  • Protected routes
  • Password hashing with bcrypt

📨 Email Management

  • Compose: Rich text email composition
  • Schedule: Future delivery scheduling
  • Contacts: Excel-based contact management
  • Templates: AI-improved email templates

🤖 AI-Powered Features

  • Grammar Correction: Automatic grammar and spelling fixes
  • Tone Adjustment: Professional, friendly, formal, casual tones
  • Content Optimization: AI-suggested improvements
  • Multi-tone Suggestions: Compare different writing styles

📊 Analytics & Reporting

  • Delivery success rates
  • Open and click tracking
  • Performance metrics
  • Scheduled vs sent analytics

⚡ Advanced Features

  • Bulk Operations: Send to multiple contacts
  • Excel Integration: Import/export contact lists
  • Real-time Status: Live email delivery status
  • Error Handling: Comprehensive error management

🗂️ Project Structure

AI-Based Email Scheduler/
├── client/                 # React Frontend
│   ├── src/
│   │   ├── components/     # Reusable components
│   │   ├── pages/         # Page components
│   │   ├── context/       # React context
│   │   ├── utils/         # Utilities and API
│   │   └── hooks/         # Custom hooks
│   └── package.json
├── server/                # Node.js Backend
│   ├── controllers/       # Route controllers
│   ├── models/           # MongoDB models
│   ├── routes/           # API routes
│   ├── services/         # Business logic
│   ├── middleware/       # Custom middleware
│   └── server.js
└── ai-email-service/     # Python AI Service
    ├── app/
    │   ├── models/       # AI model wrappers
    │   ├── services/     # Text processing services
    │   └── utils/        # Helper functions
    └── run.py

🎨 UI/UX Features

  • Responsive Design: Works on desktop, tablet, and mobile
  • Dark/Light Mode: Theme support (ready for implementation)
  • Real-time Updates: Live dashboard updates
  • Intuitive Navigation: Sidebar-based navigation
  • Loading States: Smooth loading indicators
  • Error Boundaries: Graceful error handling

🔌 API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user
  • PUT /api/auth/updatepassword - Update password

Email Management

  • POST /api/emails/schedule - Schedule new emails
  • GET /api/emails/scheduled - Get scheduled emails
  • DELETE /api/emails/scheduled/:id - Cancel scheduled email
  • GET /api/emails/analytics - Get email analytics
  • POST /api/emails/upload-contacts - Upload Excel contacts

AI Services

  • POST /api/improve-text - Improve text with AI
  • POST /api/check-grammar - Grammar check
  • POST /api/suggest-tone - Get tone suggestions

🤖 AI Models Used

Grammar Correction

  • Model: vennify/t5-base-grammar-correction
  • Purpose: Fix grammatical errors and improve sentence structure

Tone Analysis

  • Model: cardiffnlp/twitter-roberta-base-sentiment-latest
  • Purpose: Analyze and adjust email tone

Text Paraphrasing

  • Model: t5-small
  • Purpose: Rephrase content for different tones

🚀 Deployment

Frontend (Vercel/Netlify)

npm run build
# Deploy dist/ folder to your hosting service

Backend (Railway/Heroku)

# Set environment variables in hosting platform
# Deploy server/ directory

AI Service (Railway/DigitalOcean)

# Install Python dependencies
# Set environment variables
# Deploy ai-email-service/ directory

🧪 Testing

Frontend Testing

cd client
npm test

Backend Testing

cd server
npm test

API Testing

Use the provided Postman collection or test with curl:

# Test health endpoint
curl http://localhost:5000/api/health

# Test AI service
curl -X POST http://localhost:5001/api/improve-text \
  -H "Content-Type: application/json" \
  -d '{"text": "test email content", "tone": "professional"}'

🔒 Security Features

  • JWT Authentication: Secure token-based auth
  • Password Hashing: bcrypt password security
  • Input Validation: Server-side validation
  • CORS Protection: Configured CORS policies
  • Rate Limiting: API rate limiting
  • XSS Protection: Input sanitization
  • Helmet.js: Security headers

📈 Performance Optimizations

  • React Lazy Loading: Code splitting for faster loads
  • Image Optimization: Optimized assets
  • API Caching: Intelligent caching strategies
  • Database Indexing: Optimized MongoDB queries
  • Model Caching: AI model caching for faster inference

🐛 Troubleshooting

Common Issues

  1. Email Not Sending

    • Check email configuration in .env
    • Verify app password for Gmail
    • Check SMTP settings for other providers
  2. AI Service Not Working

    • Verify Python dependencies
    • Check model download permissions
    • Ensure sufficient RAM for models
  3. Database Connection Issues

    • Verify MongoDB is running
    • Check connection string in .env
    • Ensure network connectivity

Debug Mode

Enable debug mode by setting:

NODE_ENV=development
FLASK_DEBUG=True

🤝 Contributing

  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

📄 License

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

🙏 Acknowledgments

  • Hugging Face for transformer models
  • MongoDB for database services
  • React & Node.js communities
  • Tailwind CSS for styling utilities

📞 Support

For support and questions:


Built with ❤️ using MERN Stack & AI Technologies


⭐ Don't forget to star this repository if you find it helpful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors