Smart Mail, an AI Email Assistant
Smart Mail reads your unread Gmail, drafts a reply with Google Gemini, lets you edit it, and sends it back into the same thread. A React + TypeScript front end talks to a Flask API, and Supabase handles accounts.
Routine email eats time, and generic AI drafts often aren't much better. They come back vague, unsigned, or full of placeholders like [briefly mention reason] that you have to fix by hand. The goal was a draft you could send after a quick read, with the person still in control of what goes out.
a few of the prompt rules (abridged) ↓
# generate_reply() → Gemini 1.5 Flash
1. Begin with: "Dear {sender_name},"
2. Address all points from the original message.
4. DO NOT include bracketed text like [suggest timeframe].
7. Use concrete timeframes like "48 hours".
8. End with: "Best regards,\n{user_name}"
Front end (React + TypeScript)
Supabase sign-up/sign-in, an inbox dashboard, email detail and reply form, a chat-style assistant widget, plus profile and settings pages.
Back end (Flask)
Blueprints for /check-auth, /unread, /generate-reply and /send-reply, all wrapping the Gmail API and Gemini.
Prompt rules plus post-processing
The prompt sets the structure (greeting with the sender's name, one paragraph per point, sign-off with your name), and a regex pass removes any bracketed placeholders the model still produces.
Replies stay in the thread
Sent replies carry the In-Reply-To and References headers plus Gmail's threadId, so they appear in the original conversation instead of as new emails.
Your instructions shape the draft
Optional extra context ("decline politely", "propose Thursday") is added to the prompt before generation.
Human in the loop
Nothing is sent automatically. Every draft is shown for review and editing first, and the command-line version lets you choose reply-to-sender, reply-all or custom recipients.