An intelligent email management system that automatically classifies emails, generates AI-powered responses, schedules meetings, and creates reminders using LLaMA 3.1 and Google APIs.
- Automatic classification into 13+ categories (INFO_REQUEST, MEETING_INVITE, SUPPORT_ISSUE, etc.)
- AI-generated draft responses using Groq LLaMA 3.1
- Tone adjustment with 5 different styles (formal, casual, assertive, friendly, apologetic)
- Smart content summarization for quick email review
- Google Calendar sync for seamless meeting scheduling
- Auto-generated Google Meet links for video conferences
- Calendar reminder creation with popup and email notifications
- Meeting conflict detection and availability checking
- Deadline detection and automatic reminder creation
- Database persistence (SQLite) for email history and analytics
- Web dashboard for unified email and calendar management
- Responsive HTML interface for all devices
| Component | Technology |
|---|---|
| Backend | Flask, Python 3.8+ |
| AI/ML | Groq API, LLaMA 3.1, Mixtral-8x7b |
| Database | SQLAlchemy, SQLite |
| Gmail API, Google OAuth2 | |
| Calendar | Google Calendar API |
| Frontend | HTML5, Bootstrap, Jinja2 |
| Workflow | LangGraph |
π major/ # Root project directory
βββ π .secrets/ # Environment configuration
β βββ settings.json # API keys & email settings
βββ π .venv/ # Python virtual environment
βββ π core/ # Core business logic modules
β βββ __init__.py # Package initialization
β βββ ai_responder.py # LLaMA draft generation engine
β βββ auth.py # Google OAuth2 authentication
β βββ calendar_manager.py # Google Calendar API integration
β βββ config_loader.py # YAML configuration loader
β βββ data_models.py # Pydantic data validation models
β βββ database.py # SQLAlchemy ORM & database operations
β βββ email_classifier.py # 13-category AI email classification
β βββ email_rewriter.py # AI-powered tone adjustment
β βββ email_service.py # Gmail API service layer
β βββ helpers.py # Utility functions & HTML processing
β βββ run_refresh_token.py # OAuth token refresh utility
β βββ token_gen.py # Initial OAuth token generation
β βββ workflow_manager.py # LangGraph workflow orchestration
βββ π data/ # Application data storage
β βββ emails.db # SQLite database (auto-generated)
βββ π scripts/ # Standalone utility scripts
β βββ __init__.py # Package initialization
β βββ authenticate_email.py # Email authentication setup
β βββ schedule_jobs.py # Background task scheduling
β βββ test_single_run.py # Development testing script
βββ π tests/ # Unit & integration tests
βββ π ui/ # Flask web interface
β βββ π static/ # Static assets (CSS, JS, images)
β βββ π templates/ # Jinja2 HTML templates
β β βββ dashboard.html # Unified calendar/reminder dashboard
β β βββ email_actions.html # Email action selection interface
β β βββ email_reminder.html # Reminder creation & management
β β βββ email_respond.html # AI reply composition interface
β β βββ email_schedule.html # Meeting scheduling interface
β β βββ emails.html # Email inbox & classification view
β β βββ index.html # Main application homepage
β β βββ rewrite.html # Tone adjustment interface
β β βββ send.html # Manual email composition
β β βββ settings.html # Application configuration
β βββ __init__.py # UI package initialization
β βββ app.py # Flask application & routing logic
βββ requirements.txt # Python dependencies
- Python 3.8+
- Google Cloud Project with Gmail & Calendar APIs enabled
- Groq API key for AI processing
# 1. Clone the repository
git clone https://github.com/Anil970198/major.git
cd major
# 2. Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Create configuration directory
mkdir .secrets- Google APIs Setup:
- Create a Google Cloud Project
- Enable Gmail API and Google Calendar API
- Create OAuth2 credentials
- Download credentials.json to
.secrets/
- Groq API Setup:
- Sign up at Groq Console
- Generate API key
- Add to settings.json
- Create
.secrets/settings.json:
{
"monitored_email": "your-email@example.com",
"timezone": "Asia/Kolkata",
"groq_api_key": "your-groq-api-key"
}# Run the Flask app to auto-create database tables
python ui.appThe central hub for monitoring email processing status and quick navigation.

Automatically categorized emails with AI-powered classification into 13 different types.

Generate intelligent draft responses with tone adjustment capabilities. Adjust email tone with 5 different styles for professional communication.

Seamless Google Calendar integration with automatic Meet link generation.
Smart deadline detection and reminder creation with calendar integration.

Easy setup of monitored email addresses and system preferences.

Complete overview of meetings, reminders, and scheduled activities.

The system uses Mixtral-8x7b model to classify emails into 13 categories:
- EMAIL (requires response): INFO_REQUEST, QUOTE_PROPOSAL, SUPPORT_ISSUE, FEEDBACK_COMPLAINT, MEETING_INVITE, SCHEDULE_REQUEST, DEADLINE_TASK
- NOTIFY (informational): RESULT, UPCOMING_EVENT, ALERT
- NO (can ignore): SPAM, PROMOTION, SOCIAL
Powered by LLaMA 3.1-8b-instant, the response generator:
- Analyzes email context and intent
- Generates contextually appropriate replies
- Maintains professional tone and structure
- Supports custom tone adjustments
Google Calendar integration provides:
- Meeting scheduling with conflict detection
- Automatic Google Meet link generation
- Reminder creation with multiple notification methods
- Availability checking across date ranges
| Endpoint | Method | Purpose |
|---|---|---|
/ |
GET | Main dashboard |
/emails |
GET | Display classified emails |
/fetch |
POST | Fetch new emails from Gmail |
/email/<id>/respond |
GET | Email response interface |
/email/<id>/schedule |
GET | Meeting scheduling interface |
/email/<id>/generate_draft |
POST | Generate AI draft response |
/email/<id>/rewrite |
POST | Rewrite draft with tone |
/email/<id>/send |
POST | Send email reply |
/email/<id>/schedule_meeting |
POST | Create calendar meeting |
/reminder/<id> |
GET/POST | Reminder management |
/dashboard |
GET | Unified calendar/reminder view |
/settings |
GET/POST | Configuration management |
The system uses 4 main tables:
- Email: Stores email metadata and AI classifications
- Reminder: Deadline tracking and calendar reminders
- Meeting: Scheduled meetings with Google Calendar links
- SentEmail: Log of outgoing email responses
GROQ_API_KEY=your-groq-api-key
GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json# Start Flask development server
cd ui
python app.py
# Access at http://localhost:5000# Run single email processing test
python scripts/test_single_run.py
# Authenticate Gmail access
python scripts/authenticate_email.py- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
Gmail API Authentication:
- Ensure OAuth2 credentials are properly configured
- Check that Gmail API is enabled in Google Cloud Console
- Verify credentials.json is in
.secrets/directory
Groq API Rate Limiting:
- Monitor API usage in Groq Console
- Implement exponential backoff for failed requests
- Consider upgrading to higher tier for production use
Calendar Permission Issues:
- Confirm Google Calendar API is enabled
- Verify OAuth scope includes calendar permissions
- Re-authenticate if calendar access fails
Database Connection:
- Ensure write permissions to
data/directory - Check SQLite database file isn't locked by another process
- Restart Flask app if database schema changes
This project is licensed under the MIT License - see the LICENSE file for details.
- Groq for providing fast AI inference
- Google APIs for Gmail and Calendar integration
- LangGraph for workflow orchestration
- Flask for the web framework




