A simple personal newsletter processing system that automatically fetches, processes, and generates AI-powered digest summaries from your email subscriptions. Detailed writeup here.
- Automated Processing: Fetches newsletters from Gmail daily at 8 PM
- AI Summarization: Uses free Gemini model to generate summaries
- Weekly Digests: Creates comprehensive weekly summaries every Sunday at 7 AM
- Notion Integration: Publishes digests to Notion with rich formatting
- FastAPI Server: Web server that uses background workers for automated processing
- 15 Genres: Supports Technology, Business, Science, Health, and 11 other categories
graph TD;
A[⏰ Daily Scheduler] -->|8 PM Daily| B[Email Daily Processor]
C[⏰ Weekly Scheduler] -->|Sunday 7 AM| D[Weekly Digest Generator]
B -->|IMAP Fetch| E[📧 Email Servers]
B -->|Primitive Filter| F[Potential Newsletters]
F -->|Batch Processor| G[LLM Batch Analysis]
G -->|10 newsletters/call| H[Summary]
H --> I[📊 SQLite Database]
D -->|Query Last 7 Days| I
D --> L[📄 Weekly Digest]
L --> M[Notion]
N[👤 User] --> M
style A fill:#fff3e0
style C fill:#e8f5e8
style B fill:#e1f5fe
style D fill:#e8f5e8
style I fill:#f3e5f5
style G fill:#fff8e1
style M fill:#fce4ec
- Install dependencies:
pip install -r requirements.txt- Set up environment variables (create
.envfile):
# Gmail
EMAIL_ADDRESS=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
# OpenRouter (Free Gemini)
OPENROUTER_API_KEY=your-openrouter-key
# Notion
NOTION_TOKEN=your-notion-token
NOTION_DATABASE_ID=your-database-id- Run the server:
python app.pyThe server will start on http://localhost:8000 with automatic background processing.
GET /- Server statusGET /status- Scheduler status and next run timesPOST /jobs/daily- Manually trigger daily processingPOST /jobs/weekly- Manually trigger weekly digest
- Enable 2FA on your Google account
- Generate an App Password:
- Go to Google Account Settings
- Security → 2-Step Verification → App passwords
- Generate password for "Mail"
- Use this password (not your regular password)
- Create account at OpenRouter
- Go to Keys section
- Create new key with sufficient credits
- The system uses the free Gemini model
-
Create a Notion integration:
- Go to Notion Developers
- Create new integration
- Copy the "Internal Integration Token"
-
Create a database:
- Create a new Notion page
- Add a database with these properties:
- Title (title)
- Week Start (date)
- Week End (date)
- Total Newsletters (number)
- Share the database with your integration
-
Get the database ID:
- Copy the database URL
- Extract the ID from the URL (32-character string)
Test the complete workflow:
python test_workflow.py- Daily Processing: Every day at 8:00 PM
- Weekly Digest: Every Sunday at 7:00 AM
Trigger jobs manually via API:
# Daily processing
curl -X POST http://localhost:8000/jobs/daily
# Weekly digest
curl -X POST http://localhost:8000/jobs/weekly
# Check status
curl http://localhost:8000/statusThe system is designed to be simple and personal. It uses:
- SQLite for data storage
- Background scheduling with APScheduler
- FastAPI for the web interface
- Simple print statements for monitoring
Perfect for personal newsletter management without production complexity.
MIT License - See LICENSE file for details.