Back to build log

Building an AI Gmail client – architecture notes

·5 min read

Building an AI Gmail client – architecture notes

When I started building Quero, I knew the architecture would make or break the project. Here's what I learned.

The OAuth Challenge

Gmail's OAuth flow is notoriously complex. You need to handle:

Initial authorization

Token refresh cycles

Scope management for different features

I ended up creating a dedicated auth service that handles all token management transparently.

Streaming AI Responses

The biggest UX win was implementing streaming responses. Instead of waiting for the full AI response, users see text appear in real-time.

const stream = await generateResponse(emailContext);
for await (const chunk of stream) {
  yield chunk;
}

Key Takeaways

1. **Separate concerns early** - Auth, email processing, and AI generation should be independent services

2. **Cache aggressively** - Email metadata rarely changes, cache it

3. **Stream everything** - Users prefer seeing progress over waiting