Third-Party Services
Relevant source files
The following files were used as context for generating this wiki page:Introduction
Inbox Zero integrates a wide array of third-party services to deliver its core features, from AI-powered email assistance to real-time analytics and user authentication. These services are fundamental to the application's architecture, providing specialized functionalities that would be impractical to build in-house. This document outlines the key external services used, their purpose within the system, and how they are configured and integrated.
The application relies on these services for authentication (Google, Microsoft), data persistence and caching (PostgreSQL, Upstash Redis), AI processing (OpenAI, Anthropic, etc.), transactional email (Resend), payment processing (Lemon Squeezy, Stripe), and comprehensive analytics and monitoring (Tinybird, PostHog, Sentry). Configuration is managed primarily through environment variables, which are validated using Zod in apps/web/env.ts.
Sources: ARCHITECTURE.md, apps/web/env.ts
This diagram provides a high-level overview of the major third-party service categories integrated into the Inbox Zero application.
Service Configuration
Configuration for all third-party services is managed through environment variables, defined and validated in apps/web/env.ts. This centralized approach ensures that all required keys and settings are present and correctly formatted.
Key Services and Environment Variables
| Service | Purpose | Environment Variables | Source File |
|---|---|---|---|
| Google OAuth | User authentication and Gmail API access | GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET | apps/web/env.ts:16-17 |
| Microsoft OAuth | User authentication and Outlook API access | MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET | apps/web/env.ts:18-19 |
| Upstash Redis | Caching, session storage, and queues | UPSTASH_REDIS_URL, UPSTASH_REDIS_TOKEN | apps/web/env.ts:47-48 |
| Google Pub/Sub | Real-time email notifications | GOOGLE_PUBSUB_TOPIC_NAME, GOOGLE_PUBSUB_VERIFICATION_TOKEN | apps/web/env.ts:55-56 |
| LLM Providers | AI features (summarization, drafting, etc.) | OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, etc. | apps/web/env.ts:39-46 |
| Resend | Transactional emails (e.g., digests) | RESEND_API_KEY, RESEND_FROM_EMAIL | apps/web/env.ts:84-87 |
| Tinybird | Real-time email analytics | TINYBIRD_TOKEN, TINYBIRD_BASE_URL | apps/web/env.ts:77-78 |
| PostHog | Product analytics and feature flags | POSTHOG_API_SECRET, NEXT_PUBLIC_POSTHOG_KEY | apps/web/env.ts:81-82, 120 |
| Sentry | Error tracking and monitoring | SENTRY_AUTH_TOKEN, NEXT_PUBLIC_SENTRY_DSN | apps/web/env.ts:59-61, 126 |
| Lemon Squeezy | Payment processing | LEMON_SQUEEZY_API_KEY, LEMON_SQUEEZY_SIGNING_SECRET | apps/web/env.ts:68-69 |
| Stripe | Payment processing | STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET | apps/web/env.ts:72-73 |
| Axiom | Log management and web vitals | NEXT_PUBLIC_AXIOM_DATASET, NEXT_PUBLIC_AXIOM_TOKEN | apps/web/env.ts:131-132 |
| Dub.co | Link shortening and analytics | DUB_API_KEY, NEXT_PUBLIC_DUB_REFER_DOMAIN | apps/web/env.ts:104, 140 |
Sources: apps/web/env.ts, ARCHITECTURE.md
Authentication Services
The application supports user sign-in and email account linking via Google and Microsoft.
Google OAuth
- Purpose: Allows users to sign in with their Google account and grant the application permission to access their Gmail data.
- Setup: Requires
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET. The setup process involves configuring a consent screen, defining authorized redirect URIs (/api/auth/callback/google,/api/google/linking/callback), and adding necessary API scopes likegmail.modifyandcontacts. - Scopes:
userinfo.profile,userinfo.email,gmail.modify,gmail.settings.basic,contacts.
Sources: README.md:112-146, apps/web/env.ts:16-17
Microsoft OAuth
- Purpose: Allows users to sign in with their Microsoft account and grant access to Outlook data.
- Setup: Requires
MICROSOFT_CLIENT_IDandMICROSOFT_CLIENT_SECRET. Configuration is done in the Azure Portal, where redirect URIs (/api/auth/callback/microsoft,/api/outlook/linking/callback) and API permissions are set. - Permissions:
openid,profile,email,User.Read,offline_access,Mail.ReadWrite,Mail.Send, and others.
Sources: README.md:162-206, apps/web/env.ts:18-19
AI & LLM Providers
The application is architected to be model-agnostic, supporting various LLM providers for its AI features. The choice of provider and model can be configured via environment variables.
- Supported Providers: Anthropic, Google, OpenAI, AWS Bedrock, OpenRouter, Groq, and a local Ollama instance.
- Configuration: The default, economy, and chat models can be set independently. For example,
DEFAULT_LLM_PROVIDERandECONOMY_LLM_PROVIDERcan be configured to use different models to balance cost and performance. - Fallback: A backup model (
OPENROUTER_BACKUP_MODEL) can be specified for resilience.
This flowchart illustrates the logic for selecting an LLM provider based on environment variable configuration.
Sources: apps/web/env.ts:21-46, README.md:209-230
Communication & Notifications
Resend
Resend is used for sending transactional emails, such as the weekly email digest. The packages/resend/ directory contains the integration logic, and packages/resend/emails/digest.tsx defines the React-based email template for the digest.
- Digest Email: A summary email generated with dynamic content based on categorized emails. The subject is dynamically generated to reflect the content.
- Configuration:
RESEND_API_KEY,RESEND_AUDIENCE_ID,RESEND_FROM_EMAIL.
Sources: packages/resend/emails/digest.tsx, ARCHITECTURE.md:61, apps/web/env.ts:84-87
Google Pub/Sub
To handle incoming emails in real-time, the application uses Google Pub/Sub. When a new email arrives in a user's Gmail account, Google sends a notification to a webhook endpoint in the application.
- Flow:
- Google sends a push notification to
/api/google/webhook. - The webhook handler verifies a security token (
GOOGLE_PUBSUB_VERIFICATION_TOKEN). - The application then fetches the new email details from the Gmail API.
- Google sends a push notification to
- Setup: Requires creating a Pub/Sub topic and subscription in Google Cloud and setting the
GOOGLE_PUBSUB_TOPIC_NAMEenvironment variable.
This sequence diagram shows the real-time email notification flow.
Sources: README.md:255-274, ARCHITECTURE.md:118-124
Analytics & Monitoring
The application uses a suite of tools for analytics, monitoring, and logging. These are primarily integrated on the frontend.
Client-Side Integration
The root layout (apps/web/app/layout.tsx) initializes several analytics and monitoring services.
| Service | Purpose | Integration Component |
|---|---|---|
| Vercel Analytics | Performance metrics | <Analytics /> |
| Vercel Speed Insights | Web vitals | <SpeedInsights /> |
| Axiom | Log management & web vitals | <AxiomWebVitals /> |
| PostHog | Product analytics & session recording | <PostHogProvider /> |
| Google Tag Manager | Marketing analytics & tracking | <GoogleTagManager /> |
| Dub.co | Link analytics | <DubAnalytics /> |
| Sentry | Error tracking | withSentryConfig in next.config.ts |
Sources: apps/web/app/layout.tsx:156-169, next.config.ts:202
Proxying and Rewrites
To circumvent ad-blockers and manage data ingestion, the Next.js configuration sets up rewrites for PostHog and Dub.co.
// apps/web/next.config.ts:121-132
async rewrites() {
return [
{
source: "/ingest/:path*",
destination: "https://app.posthog.com/:path*",
},
// ...
{
source: "/_proxy/dub/track/:path",
destination: "https://api.dub.co/track/:path",
},
{
source: "/_proxy/dub/script.js",
destination: "https://www.dubcdn.com/analytics/script.js",
},
];
},
This configuration routes requests from /ingest/* to PostHog's servers and from /_proxy/dub/* to Dub.co's API and script endpoints.
Sources: next.config.ts:121-132
Other Services
- Formbricks: Used to display the "Open Source Friends" list by fetching data from their API. This demonstrates inter-project collaboration within the open-source community.
Sources: apps/web/app/(landing)/oss-friends/page.tsx:23-24 - Crisp: Integrated for customer support chat, configured via
NEXT_PUBLIC_CRISP_WEBSITE_ID.
Sources: apps/web/env.ts:130 - Loops: A package for marketing email automation, configured with
LOOPS_API_SECRET.
Sources: ARCHITECTURE.md:60, apps/web/env.ts:88
Conclusion
Inbox Zero's architecture is a prime example of a modern web application built by composing powerful, specialized third-party services. This approach allows the development team to focus on the unique value proposition—AI-driven email management—while relying on industry-standard solutions for authentication, payments, analytics, and infrastructure. The extensive use of environment variables for configuration provides flexibility for both self-hosted deployments and the production environment. Understanding this service-oriented architecture is key to developing, deploying, and maintaining the application.