How stalpha2708/smart_email_assistant works
Project type and purpose
• This is a lightweight, single-service Python application (“smart_email_assistant”) that automates email-based task extraction and management.
• It connects to Gmail (IMAP/SMTP), parses incoming emails for tasks, persists them in a local SQLite database, and can display or send emails back.
File structure
Top-level
• ReadMe.md – installation & setup instructions
• smart_email_assistant/ – application source
Inside smart_email_assistant/
• .env – environment variables (GMAIL creds)
• db.py – database adapter (SQLite)
• email_reader.py – IMAP/HTTP layer for fetching emails
• email_sender.py – SMTP layer for sending emails
• task_extractor.py – domain logic (NLP/rules to find “tasks” in email content)
• view_tasks.py – presentation layer (CLI view of tasks)
• main.py – orchestration: wire up reader → extractor → storage → view/sender
• tasks.db – persisted SQLite database file
• .gitignore, __pycache__ – housekeeping
README for additional insights
• Dependencies: python-dotenv (load .env), requests (if used for API calls), standard libs (imaplib, smtplib, sqlite3)
• Gmail App Password is required (security boundary)
a. Main components
1. User / CLI: entrypoint (main.py)
2. Email Service (Gmail IMAP/SMTP)
3. Application modules:
• Email Reader adapter
• Task Extractor (domain logic)
• Database Adapter (SQLite, via db.py)
• Email Sender adapter
• View/Presentation (view_tasks.py)
b. Relationships & interactions (data flow)
1. User invokes main.py with a command (e.g., “extract‐tasks” or “view‐tasks”)
2. main.py loads .env → credentials → calls Email Reader
3. Email Reader fetches new messages from Gmail IMAP
4. main.py passes raw email data to Task Extractor
5. Task Extractor returns structured task objects
6. main.py calls Database Adapter to save tasks into tasks.db
7. For “view‐tasks”, main.py calls View/Presentation to fetch & display tasks
8. If configured, main.py calls Email Sender to send summary/follow-up via SMTP
9. Email Sender → Gmail SMTP → external
c. Architectural patterns & design principles
• Layered Architecture:
– Adapters (Email Reader/Sender, DB) isolate external interfaces
– Domain Services (Task Extractor) encapsulate business logic
– Orchestrator (main) coordinates flows
– Presentation (view_tasks) handles user output
• Single Responsibility per module
• Dependency Injection via main.py wiring
• Environment-based configuration for secrets
d. Key technologies & libraries
• Python 3.x
• python-dotenv (configuration)
• imaplib/smtplib or requests (email I/O)
• sqlite3 (lightweight, file-based DB)
• NLP/regex (inside task_extractor)