Your Inbox Deserves Better
AI-powered email automation that labels your Gmail and Outlook messages automatically and drafts intelligent responses.
Website β’ Features β’ Getting Started β’ Deployment β’ Tech Stack
NeatMail is an intelligent email management platform that automatically organizes your Gmail and Outlook inboxes in real-time. No complicated setup, no manual sorting - just clean, organized emails labeled exactly where you need them.
- Drowning in emails with no structure
- Spending hours manually organizing messages
- Missing important emails buried in clutter
- Wasting time drafting repetitive responses
NeatMail watches your inbox 24/7 and:
- β¨ Automatically labels incoming emails directly in Gmail and Outlook
- π¨ Custom categories - use presets or create your own
- π€ AI-powered drafts - generates response drafts for pending emails in your tone
- π Real-time processing - labels emails as they arrive, not in batches
- Preset Categories: Action Needed, Pending Response, Automated Alerts, Event Updates, Discussion, Read Only, Resolved, Marketing
- Custom Labels: Create personalized labels with custom colors
- Direct Gmail & Outlook Integration: Labels/categories appear instantly in your mailbox interface
- 95%+ Confidence Threshold: Only labels when AI is highly confident
- Automatically detects emails requiring responses
- Generates contextual draft replies in your tone
- Creates drafts directly in Gmail and Outlook for easy editing and sending
- Skips automated/newsletter emails intelligently
- Weekly email trends visualization
- Real-time tracking of labeled emails
- Sender, subject, and label insights
- Date-based filtering and search
- OAuth 2.0 authentication via Clerk
- Minimal permission scope (read metadata, labels/categories, drafts)
- No email content storage
- Row-level security with Prisma
- Node.js 20+ and npm/yarn/pnpm
- PostgreSQL database
- Redis instance
- Google Cloud Project with Gmail API enabled (for Gmail)
- Microsoft Entra app registration with Microsoft Graph Mail permissions (for Outlook)
- Clerk account for authentication
- OpenAI API key
- DodoPay account (payment processing)
- Clone the repository
git clone https://github.com/Lakshay1509/NeatMail.git
cd neatmail- Install dependencies
bun install
#or
npm install
# or
pnpm install- Set up environment variables
Create a .env.local file:
# Database
DATABASE_URL="postgresql://..."
DIRECT_URL="postgresql://..."
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
CLERK_WEBHOOK_SECRET=
# OpenAI
OPENAI_API_KEY=
#If using Azure
AZURE_ENDPOINT=
AZURE_API_KEY=
# Gmail Webhook
GMAIL_WEBHOOK_TOPIC=projects/your-project/topics/gmail-notifications
#Gmail service account
GMAIL_SERVICE_ACCOUNT=
# Redis
UPSTASH_REDIS_URL=
UPSTASH_REDIS_TOKEN=
# Payment (DodoPay)
DODO_API=
DODO_WEBHOOK_SECRET=
DODO_PRODUCT_ID_INDIA=
DODO_PRODUCT_ID_GLOBAL=
DODO_WEB_URL=
#API URL
NEXT_PUBLIC_API_URL=http://localhost:3000
#Cron Secret
CRON_SECRET=
#INNGEST
INNGEST_EVENT_KEY=
INNGEST_SIGNING_KEY=
#Classification URL
CLASSIFICATION_API_URL=
CLASSIFICATION_API_BEARER_TOKEN=
# App Configuration
NODE_ENV=development
- Set up the database
bunx prisma generate
bunx prisma db push- Run the development server
bun run devOpen http://localhost:3000 in your browser.
graph LR
A[Gmail / Outlook] -->|Push Notification| B[Google Pub/Sub / Graph Subscription]
B -->|Webhook| C[NeatMail API]
C -->|Fetch Email| A
C -->|Classify| D[OpenAI]
D -->|Label Name| C
C -->|Apply Label/Category| A
C -->|Generate Draft| D
D -->|Draft Content| C
C -->|Create Draft| A
C -->|Store Metadata| E[(PostgreSQL)]
C -->|Deduplication| F[(Redis)]
- Next.js 16 - Frontend & API routes
- Hono - Lightweight API framework
- Prisma - Type-safe ORM
- Gmail API / Microsoft Graph API - Email operations
- OpenAI GPT-4 - Email classification & draft generation
- Clerk - Authentication & OAuth management
- Redis - Message deduplication
- Google Pub/Sub - Real-time webhook delivery
- Framework: Next.js 16.1.1 (App Router)
- Language: TypeScript 5.x
- UI Library: React 19.2.3
- Styling: Tailwind CSS 4.x
- UI Components: Radix UI, shadcn/ui
- Charts: Recharts 3.6.0
- State Management: TanStack Query 5.90.16 (React Query)
- Forms: React Hook Form 7.71.1 + Zod 4.3.5
- API: Hono.js 4.11.3
- Database: PostgreSQL
- ORM: Prisma 7.2.0 with Prisma Adapter PG
- Cache: Redis (Upstash Redis 1.36.0)
- Authentication: Clerk 6.36.5
- Payments: DodoPay 2.14.1
- Webhooks: Svix 1.84.1
- Draft Generation: OpenAI 6.15.0 (GPT-4 Mini)
- Classification: OpenAI 6.15.0 (GPT-4 Mini)
- Email APIs: Google APIs 169.0.0 (Gmail API), Microsoft Graph API (Outlook)
- Webhooks: Google Cloud Pub/Sub
- Hosting: Vercel (recommended)
- Database: Neon/Supabase PostgreSQL
- Redis: Upstash Redis
- Monitoring: Vercel Analytics
- Click the button above or manually:
npm install -g vercel
vercel-
Configure environment variables in Vercel dashboard
-
Set up Google Cloud Pub/Sub webhook:
- Create a Pub/Sub topic
- Add your Vercel domain as webhook endpoint
- Grant Gmail API permissions
npx prisma migrate deploy- Go to Google Cloud Console
- Create a new project
- Enable Gmail API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs (Clerk callback)
- Create a Pub/Sub topic for webhooks
- Go to Azure Portal
- Open Microsoft Entra ID β App registrations β New registration
- Add redirect URIs used by your auth provider (Clerk callback)
- Add Microsoft Graph delegated permissions (for example):
Mail.ReadMail.ReadWriteMail.Sendoffline_access
- Grant admin consent if required by your tenant policy
- Configure subscription/webhook notifications for mailbox events
- Create a Clerk application
- Enable Google OAuth provider
- Add required Gmail scopes:
https://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/gmail.readonly
- Configure webhook endpoints if needed
- Create a DodoPay account
- Create a subscription product
- Configure webhook endpoints for subscription events
- Add webhook secret to environment variables
-
Configure Environment Fill in the
.env.buildfile with your credentials (ensure no empty lines or comments):NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=... NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_API_URL=http://localhost:8080 DATABASE_URL=... DIRECT_URL=... UPSTASH_REDIS_URL=... UPSTASH_REDIS_TOKEN=... OPENAI_API_KEY=...
-
Build Image Build the container image using
podman(or docker), passing the variables as build arguments:podman build \ $(sed 's/^/--build-arg /' .env.build) \ -t neatmail .
-
Run Container Run the container passing the environment variables:
podman run -p 8080:8080 --env-file .env.local neatmail
/app- Next.js 16 App Router with route groups for auth and dashboard/components- Reusable React components including shadcn/ui primitives/features- Custom React Query hooks organized by feature domain/lib- Core utilities for Gmail, OpenAI, Prisma, Redis integrations/prisma- Database schema with multi-schema support and generated client/types- Shared TypeScript interfaces and type definitions
We love contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Ensure code passes linting (
npm run lint)
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js - React framework
- Clerk - Authentication
- OpenAI - AI models
- Prisma - Database ORM
- shadcn/ui - UI components
- Website: neatmail.tech
- Issues: GitHub Issues
- Email: help.neatmail@gmail.com
Built with β€οΈ by the NeatMail team