An intelligent email processing pipeline that reads unread Gmail messages, classifies them using a local LLM (DeepSeek via Ollama), and automatically summarizes or drafts replies based on category.
Gmail Inbox ──▶ readEmail.py ──▶ EmailConductor.py ──▶ Ollama / DeepSeek LLM
│ │
│ ├─ classify_email()
│ ├─ summarize_email()
│ └─ draft_reply_email()
│ │
└───────── EmailRecord (dataclass) ◀──┘
| Module | Purpose |
|---|---|
EmailRecord.py |
Dataclass holding email fields: id, subject, body, category, action, summary, draft_reply |
EmailConductor.py |
LLM chains for classification, summarization, and reply drafting; action routing logic |
readEmail.py |
Connects to Gmail via IMAP, extracts subject/body, and sends each email through the pipeline |
| Category | Action |
|---|---|
| Spam / Scam | 🗑️ Delete / Ignore |
| Friends / Personal | 📝 Summarize + Draft Reply |
| Delivery | 📦 Summarize |
| Scheduling | 📅 Summarize + Draft Reply |
| Other | 🔍 Review Manually |
- Python 3.10+
- Ollama running locally with the
deepseek-r1:8bmodel pulled - A Gmail account with an App Password enabled
# Clone the repo
git clone <repo-url> && cd AWSDC
# Create a virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root:
EMAIL=your_email@gmail.com
PASSWORD=your_16_char_app_passwordollama pull deepseek-r1:8bpython readEmail.pyThis will:
- Connect to your Gmail inbox
- Fetch all unread emails
- Classify, summarize, and (where applicable) draft replies
- Print each
EmailRecordto the console
python EmailConductor.pyRuns a hardcoded spam email through the full pipeline to verify the LLM chain is working.
AWSDC/
├── .env # Gmail credentials (not committed)
├── EmailRecord.py # EmailRecord dataclass
├── EmailConductor.py # LLM classification / summarization / drafting
├── readEmail.py # Gmail IMAP reader + pipeline entry point
├── class_diagram.puml # PlantUML class diagram
├── requirements.txt # Python dependencies
└── README.md # This file
A PlantUML class diagram is available at class_diagram.puml.
Render it with the PlantUML VS Code extension or at plantuml.com.