AI / MLCompleted2 min read

Smart Email Assistant

AI Email Automation

Smart Email Assistant

Overview

The Smart Email Assistant is a full-stack AI-powered email management platform. A fine-tuned DistilBERT classifies incoming emails into 6 categories (promotions, spam, social_media, forum, verify_code, updates). A fine-tuned T5-small model generates context-aware draft replies. A heuristic priority scoring engine (0.0–1.0) weighs category confidence, urgency keywords, sender reputation, Gmail labels, and read status. Sentence-BERT (all-MiniLM-L6-v2) embeddings indexed in FAISS enable natural-language semantic search over the Gmail inbox. The system integrates with Gmail via OAuth2 (PKCE) for inbox fetching, real-time classification, bulk analysis, and draft reply creation. Built with Next.js 16 + React 19 frontend, FastAPI backend, and trained on Google Colab (T4 GPU).

Problem & Solution

The Problem

Repetitive email work — classification, prioritisation, drafting standard replies — consumes hours that could be spent on meaningful work.

The Solution

Multi-model ML pipeline that classifies emails into 6 categories, generates context-aware draft replies, scores priority, and enables semantic search — all integrated with Gmail via OAuth2.

Architecture & Dataflow

Pipeline Architecture
Gmail (OAuth2) → Email Ingestion → DistilBERT (6-class classification) + T5 (reply generation) + Sentence-BERT → FAISS Index (semantic search) + Priority Scorer → FastAPI → Next.js 16 Dashboard

Technical Stack & Implementation

AI / ML & Models

  • DistilBERT (classification)
  • T5-small (reply generation)
  • Sentence-BERT/all-MiniLM-L6-v2 (embeddings)
  • FAISS
  • PyTorch
  • HuggingFace Transformers

Backend & APIs

  • FastAPI
  • Python
  • SQLAlchemy
  • Pydantic
  • JWT (python-jose)

Frontend & UI

  • Next.js 16
  • React 19
  • TypeScript
  • Tailwind CSS

Data & Storage

  • SQLite (dev)
  • PostgreSQL (Docker)

DevOps & Infra

  • Docker
  • Docker Compose
  • Google OAuth2 (PKCE)

Technical Challenges & Solutions

01

Fine-tuning DistilBERT for 6-class email classification with limited labelled data

02

Building a priority scoring heuristic that balances multiple signal sources

03

Integrating Gmail OAuth2 (PKCE) flow with real-time classification pipeline

Key Highlights & Results

Training pipeline: DistilBERT (~20 min), FAISS index (~5 min), T5 (~15 min) on Google Colab T4

Full-stack integration: Next.js frontend → FastAPI backend → ML models → Gmail API

Comprehensive test coverage: 23 backend + 4 frontend tests

6-category email classification with fine-tuned DistilBERT
Context-aware reply generation with fine-tuned T5-small
Heuristic priority scoring engine (category + urgency + sender + labels)
FAISS semantic search via Sentence-BERT embeddings over Gmail inbox
Full Gmail OAuth2 integration (inbox fetch, real-time classification, draft creation)
Bulk email analysis with priority sorting
Per-user analysis history with JWT authentication
23 backend tests + 4 frontend tests