An intelligent email automation platform powered by AI that transforms how you manage, analyze, and respond to emails.
SmartMail AI is a comprehensive email automation solution that combines the power of modern web technologies with advanced AI language models. It provides a seamless interface for Gmail integration, intelligent email processing, task detection, auto-reply generation, document analysis, and calendar management.
Built for the Sofrecom Tunisia Hackathon, this project demonstrates the potential of AI-driven workflow automation in enterprise email management.
- π€ AI-Powered Analysis: Semantic analysis, sentiment detection, and urgency classification
- π Multi-Language Support: Automatic translation from French to English
- π Smart Attachment Processing: OCR for PDFs and images with text extraction
- π Calendar Integration: Intelligent meeting scheduling with Google Calendar
- π¬ Auto-Reply Generation: Context-aware email responses
- π RAG Question Answering: Ask questions about email content with AI
- π Document Classification: Automatic theme detection and categorization
- β‘ Real-Time Processing: Instant analysis with live status updates
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SmartMail AI Platform β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Frontend ββββββββββββΊβ Backend β β
β β (Next.js 15) β REST β (FastAPI) β β
β β β API β β β
β β ββββββββββββββ β β ββββββββββββββ β β
β β β Gmail UI β β β β LLM Client β β β
β β ββββββββββββββ€ β β ββββββββββββββ€ β β
β β β Email β β β β RAG Engine β β β
β β β Analysis β β β ββββββββββββββ€ β β
β β ββββββββββββββ€ β β β OCR β β β
β β β Calendar β β β β Processor β β β
β β ββββββββββββββ€ β β ββββββββββββββ€ β β
β β β Chatbot β β β β Calendar β β β
β β β Interface β β β β Service β β β
β β ββββββββββββββ β β ββββββββββββββ β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β β β
β β β β
β βΌ βΌ β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Gmail API β β AI Models β β
β β Google Calendar β β - NVIDIA Llama β β
β β NextAuth.js β β - Mistral AI β β
β ββββββββββββββββββββ β - ChromaDB β β
β ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Gmail Integration: Seamless access to your Gmail inbox
- Thread Viewer: Read email conversations with full history
- Smart Filters: Filter by unread, starred, sender, or date
- Search: Powerful search across all emails
- Attachment Viewer: Preview and download attachments
- Semantic Analysis: Understand email intent, tone, and type
- Sentiment Detection: Identify positive, negative, or neutral sentiment
- Urgency Classification: Detect time-sensitive emails automatically
- Task Extraction: Automatically identify action items and to-dos
- Key Points Summary: Get concise summaries of long emails
- Auto-Translation: Convert French emails to English instantly
- Auto-Reply: Generate contextually appropriate responses
- Meeting Detection: Identify meeting proposals in emails
- Calendar Scheduling: Automatically schedule meetings with conflict detection
- Batch Processing: Process multiple emails simultaneously
- OCR Technology: Extract text from PDFs and images (PNG, JPG, JPEG)
- Format Support: Handle TXT, DOCX, PDF, and image files
- Text Extraction: Accurate text recognition with Tesseract OCR
- Metadata Extraction: File size, type, creation date
- RAG (Retrieval-Augmented Generation): Ask questions about email content
- Vector Search: Semantic search using ChromaDB
- Context-Aware Answers: Get accurate answers based on email context
- Document Classification: Automatically categorize documents by theme
- Availability Check: View free time slots for the next 7 days
- Smart Scheduling: Avoid conflicts when booking meetings
- Meeting Analysis: Extract meeting details from email text
- Event Creation: Create Google Calendar events directly
- Conversational AI: Natural language interface for email queries
- Quick Actions: Pre-defined shortcuts for common tasks
- Multi-Turn Conversations: Context-aware dialogue
- Email Insights: Ask questions about your inbox
- Framework: Next.js 15 (App Router)
- Language: TypeScript 5.0
- Authentication: NextAuth.js v5
- Styling: Tailwind CSS
- UI Components: Radix UI, Lucide Icons
- State Management: React Hooks
- API Integration: Native Fetch with custom wrappers
- Framework: FastAPI
- Language: Python 3.8+
- AI Models:
- NVIDIA Llama 3 (8B & 70B Instruct)
- Mistral AI (mistral-small)
- Vector Store: ChromaDB
- Embeddings: HuggingFace (sentence-transformers)
- OCR: Tesseract, OpenCV, pytesseract
- Document Processing: python-docx, PyPDF2
- Calendar: Google Calendar API
- Authentication: Google OAuth 2.0
- APIs: Gmail API, Google Calendar API
- Caching: File-based translation cache
- Database: ChromaDB for vector storage
projet_email_automation/
βββ frontend/ # Next.js frontend application
β βββ src/
β β βββ app/ # Next.js pages (App Router)
β β β βββ page.tsx # Landing page
β β β βββ inbox/ # Gmail inbox pages
β β β βββ api/ # API routes (NextAuth, Gmail proxy)
β β βββ components/ # React components
β β β βββ inbox/ # Email UI components
β β β βββ chatbot/ # Chatbot interface
β β β βββ calendar/ # Calendar widgets
β β β βββ ui/ # Reusable UI elements
β β βββ services/ # API service layer
β β βββ lib/ # Utilities and helpers
β β βββ auth/ # NextAuth configuration
β β βββ types/ # TypeScript definitions
β βββ public/ # Static assets
β βββ .env.local # Environment variables (not in git)
β βββ next.config.js # Next.js configuration
β βββ package.json # Dependencies
β
βββ backend/ # FastAPI backend application
β βββ api/
β β βββ main.py # FastAPI entry point
β β βββ routes/ # API endpoints
β β β βββ email.py # Email processing
β β β βββ attachment.py # Attachment handling
β β β βββ calendar.py # Calendar integration
β β β βββ rag.py # RAG Q&A
β β β βββ classification.py # Document classification
β β βββ models/ # Pydantic models
β βββ modules/ # Core business logic
β β βββ llm_client.py # AI model client
β β βββ rag_processor.py # RAG engine
β β βββ attachment_processor.py # OCR & file processing
β β βββ calendar_service.py # Google Calendar service
β βββ config/
β β βββ .env # Backend environment variables
β β βββ client_secret.json # Google OAuth credentials
β βββ data/ # Data storage
β β βββ translation_cache/ # Cached translations
β β βββ chroma_db_api/ # RAG vector store
β β βββ chroma_db_classification/ # Classification vectors
β βββ requirements.txt # Python dependencies
β βββ tests/ # Test suites
β
βββ README.md # This file
- Node.js 18+ and npm/yarn
- Python 3.8+
- Tesseract OCR (for attachment processing)
- Google Cloud Project with Gmail & Calendar APIs enabled
git clone https://github.com/your-username/projet_email_automation.git
cd projet_email_automationcd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtCreate backend/config/.env:
# AI Models
NVIDIA_API_KEY_LLAMA3_8B=your_nvidia_api_key_8b
NVIDIA_API_KEY_LLAMA3_70B=your_nvidia_api_key_70b
CLOUD_ADAPTER_API_KEY=your_mistral_api_key
MISTRAL_MODEL=mistral-small
# Optional: Local Llama
LOCAL_LLAMA_API_BASE_URL=http://localhost:11434
LOCAL_LLAMA_MODEL_NAME=llama3python api/main.py
# Backend runs on http://127.0.0.1:8002cd ../frontend
npm installCreate frontend/.env.local:
# Google OAuth
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GMAIL_SCOPES=openid email profile https://www.googleapis.com/auth/gmail.readonly
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-random-secret-32-chars
# Backend API
NEXT_PUBLIC_BACKEND_URL=http://127.0.0.1:8002npm run dev
# Frontend runs on http://localhost:3000- Open http://localhost:3000
- Click "Sign In" and authenticate with Google
- Grant Gmail permissions
- Start using SmartMail AI! π
- Frontend README - Frontend setup, architecture, and usage
- Backend README - Backend API documentation and configuration
- API Documentation - Interactive Swagger UI (when backend is running)
GET /api/gmail/threads- List Gmail threadsGET /api/gmail/threads/[threadId]- Get thread detailsGET /api/gmail/messages/[id]- Get message details
POST /api/translate- Translate emailPOST /api/analyze- Semantic analysisPOST /api/summary- Generate summaryPOST /api/tasks- Detect tasksPOST /api/reply- Generate auto-replyPOST /api/attachment/process- Process attachmentPOST /api/rag/ask- RAG question answeringPOST /api/classification/themes- Classify documentGET /api/calendar/availability- Check availabilityPOST /api/calendar/schedule- Schedule event
- Automatically detect urgent emails
- Classify emails by type (meeting, task, information)
- Filter and sort inbox intelligently
- Translate French emails to English
- Maintain context and tone in translations
- Support for business communication
- Extract action items from emails
- Assign tasks with deadlines
- Track pending work items
- Detect meeting requests in emails
- Check calendar availability
- Schedule meetings automatically
- Avoid double-bookings
- Extract text from scanned documents
- Classify documents by theme
- Answer questions about document content
- Generate professional email responses
- Maintain consistent tone across replies
- Reduce response time
cd frontend
npm run type-check # TypeScript type checking
npm run lint # ESLint
npm run build # Production build testcd backend
python tests/test_pipeline.py # API integration tests
# Manual testing with curl
curl -X GET http://127.0.0.1:8002/health
curl -X POST http://127.0.0.1:8002/api/translate \
-H "Content-Type: application/json" \
-d '{"subject":"Test","message":"Bonjour"}'- Start the backend
- Visit http://127.0.0.1:8002/docs
- Use Swagger UI to test all endpoints
Solution: Ensure dateFormatter.ts is properly imported:
import { formatEmailDate } from "@/utils/dateFormatter";
<span>{formatEmailDate(email.date)}</span>- Check backend is running:
http://127.0.0.1:8002/health - Verify
NEXT_PUBLIC_BACKEND_URLin frontend.env.local - Check CORS settings in
backend/api/main.py
- Verify Google OAuth credentials in
.env.local - Check Gmail API is enabled in Google Cloud Console
- Ensure redirect URIs match in Google Console
- Verify API keys in
backend/config/.env - Check model names are correct
- Test with Mistral if NVIDIA keys expired
- OAuth 2.0: Secure Google authentication
- HTTP-Only Cookies: Session tokens stored securely
- API Key Protection: Backend keys never exposed to client
- CORS Configuration: Restricted to authorized origins
- Input Validation: Pydantic models for request validation
- Rate Limiting: Protection against API abuse (future enhancement)
GOOGLE_CLIENT_ID= # Google OAuth Client ID
GOOGLE_CLIENT_SECRET= # Google OAuth Client Secret
GMAIL_SCOPES= # Gmail API scopes
NEXTAUTH_URL= # NextAuth callback URL
NEXTAUTH_SECRET= # NextAuth encryption key
NEXT_PUBLIC_BACKEND_URL= # Backend API URLNVIDIA_API_KEY_LLAMA3_8B= # NVIDIA API key (8B model)
NVIDIA_API_KEY_LLAMA3_70B= # NVIDIA API key (70B model)
CLOUD_ADAPTER_API_KEY= # Mistral API key
MISTRAL_MODEL= # Mistral model name
LOCAL_LLAMA_API_BASE_URL= # Local Llama URL (optional)
LOCAL_LLAMA_MODEL_NAME= # Local Llama model (optional)- Email Analysis: < 3 seconds
- Translation: < 2 seconds (cached: < 100ms)
- OCR Processing: 5-10 seconds (depending on document size)
- RAG Question Answering: 3-5 seconds
- Calendar Availability Check: < 1 second
- Auto-Reply Generation: < 3 seconds
- β Gmail integration
- β Email analysis & translation
- β Task detection
- β Auto-reply generation
- β Attachment processing
- β Calendar integration
- β RAG Q&A
- β Document classification
- Email drafting assistant
- Bulk email processing
- Advanced filters & rules
- Email templates
- Analytics dashboard
- Mobile app (React Native)
- Multi-account support
- Team collaboration features
- Integration with Slack, Teams
- Custom AI model training
- Enterprise SSO
- Advanced security features
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code style
- Add tests for new features
- Update documentation
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Sofrecom Tunisia for hosting the hackathon
- Next.js Team for the amazing framework
- FastAPI for the blazing-fast backend framework
- Google for Gmail and Calendar APIs
- NVIDIA and Mistral AI for powerful language models
- OpenAI for inspiration and API design patterns
- HuggingFace for embeddings and transformers
- Tesseract OCR for text extraction capabilities
@ImenBenAmar @YomnaJL @ fakhfakheya @jerbi86
If you find this project useful, please consider giving it a β on GitHub!
Made with β€οΈ for Sofrecom Tunisia Hackathon 2025