A production-ready email aggregator featuring real-time IMAP synchronization, AI-powered categorization, and intelligent reply suggestions using Retrieval-Augmented Generation (RAG).
- Explaination Video Link - LOOM
Email Onebox is a comprehensive email management system that aggregates multiple email accounts into a unified interface with advanced AI capabilities. Built as a full-stack TypeScript application, it demonstrates real-time data synchronization, distributed search, vector databases, and modern frontend development.
Key Capabilities:
- π Real-time email synchronization across multiple IMAP accounts
- π Full-text search and advanced filtering with Elasticsearch
- π€ AI-powered email categorization and reply suggestions
- π Vector-based semantic search with Qdrant
- π Real-time notifications via Slack and webhooks
- π‘ Modern React UI with Lucide icons
The system follows a four-layer architecture pattern:

Layers:
- Client Layer - React TypeScript UI
- Application Layer - Express.js REST API
- Orchestrator Service - Coordinates service interactions
- Service Layer - Specialized services (IMAP, AI, Search, Notify, Vector)
- Infrastructure Layer - External services (Gmail, OpenAI, Slack, Docker containers)
- Multi-account IMAP sync (2+ accounts supported)
- 30-day historical email fetch
- Persistent IMAP connections with IDLE mode for instant notifications
- Automatic reconnection and fallback polling (30s intervals)
- Docker-hosted Elasticsearch instance
- Full-text search across subject, body, and sender
- Advanced filtering by folder, account, and category
- Optimized indexing with keyword fields for aggregations
- Real-time stats and category breakdowns
- Intelligent categorization into multiple categories:
- Work - Professional communications
- Personal - Personal messages
- Promotions - Marketing emails
- Social - Social media notifications
- Updates - Product/system updates
- Forums - Discussion threads
- Spam - Unwanted content
- Important - Priority emails
- Finance - Financial transactions
- Travel - Travel itineraries
- Shopping - Purchase confirmations
- Health - Health-related content
- Real-time categorization on email arrival
- Visual icon indicators using Lucide React icons
- Slack notifications for categorized emails
- Rich message formatting with email preview
- Webhook triggers for external automation
- Configurable notification rules
- React TypeScript with Tailwind CSS
- Real-time email display
- Advanced search and filtering
- Pagination with "Load More" functionality
- Category-based filtering with visual indicators
- Responsive design with independent scrollable sections
- Lucide React icons for modern UI
- Qdrant vector database for context storage
- OpenAI embeddings for semantic search
- Context-aware reply generation
- Automatic meeting link inclusion
- One-click copy to clipboard
email-onebox/
βββ backend/ # Node.js + TypeScript backend
β βββ src/
β β βββ config/ # Configuration files
β β β βββ env.ts # Environment variables
β β β βββ elasticsearch.ts
β β β βββ index.ts
β β βββ models/ # Data models
β β β βββ Email.ts
β β βββ routes/ # API endpoints
β β β βββ index.ts
β β βββ services/ # Core services
β β β βββ ai.service.ts # OpenAI integration
β β β βββ elasticsearch.service.ts
β β β βββ imap.service.ts # Email sync
β β β βββ notification.service.ts
β β β βββ orchestrator.service.ts
β β β βββ qdrant.service.ts
β β βββ types/ # TypeScript types
β β βββ index.ts
β βββ package.json
β βββ tsconfig.json
β
βββ frontend/ # React + TypeScript frontend
β βββ src/
β β βββ components/ # React components
β β β βββ CategoryStats.tsx
β β β βββ EmailDetail.tsx
β β β βββ EmailItem.tsx
β β β βββ EmailList.tsx
β β β βββ Sidebar.tsx
β β βββ utils/ # Utilities
β β β βββ helpers.tsx # Helper functions with Lucide icons
β β βββ types/ # TypeScript types
β β β βββ index.ts
β β βββ App.tsx
β β βββ index.tsx
β β βββ index.css
β βββ public/ # Static assets
β βββ package.json
β βββ tsconfig.json
β
βββ docker-compose.yml # Docker services (Elasticsearch, Qdrant)
βββ architecture.png # Architecture diagram
βββ onebox1.png # Screenshots
βββ onebox2.png
βββ onebox3.png
βββ onebox4.png
βββ README.md
- Node.js (v18+)
- Docker and Docker Compose
- Gmail account(s) with IMAP enabled
- OpenAI API key
- (Optional) Slack webhook URL
git clone https://github.com/yourusername/email-onebox.git
cd email-oneboxBackend:
cd backend
npm installFrontend:
cd ../frontend
npm installCreate a .env file in the backend directory:
# Server Configuration
PORT=3000
NODE_ENV=development
# Email Configuration (IMAP)
IMAP_ACCOUNT_1_EMAIL=your-email@gmail.com
IMAP_ACCOUNT_1_PASSWORD=your-app-password
IMAP_ACCOUNT_1_HOST=imap.gmail.com
IMAP_ACCOUNT_1_PORT=993
# Optional: Second account
IMAP_ACCOUNT_2_EMAIL=second-email@gmail.com
IMAP_ACCOUNT_2_PASSWORD=app-password
IMAP_ACCOUNT_2_HOST=imap.gmail.com
IMAP_ACCOUNT_2_PORT=993
# OpenAI Configuration
OPENAI_API_KEY=sk-your-openai-api-key
# Optional: Slack Integration
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
# Optional: Custom Webhook
WEBHOOK_URL=https://webhook.site/your-unique-id
# Product Information for RAG
PRODUCT_INFO=Your product description here
MEETING_LINK=https://calendly.com/yourmeetingπ Note for Gmail:
- Enable "Less secure app access" or use an App Password
- Generate an app password: Google Account β Security β App passwords
# Start Elasticsearch and Qdrant
docker-compose up -d
# Verify services are running
docker-compose pscd backend
npm run devThe backend will start on http://localhost:3000
cd frontend
npm startThe frontend will start on http://localhost:3001
- Open your browser and navigate to
http://localhost:3001 - The application will automatically start syncing emails from configured IMAP accounts
- Wait for the initial sync to complete (fetches last 30 days of emails)
- Browse all synced emails in the center panel
- Click on any email to view details in the right panel
- Use the search bar in the sidebar to search across subject, body, and sender
- Filter by account using the dropdown
- Filter by category using the category dropdown
- Click "Apply" to apply filters
- View category breakdown in the sidebar
- Click on any category to filter emails by that category
- See email counts per category
- Click on any email to view details
- The AI will automatically generate a contextual reply
- Click "Copy to Clipboard" to copy the suggested reply
- New emails are automatically synced via IMAP IDLE mode
- Statistics and counts update in real-time
- No need to refresh the page
Add multiple IMAP accounts by extending the configuration in backend/src/config/env.ts:
imap: {
accounts: [
{
id: 'account1',
email: process.env.IMAP_ACCOUNT_1_EMAIL,
password: process.env.IMAP_ACCOUNT_1_PASSWORD,
host: process.env.IMAP_ACCOUNT_1_HOST || 'imap.gmail.com',
port: parseInt(process.env.IMAP_ACCOUNT_1_PORT || '993'),
tls: true
},
// Add more accounts...
]
}Categories can be customized in the AI service. Edit backend/src/services/ai.service.ts:
const categories = [
'Work',
'Personal',
'Promotions',
'Social',
// Add more categories...
];Configure notification triggers in backend/src/services/notification.service.ts:
// Example: Only notify for "Important" category
if (email.category === 'Important') {
await this.sendSlackNotification(email);
}Backend with auto-reload:
cd backend
npm run devFrontend with hot reload:
cd frontend
npm startBackend:
cd backend
npm run build
npm startFrontend:
cd frontend
npm run build
# Serve the build folder with a static server
npx serve -s build- Send a test email to one of your configured accounts
- Wait up to 30 seconds for IMAP polling to catch the new email
- Verify the email appears in the UI
- Send emails with specific keywords (e.g., "meeting", "urgent")
- Verify proper categorization in the stats panel
- Use the search bar to find specific emails
- Test filters (account, category)
- Verify aggregated statistics update correctly
- Ensure Docker services are running:
docker-compose ps - Check
.envfile has all required variables - Verify Elasticsearch is accessible at
http://localhost:9200
- Verify IMAP credentials are correct
- Check if "Less secure apps" is enabled in Google Account
- Use an App Password instead of regular password
- Check backend logs for IMAP connection errors
- Verify backend is running on port 3000
- Check browser console for API errors
- Ensure Elasticsearch has data:
curl http://localhost:9200/emails/_count
- Restart services:
docker-compose restart - Check logs:
docker-compose logs elasticsearch - Rebuild if needed:
docker-compose up -d --build
| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Tailwind CSS, Lucide Icons, Axios |
| Backend | Node.js, Express.js, TypeScript |
| Database | Elasticsearch 8.11.0, Qdrant |
| AI/ML | OpenAI GPT-4o, Embeddings |
| IMAP (node-imap) | |
| Containerization | Docker, Docker Compose |
| Build Tools | TypeScript, Webpack, Tailwind |
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Shriram - GitHub
- OpenAI for GPT-4o API
- Elasticsearch for powerful search capabilities
- Qdrant for vector database
- Lucide for beautiful icons
- The open-source community
Made with β€οΈ using AI-powered email management







