Skip to content

adi-rajput/OneBox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฌ Onebox

A unified, AI-powered email dashboard built to tame inbox chaos

Born from the frustration of juggling multiple email accounts, missing important follow-ups, and typing the same replies over and over โ€” Onebox is a real-time, multi-account email management system that intelligently categorizes, searches, and helps you respond to emails faster.

What makes it different? Real-time IMAP sync (no polling!), AI-powered classification, semantic search for replies, and instant notifications for what matters โ€” all wrapped in a clean, focused interface.


โœจ Key Features

๐Ÿ”„ Real-Time IMAP Email Sync

Built on persistent IMAP connections using ImapFlow with live IDLE monitoring โ€” your emails appear the moment they arrive.

  • Multi-account support โ€” manage all your inboxes in one place
  • 30-day historical backfill on first sync
  • Zero polling overhead โ€” event-driven updates only
  • Efficient parsing with mailparser

๐Ÿ” Lightning-Fast Search (Elasticsearch)

Every email is indexed instantly for sub-second search and filtering.

  • Full-text search across subject, body, sender, and recipient
  • Advanced filtering by account, folder (inbox/sent/spam), and AI category
  • Pagination support (100 emails per page)
  • Date-sorted results (newest first)

๐Ÿค– AI-Powered Email Categorization

Let AI do the triage work using Google Gemini (gemini-2.5-flash-lite).

Categories:

  • โœ… Interested โ€” warm leads and positive responses
  • ๐Ÿ“… Meeting Booked โ€” confirmed appointments
  • โŒ Not Interested โ€” polite declines
  • ๐Ÿšซ Spam โ€” promotional noise
  • ๐Ÿ  Out of Office โ€” automated replies

Every email (new and historical) is automatically classified before indexing โ€” helping you focus on what needs your attention.

๐Ÿ”” Smart Notifications

Stay informed about important emails without constant checking.

Notification triggers:

  • Interested emails โ†’ Instant Slack DM
  • Meeting Booked โ†’ Custom webhook automation (optional)

Gracefully handles missing webhooks without crashing โ€” just logs a friendly warning.

๐Ÿ’ฌ AI-Suggested Replies (RAG-Based)

Context-aware reply suggestions powered by semantic search and LLMs.

How it works:

  1. Query arrives with email subject + body
  2. Pinecone retrieves top 3 semantically similar knowledge snippets
  3. Gemini generates 3 contextual reply options
  4. Choose, customize, and send

Knowledge base includes:

  • Product information and features
  • Common objection handling
  • Meeting scheduling templates
  • Professional response patterns

๐ŸŽจ Modern Frontend (Next.js 15 + React 19)

A clean, responsive interface designed for productivity.

Features:

  • Email list with smart pagination
  • Multi-filter support (account, folder, category)
  • Real-time full-text search
  • Category statistics and chips
  • AI reply modal with one-click insertion
  • Mobile-responsive design

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        IMAP Servers                          โ”‚
โ”‚              (Gmail, Outlook, Custom IMAP)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
                     โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚   IMAP Sync Service   โ”‚
         โ”‚   (ImapFlow + IDLE)   โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚
                    โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚  Email Parser         โ”‚
         โ”‚  (mailparser)         โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚
                    โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚  AI Categorization    โ”‚
         โ”‚  (Gemini 2.5 Flash)   โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ–ผ                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Elasticsearch  โ”‚   โ”‚  Notifications   โ”‚
โ”‚  (Indexing)     โ”‚   โ”‚  (Slack/Webhook) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           REST API (Express)             โ”‚
โ”‚  /get-all-email  /search  /suggest-repliesโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        Frontend (Next.js 15)             โ”‚
โ”‚    Email Dashboard + Reply Assistant     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ (RAG Flow)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Pinecone Vector DB โ†’ Gemini โ†’ Replies  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Backend Stack

  • Runtime: Node.js + TypeScript
  • Framework: Express
  • Email Sync: ImapFlow (IMAP IDLE)
  • Search & Storage: Elasticsearch 8.x
  • AI: Google Gemini API
  • Vector DB: Pinecone
  • Parsing: mailparser

Frontend Stack

  • Framework: Next.js 15 (App Router)
  • UI: React 19
  • Styling: Tailwind CSS
  • Icons: Lucide React
  • State: React Hooks

๐Ÿ“ก API Reference

Email Retrieval

GET /get-all-email

Fetch all emails with pagination.

Query Parameters:

  • page (number, optional) โ€” Default: 1

Response: Array of email objects (100 per page)


GET /get-filtered-emails

Filter emails by specific criteria.

Query Parameters:

  • accountId (string, optional) โ€” Filter by email account
  • folder (string, optional) โ€” inbox, sent, spam, or all
  • category (string, optional) โ€” AI-assigned category
  • page (number, optional) โ€” Default: 1

Response: Filtered array of email objects


GET /search

Full-text search across all indexed emails.

Query Parameters:

  • q (string, required) โ€” Search query

Response: Matching email objects sorted by relevance


AI Features

GET /suggest-replies

Generate contextual reply suggestions using RAG.

Query Parameters:

  • subject (string, required) โ€” Email subject line
  • body_text (string, required) โ€” Email body content

Response:

{
  "replies": [
    "Thanks for reaching out! I'd be happy to schedule a call...",
    "I appreciate your interest. Here's some information...",
    "Let me check my calendar and get back to you..."
  ]
}

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Docker & Docker Compose (for Elasticsearch)
  • Gmail/Outlook accounts with app-specific passwords
  • API keys: Google Gemini, Pinecone (optional: Slack webhook)

Backend Setup

  1. Clone and install dependencies

    cd backend
    npm install
  2. Start Elasticsearch

    cd elastic-search
    docker compose up -d
  3. Configure environment variables

    Create backend/.env:

    PORT=4000
    
    # Elasticsearch
    ES_PORT=http://localhost:9200
    ES_INDEX=reachinbox_emails
    
    # Email Accounts (add more as needed)
    USER_EMAIL_1=your-email@gmail.com
    USER_PASSWORD_1=your-app-specific-password
    USER_EMAIL_2=another-email@gmail.com
    USER_PASSWORD_2=another-app-password
    
    # AI Services
    GEMINI_API_KEY=your_gemini_api_key
    PINECONE_API_KEY=your_pinecone_key
    PINECONE_INDEX_NAME=reach-inbox-kb
    PINECONE_HOST=your-pinecone-host.io
    
    # Notifications (optional)
    SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
    AUTOMATION_WEBHOOK_URL=https://your-automation-endpoint.com
  4. (Optional) Populate Pinecone knowledge base

    In server.ts, uncomment:

    await run(); // Populate Pinecone with knowledge base

    Run once, then re-comment to avoid duplicates.

  5. Start the backend

    npm run dev

    Backend runs on http://localhost:4000

Frontend Setup

  1. Install dependencies

    cd frontend
    npm install
  2. Configure environment

    Create frontend/.env.local:

    NEXT_PUBLIC_API_URL=http://localhost:4000
  3. Start the development server

    npm run dev

    Open http://localhost:3000 in your browser


๐Ÿ“Š Email Object Schema

interface Email {
  messageId: string;
  subject: string;
  from: { address: string; name?: string };
  to: Array<{ address: string; name?: string }>;
  cc?: Array<{ address: string; name?: string }>;
  date: string; // ISO 8601
  body_text: string;
  body_html?: string;
  folder: 'inbox' | 'sent' | 'spam';
  accountId: string;
  category?: 'Interested' | 'Meeting Booked' | 'Not Interested' | 'Spam' | 'Out of Office';
  hasAttachments?: boolean;
  importance?: 'low' | 'normal' | 'high';
}

๐Ÿ› ๏ธ Technical Decisions & Trade-offs

Why IMAP IDLE over Polling?

  • Real-time updates โ€” emails appear instantly
  • Resource efficient โ€” no wasteful periodic checks
  • Scalable โ€” works with any IMAP-compliant provider

Why Elasticsearch?

  • Sub-second search across thousands of emails
  • Flexible querying โ€” full-text, filters, pagination
  • Production-ready โ€” battle-tested at scale

Why Gemini over OpenAI?

  • Cost-effective โ€” Flash Lite model is fast and cheap
  • JSON mode โ€” structured output for reliable categorization
  • Generous rate limits for personal projects

Why Pinecone for RAG?

  • Managed service โ€” no infrastructure overhead
  • Fast semantic search โ€” <100ms query latency
  • Simple API โ€” easy to integrate and maintain

Current Simplifications

  • App passwords instead of OAuth2 (faster initial setup)
  • Single INBOX folder per account (expandable to all folders)
  • Basic error handling โ€” no retry queues or dead-letter mechanisms yet
  • No threading โ€” emails treated independently

๐Ÿ”ฎ Roadmap & Future Enhancements

Authentication & Security

  • OAuth2 integration for Gmail/Outlook
  • Token refresh and rotation
  • Rate limiting and request throttling
  • Email encryption for sensitive content

Performance & Scalability

  • Bulk indexing optimization (batch writes)
  • Redis caching layer for frequently accessed emails
  • Background job queue (Bull/BullMQ)
  • Horizontal scaling with load balancing

Features

  • Email threading โ€” group conversations intelligently
  • Send email โ€” compose and send directly from UI
  • Attachment handling โ€” preview, download, search
  • Email templates โ€” save and reuse common replies
  • Read/unread status โ€” sync with mail server
  • Multi-folder support โ€” beyond inbox (drafts, archives)
  • Smart filters โ€” auto-apply rules to incoming emails
  • Analytics dashboard โ€” response times, category distribution

Real-Time & Collaboration

  • WebSocket push updates for live UI sync
  • Team inbox mode (shared accounts)
  • Collaborative tagging and notes
  • Slack bot integration for quick actions

AI & Automation

  • Sentiment analysis for customer emails
  • Auto-reply for common queries
  • Priority scoring based on sender history
  • Smart scheduling assistant (calendar integration)
  • Custom AI categorization rules (user-defined)

๐Ÿค Contributing

This is a personal learning project, but suggestions and feedback are welcome!

If you'd like to contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is open source and available under the MIT License.


๐Ÿ™ Acknowledgments

Built with:


๐Ÿ’ก Why I Built This

Email shouldn't feel like a chore. After years of switching between tabs, missing important messages, and rewriting the same responses, I wanted something better โ€” a single dashboard that's smart enough to know what matters and helpful enough to draft replies for me.

Onebox started as a weekend experiment and evolved into my daily email driver. It's not perfect, but it's mine โ€” and it makes managing multiple inboxes actually enjoyable.

If you're drowning in email or just curious about building real-time data pipelines with AI, I hope this project inspires you to build something cool too.


Questions or feedback? Open an issue or reach out โ€” I'd love to hear from you! ๐Ÿ“ง

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors