# Implement Gmail Push Notifications with Workflows This PR implements a comprehensive Gmail push notification system using Cloudflare Workflows. It creates a subscription factory pattern to handle different email providers, with Google implementation completed. The system processes Gmail history updates, vectorizes messages, generates thread summaries, and applies AI-generated labels. ## Type of Change - ✨ New feature (non-breaking change which adds functionality) - ⚡ Performance improvement ## Areas Affected - [x] Email Integration (Gmail, IMAP, etc.) - [x] User Interface/Experience - [x] Data Storage/Management - [x] API Endpoints ## Testing Done - [x] Manual testing performed ## Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in complex areas - [x] My changes generate no new warnings ## Additional Notes Key changes: 1. Created subscription factory pattern with Google implementation 2. Added Cloudflare Workflows for processing Gmail notifications 3. Implemented thread and message vectorization 4. Added AI-based thread labeling 5. Fixed string template in party.tsx component 6. Added cheerio for HTML parsing 7. Enabled interactive dev session in wrangler config The system now processes Gmail notifications in real-time, extracts meaningful data, and provides AI-generated labels for better email organization. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced advanced workflows for processing and labeling email threads using AI, including summarization, vectorization, and automatic label assignment. - Added support for managing subscriptions and notifications for Google and Outlook email providers. - Implemented user notification and token verification features for enhanced security and real-time updates. - **Improvements** - Streamlined subscription management with new queue-based and scheduled background processing for renewals and state tracking. - Enhanced label management with detailed default categories for email threads. - Improved connection and subscription state handling for greater reliability and clarity. - **Bug Fixes** - Adjusted connection handling to ensure correct context usage and state updates. - **Chores** - Updated environment configurations to support new workflows, queues, and storage namespaces. - Added new dependencies and updated development scripts for improved development experience. - **Documentation** - Expanded type definitions and documentation for new features and provider support. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Zero
An Open-Source Gmail Alternative for the Future of Email
What is Zero?
Zero is an open-source AI email solution that gives users the power to self-host their own email app while also integrating external services like Gmail and other email providers. Our goal is to modernize and improve emails through AI agents to truly modernize emails.
Why Zero?
Most email services today are either closed-source, data-hungry, or too complex to self-host. 0.email is different:
- ✅ Open-Source – No hidden agendas, fully transparent.
- 🦾 AI Driven - Enhance your emails with Agents & LLMs.
- 🔒 Data Privacy First – Your emails, your data. Zero does not track, collect, or sell your data in any way. Please note: while we integrate with external services, the data passed through them is not under our control and falls under their respective privacy policies and terms of service.
- ⚙️ Self-Hosting Freedom – Run your own email app with ease.
- 📬 Unified Inbox – Connect multiple email providers like Gmail, Outlook, and more.
- 🎨 Customizable UI & Features – Tailor your email experience the way you want it.
- 🚀 Developer-Friendly – Built with extensibility and integrations in mind.
Tech Stack
Zero is built with modern and reliable technologies:
- Frontend: Next.js, React, TypeScript, TailwindCSS, Shadcn UI
- Backend: Node.js, Drizzle ORM
- Database: PostgreSQL
- Authentication: Better Auth, Google OAuth
Getting Started
Prerequisites
Required Versions:
Before running the application, you'll need to set up services and configure environment variables. For more details on environment variables, see the Environment Variables section.
Setup Options
You can set up Zero in two ways:
Standard Setup (Recommended)
Quick Start Guide
-
Clone and Install
# Clone the repository git clone https://github.com/Mail-0/Zero.git cd Zero # Install dependencies pnpm install # Start database locally pnpm docker:db:up -
Set Up Environment
- Run
pnpm nizzy envto setup your environment variables - Run
pnpm nizzy syncto sync your environment variables and types - Start the database with the provided docker compose setup:
pnpm docker:db:up - Initialize the database:
pnpm db:push
- Run
-
Start the App
pnpm dev -
Open in Browser
Visit http://localhost:3000
Devcontainer Setup
Quick Start guide
-
Clone and Install
# Clone the repository git clone https://github.com/Mail-0/Zero.git cd ZeroThen open the code in devcontainer and install the dependencies:
pnpm install # Start the database locally pnpm docker:db:up -
Set Up Environment
- Run
pnpm nizzy envto setup your environment variables - Run
pnpm nizzy syncto sync your environment variables and types - Start the database with the provided docker compose setup:
pnpm docker:db:up - Initialize the database:
pnpm db:push
- Run
-
Start The App
pnpm devVisit http://localhost:3000
Environment Setup
-
Better Auth Setup
-
Open the
.envfile and change the BETTER_AUTH_SECRET to a random string. (Useopenssl rand -hex 32to generate a 32 character string)BETTER_AUTH_SECRET=your_secret_key
-
-
Google OAuth Setup (Required for Gmail integration)
-
Go to Google Cloud Console
-
Create a new project
-
Add the following APIs in your Google Cloud Project: People API, Gmail API
- Use the links above and click 'Enable' or
- Go to 'APIs and Services' > 'Enable APIs and Services' > Search for 'Google People API' and click 'Enable'
- Go to 'APIs and Services' > 'Enable APIs and Services' > Search for 'Gmail API' and click 'Enable'
-
Enable the Google OAuth2 API
-
Create OAuth 2.0 credentials (Web application type)
-
Add authorized redirect URIs:
- Development:
http://localhost:8787/api/auth/callback/google
- Production:
https://your-production-url/api/auth/callback/google
- Development:
-
Add to
.env:GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret -
Add yourself as a test user:
- Go to
Audience - Under 'Test users' click 'Add Users'
- Add your email and click 'Save'
- Go to
-
Warning
The authorized redirect URIs in Google Cloud Console must match exactly what you configure in the
.env, including the protocol (http/https), domain, and path - these are provided above.
-
Autumn Setup (Required for some encryption)
-Go to Autumn -For Local Use, click onboarding button and generate an Autumn Secret Key -For production, select the production mode from upper left corner and generate an fill the other fields. After that, generate an Autumn Secret Key
- Add to
.env:
AUTUMN_SECRET_KEY=your_autumn_secret - Add to
Environment Variables
Run pnpm nizzy env to setup your environment variables. It will copy the .env.example file to .env and fill in the variables for you.
For local development a connection string example is provided in the .env.example file located in the same folder as the database.
Database Setup
Zero uses PostgreSQL for storing data. Here's how to set it up:
-
Start the Database
Run this command to start a local PostgreSQL instance:
pnpm docker:db:upThis creates a database with:
- Name:
zerodotemail - Username:
postgres - Password:
postgres - Port:
5432
- Name:
-
Set Up Database Connection
Make sure your database connection string is in
.envfile. And you have ranpnpm nizzy syncto sync the latest env.For local development use:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/zerodotemail" -
Database Commands
-
Set up database tables:
pnpm db:push -
Create migration files (after schema changes):
pnpm db:generate -
Apply migrations:
pnpm db:migrate -
View database content:
pnpm db:studioIf you run
pnpm devin your terminal, the studio command should be automatically running with the app.
-
Contribute
Please refer to the contributing guide.
If you'd like to help with translating Zero to other languages, check out our translation guide.
Star History
This project wouldn't be possible without these awesome companies
🤍 The team
Curious who makes Zero? Here are our contributors and maintainers