Architecture
System Overview
┌─────────────────────────────────────────────────────────────┐
│ Client Layer │
│ Next.js Web Application │
└─────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ FastAPI Backend │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Auth Module │ │ Email Sync │ │ AI Classification │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Data Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Supabase │ │ Redis │ │ Vector DB │ │
│ │ (PostgreSQL)│ │ (Cache) │ │ (AI Memory) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘Components
Frontend (Next.js)
The web application handles user authentication, email display, and chat interface.
Key Technologies
- Next.js 14 with App Router
- Shadcn/UI components
- Zustand for state management
- SWR for data fetching
Backend (FastAPI)
Handles business logic, email synchronization, and AI processing.
python
from fastapi import FastAPI
app = FastAPI(title="Zenlym API")
@app.get("/health")
def health_check():
return {"status": "healthy"}Background Workers (Celery)
Processes email sync and AI classification asynchronously.
Data Flow
- Email Received → Gmail webhook triggers sync
- Sync Worker → Fetches and stores email
- AI Worker → Classifies email using GPT-4o-mini
- Notification → User notified if email is important