Skip to content

Project AI Email Processor. - #1

Open
KaranKumar2326 wants to merge 20 commits into
cargoaio:mainfrom
KaranKumar2326:main
Open

Project AI Email Processor.#1
KaranKumar2326 wants to merge 20 commits into
cargoaio:mainfrom
KaranKumar2326:main

Conversation

@KaranKumar2326

Copy link
Copy Markdown

AI Email Processing System - Hackathon Submission 📧✨

🎯 Solution Overview

I've developed a comprehensive AI-powered email processing pipeline that transforms raw email files into actionable insights through intelligent summarization and advanced attachment parsing. The system handles multiple email formats (.eml, .msg) and leverages AI to provide structured summaries of email content and attachments.

🚀 Live Demo

Deployed Application: https://intern-hackathon-2025.onrender.com/

🏗️ Implementation Approach

graph TB
    A[Email File Upload] --> B[Email Parser]
    B --> C{Email Type}
    C -->|.eml| D[EML Parser]
    C -->|.msg| E[MSG Parser]
    D --> F[Extract Metadata]
    E --> F
    F --> G[Extract Body Content]
    G --> H[Extract Attachments]
    H --> I{Attachment Type}
    I -->|PDF| J[PDF Text Extractor]
    I -->|DOCX| K[Word Document Parser]
    I -->|Image| L[OCR Text Extraction]
    I -->|Other| M[Base64 Storage]
    J --> N[Compile Email Data]
    K --> N
    L --> N
    M --> N
    N --> O[AI Summarizer]
    O --> P[Groq API Call]
    P --> Q[Generate Summary]
    Q --> R[JSON Response]
    R --> S[Web Interface Display]
    
    style A fill:
    style O fill:#c63939
    style P fill:
    style Q fill:
    style R fill:
    style S fill:
Loading

Core Architecture

  • Multi-format Email Parser: Native support for .eml and Outlook .msg files
  • AI Summarization Engine: Groq API integration with Llama 3 70B model
  • Smart Attachment Processor: Handles PDFs, Word docs, and images with OCR
  • RESTful API Design: Clean endpoints for upload, processing, and results retrieval
  • Web Interface: User-friendly frontend for email upload and result visualization

Key Technical Decisions

  1. Groq API Integration: Chose Llama 3 70B for superior summarization quality
  2. Multi-format Support: Implemented separate parsers for .eml and .msg formats
  3. Intelligent Attachment Processing: Cascading fallback logic for different file types
  4. Rate Limiting: Built-in API rate limiting (1 req/sec) for stability
  5. Error Resilience: Comprehensive error handling throughout the pipeline

📂 Files Added/Modified

Core Components

  • src/web/app.py - Flask application with API endpoints
  • src/email_parser.py - Email parsing logic for .eml/.msg files
  • src/summarizer.py - AI summarization with Groq API integration
  • src/document_processor.py - Universal attachment processor

Frontend & Templates

  • src/web/templates/ - HTML templates for web interface
  • src/web/static/ - CSS and JavaScript assets

Configuration & Deployment

  • requirements.txt - Python dependencies
  • Dockerfile - Container configuration with Tesseract OCR
  • .env.example - Environment variables template
  • README.md - Comprehensive documentation with architecture diagram

🔧 Special Dependencies & Setup

Required API Keys

GROQ_API_KEY=your_groq_api_key_here
SECRET_KEY=your_flask_secret_key

System Dependencies

  • Tesseract OCR (for image text extraction)
  • Python 3.8+
  • Docker (optional, for containerized deployment)

Installation Steps

git clone https://github.com/KaranKumar2326/Intern-Hackathon-2025.git
cd Intern-Hackathon-2025/email-ai-agent
python -m venv venv

# Windows
venv\Scripts\activate

# Linux/macOS  
source venv/bin/activate

pip install -r requirements.txt


Note: For windows, you need to install tesseract ocr manually .

# Running
For Windows : 
python src\web\app.py

For Linux:
python src/web/app.py

🎨 Architecture Flowchart

Added a comprehensive Mermaid flowchart in the README showing the complete data flow:

  • Email file upload → Parser selection → Content extraction
  • Attachment processing → AI summarization → Result display

🧪 Testing & Validation

  • Email Format Testing: Verified with both .eml and .msg samples
  • Attachment Processing: Tested PDF, DOCX, and image file handling
  • API Endpoint Testing: All endpoints tested for proper JSON responses
  • Error Handling: Graceful degradation for unsupported formats
  • Rate Limiting: Confirmed API call throttling works correctly

📊 API Response Format

The system returns structured JSON with:

  • Email metadata (from, subject, date)
  • AI-generated summary with model information
  • Processed attachment content
  • Processing timestamps and status

🌟 Unique Features

  1. Windows-Friendly: Proper MIME handling for Windows email clients
  2. Intelligent OCR: Tesseract integration for image text extraction
  3. Cascading Processors: Multiple fallback strategies for attachment parsing
  4. Live Deployment: Fully functional web application on Render
  5. Comprehensive Documentation: Detailed README with deployment guides

📸 Screenshot/Preview

AI Email Processor Preview


Ready for review! The solution is production-ready with comprehensive error handling, proper documentation, and live deployment verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant