Developed as a next-generation intelligent inbox, combining expertise in machine learning, full-stack engineering, semantic search, and natural language processing.
| Name | College | Graduation Year | Email / Phone | GitHub |
|---|---|---|---|---|
| Nirbhay | Nirma University | 2028 | 24bce268@nirmauni.ac.in 8320586268 |
@itatshu |
| Darshan | Nirma University | 2028 | buddhdevdarshan1478@gmail.com 9328325601 |
@darshanNhb |
Transforming the inbox from a chronological feed into a context-aware knowledge base.
MailSense is a hybrid email platform. It combines structured Gmail-style operators, BM25 keyword search, semantic vector search, cross-encoder reranking, and a personalized ML importance engine to help you find, understand, and prioritize your communications.
- Problem Statement
- Key Features
- System Architecture
- Machine Learning Pipelines
- Detailed Tech Stack
- Comprehensive Folder Structure
- Installation
- Environment Variables
- Future Roadmap
- Team
Standard email clients like Gmail and Outlook are built on outdated retrieval paradigms. Finding specific information requires exact keyword matches, deciding what to read first is overwhelming, and summarizing long threads is a manual, cognitive burden.
| Challenge | Impact |
|---|---|
| ๐ด Exact keyword search | Hard to find emails when you forget the exact phrasing |
| ๐ด High false positive rates | Traditional search returns too many irrelevant results |
| ๐ด Chronological sorting | Critical action items get buried under newsletters |
| ๐ด Manual labeling | High cognitive load to maintain inbox zero |
MailSense solves these using a hybrid semantic search engine, LLM-powered RAG, and an adaptive ML scoring model.
Our advanced search pipeline routes queries through multiple retrieval mechanisms simultaneously:
- BM25 Keyword Search (
rank_bm25) for exact lexical matches. - Vector Semantic Search (
ChromaDB+gte-Qwen2-1.5B-instruct) to find emails by meaning. - Cross-Encoder Reranking (
bge-reranker-v2-m3) for state-of-the-art relevance sorting. - Reciprocal Rank Fusion (RRF) to perfectly balance keyword and semantic scores.
A multi-phase ML pipeline built on LightGBM. It learns from your explicit onboarding labels and implicit behavior (opens, replies, stars) to predict email importance, sorting the signal from the noise.
Chat directly with your inbox using the Gemini LLM. Ask questions like:
"What were the action items from yesterday's marketing sync?"
The Copilot retrieves relevant emails via our hybrid search pipeline and generates grounded, factual answers.
The importance engine explains why an email is scored highly. Using feature attribution (pred_contrib=True), the UI displays human-readable reasons like "Mentions an application deadline" or "Similar to emails you've marked important before".
Seamless Google OAuth integration and Gmail Pub/Sub webhooks ensure your dashboard is always synchronized in real-time.
graph TD
subgraph "Frontend Layer"
UI["React Dashboard<br/>(Inbox, Search, Copilot)"]
end
subgraph "Backend API (Node.js)"
AUTH["Auth & Sync (OAuth/Webhooks)"]
MONGO["MongoDB (Emails, Labels, Features)"]
ROUTES["API Routes"]
end
subgraph "Python ML Services"
subgraph "Search & RAG (FastAPI/gRPC)"
QR["Query Router (spaCy)"]
RRF["BM25 + ChromaDB + RRF"]
CE["Cross-Encoder Reranker"]
LLM["Gemini Copilot"]
end
subgraph "Importance Engine (Flask/gRPC)"
FE["Feature Engineering Pipeline"]
LGBM["LightGBM Global Model"]
CAL["Platt Scaling Calibration"]
XAI["Feature Attribution"]
end
end
UI <--> ROUTES
ROUTES <--> AUTH
AUTH <--> MONGO
ROUTES <--> QR
ROUTES <--> FE
QR --> RRF
RRF --> CE
CE --> LLM
FE --> LGBM
LGBM --> CAL
CAL --> XAI
Our platform leverages a specialized stack distributed across Node.js and Python microservices to ensure real-time API responsiveness while performing heavy machine learning computation.
- React.js 18: Component-based UI library ensuring highly interactive dashboard performance.
- Vite: Ultra-fast build tool and development server providing instant Hot Module Replacement (HMR).
- Tailwind CSS v4: Utility-first CSS framework. Extensively used for our dark-mode interface, dynamic Importance Badges, and fluid micro-animations.
- Axios: Intercepts HTTP requests and manages JWT/session headers for secure backend communication.
- Node.js & Express.js: Event-driven architecture perfectly suited for handling high-throughput Google Pub/Sub Webhooks whenever a new email arrives.
- MongoDB & Mongoose: Used as the primary operational database. Its document-oriented structure naturally maps to raw email JSON payloads and provides rapid metadata-filtering via indexes.
- Google Cloud APIs (Gmail & OAuth 2.0): Manages secure user authentication, watch subscriptions, and message fetching.
- FastAPI: Provides a high-concurrency async REST interface for the search engine.
- gRPC (Google Remote Procedure Calls): Enables ultra-low-latency binary communication between the Node.js backend and the Python ML services (avoiding HTTP overhead for high-frequency scoring/embedding requests).
- ChromaDB: The primary Vector Database. Selected for its lightweight local persistency, making it perfect for storing dense semantic embeddings of email subjects and bodies.
- SentenceTransformers: Framework used for embedding generation.
- scikit-learn & Pandas: Core libraries for the Feature Engineering pipeline, dataset handling, and Platt Scaling calibration.
- gte-Qwen2-1.5B-instruct (Embeddings): A 1.5-billion parameter embedding model by Alibaba. It generates highly contextual dense vectors for semantic search, heavily outperforming basic models.
- bge-reranker-v2-m3 (Cross-Encoder): A heavy, highly accurate model that takes a query and a retrieved email, processes them together, and outputs an absolute relevance score. This acts as the final quality filter in the search pipeline.
- LightGBM (Importance Engine): A gradient boosting framework created by Microsoft. Selected over deep learning because it handles tabular (feature-engineered) and categorical data significantly faster and with higher accuracy on small datasets.
- spaCy (en_core_web_sm): A lightweight, deterministic NLP library used to parse search queries for intent, dates, and named entities without the latency of an LLM call.
- Google Gemini API (LLM): The foundational Large Language Model used to power the RAG (Retrieval-Augmented Generation) chat interface.
The project is structured into strict microservices to enforce a separation of concerns between I/O bound web traffic and CPU/GPU bound ML workloads.
Email-Manager/
โ
โโโ backend/ # ๐ข Node.js API server (Auth, Webhooks, Orchestration)
โ โโโ src/
โ โโโ config/ # Database and OAuth credentials configuration
โ โโโ controllers/ # Request handlers (webhook processing, auth callbacks)
โ โโโ grpc/ # gRPC client stubs to communicate with Python services
โ โโโ models/ # Mongoose Schemas (Email, EmailLabel, SyncState)
โ โโโ routes/ # Express API endpoints (/inbox, /onboarding, /search)
โ โโโ services/ # Core business logic (gmail.service.js, inboxSampler.js)
โ
โโโ frontend/ # ๐ต React UI (Dashboard, Inbox, AI Chat)
โ โโโ src/
โ โโโ assets/ # Global CSS (Tailwind index), static images
โ โโโ components/ # Reusable UI (ImportanceBadge, Explainability Tooltips)
โ โโโ pages/ # Full views: InboxPage, SearchPage, OnboardingLabeling
โ
โโโ search_feature_demo/ # ๐ Python Hybrid Search & RAG microservice
โ โโโ grpc_app/ # gRPC server exposing EmbedAndStore routines
โ โโโ llm/ # Gemini AI Copilot context orchestration
โ โโโ models/ # Scripts to download and cache HuggingFace weights
โ โโโ retrieval/ # Search core: rank_bm25, ChromaDB management, RRF logic
โ โโโ router/ # Query intent parsing and operator extraction via spaCy
โ โโโ main.py # Entry point for FastAPI (8001) and gRPC (50052)
โ
โโโ feature_engineering/ # โ๏ธ ML Feature Extraction Pipeline
โ โโโ sender_features.py # Analyzes sender domains and historical contact frequency
โ โโโ content_features.py # Extracts NLP flags (urgency, OTPs, deadlines)
โ โโโ time_features.py # Temporal heuristics (day of week, time of day)
โ โโโ pipeline.py # Combines all extractors into a single feature vector
โ โโโ tests/ # Verification of edge cases and cold-start guards
โ
โโโ python-service/ # ๐ง Importance Scoring & Inference API
โ โโโ importance_model/
โ โ โโโ train_global.py # Trains the global LightGBM bootstrap model on all data
โ โ โโโ calibration.py # Fits per-user Platt scaling logistic regression
โ โ โโโ scorer.py # Executes real-time inference with pred_contrib=True
โ โ โโโ explanation_labels.py # Maps raw ML features to human-readable UI tooltips
โ โโโ app.py # Entry point for the scoring REST API
โ
โโโ SECURITY_NOTES.md # Documentation on current OAuth scope and privacy caveats
โโโ README.md # This document
- Natural Language Parsing: Uses
spaCyto extract intent and entities from plain-text queries, supporting Gmail operators (from:sarah after:2024/01/01). - Parallel Retrieval: Fires queries simultaneously to MongoDB (Metadata),
rank_bm25, andChromaDB. - Fusion: Uses RRF (k=60) to merge discrete sparse and dense ranked lists.
- Reranker: A cross-encoder validates the top K results for maximum precision.
Uses a Global Bootstrap Model + Per-User Calibration:
- Feature Extraction: Generates 25+ features (temporal trends, sender history, regex content flags, embedding centroids).
- Global Model: A single LightGBM binary classifier trained across all users to prevent overfitting on low-data accounts.
- Platt Scaling: Adjusts the global model's probabilities to the specific baseline of each individual user.
- Node.js
v18+ - Python
3.11+ - MongoDB running on
localhost:27017 - NVIDIA GPU with CUDA support (Recommended for search pipeline)
git clone https://github.com/Nirbhay71/Email-Manager.git
cd Email-Managercd backend
npm install
npm run dev # Starts API on port 3000cd frontend
npm install
npm run dev # Starts UI on port 5173cd search_feature_demo
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install torch --index-url https://download.pytorch.org/whl/cu121 # Install CUDA first
pip install -r requirements.txt
python -m spacy download en_core_web_sm
python main.py # Starts HTTP (8001) and gRPC (50052)cd python-service
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.py # Starts Scoring APICreate .env files in the respective directories:
Backend (backend/.env)
PORT=3000
MONGO_URI=mongodb://localhost:27017/ai_email_manager
GMAIL_CLIENT_ID=your_client_id
GMAIL_CLIENT_SECRET=your_client_secret
GMAIL_REDIRECT_URI=http://localhost:3000/auth/google/callback
GMAIL_PUBSUB_TOPIC=projects/your-project/topics/your-topicPython Search Service (search_feature_demo/.env)
MONGO_URI=mongodb://localhost:27017/ai_email_manager
CHROMA_PERSIST_DIR=./chroma_data
GEMINI_API_KEY=your_gemini_api_key
SEARCH_HTTP_PORT=8001
SEARCH_GRPC_PORT=50052
DEVICE=auto- Historical 1-6 Month Backfill โ Bulk embedding pipeline for initializing new users quickly.
- Automated Draft Generation โ Let the AI Copilot auto-draft replies to flagged high-importance emails.
- Action Item Extraction Dashboard โ Dedicated kanban board for extracted tasks and deadlines.
- Edge AI Deployment โ Run lightweight embeddings locally in the browser via ONNX for absolute privacy.
Built with ๐ก to revolutionize digital communication.
MailSense โ Search, Understand, Prioritize.