How priyadharshanr31/email-processor works
Main Components
• Email Fetcher/Processor: Represented by email_processor.py. This module connects to the email server (using IMAP via imaplib) and extracts attachments from unread emails matching a specific subject.
• Email Sender: Represented by email_sender.py. This component creates and sends the processed file back to the sender (using smtplib, email, and mimetypes).
• File Processor: Represented by process_files.py. It handles reading the downloaded Excel file, applying the filter (e.g., based on a “Status” column), and merging the data into the predefined template (template.xlsx) using libraries like pandas and openpyxl.
• Streamlit UI: Defined in streamlit_ui.py. It provides an interactive interface for the user to preview data and specify the location where processed data should be inserted in the template.
• Configuration Module: config.py contains the email credentials and other settings that tailor the behavior of the email processor and sender.
• External Artifacts:
• Attachments Folder: Holds downloaded email attachments.
• Output Folder: Stores the processed files that have been merged with the template.
• Template File: template.xlsx serves as the baseline to which new data is added.
Relationships and Interactions
• The Email Processor connects to the email server where it finds unread emails and downloads Excel attachments into the attachments folder.
• The File Processor then reads these attachments, applies the data filter (based on criteria in process_files.py), and merges it into the template provided.
• The processed output is saved in the output folder.
• Finally, the Email Sender picks up this processed file and sends it back to the original sender, completing the loop.
• The config.py file is used by both email_processor.py and email_sender.py to configure connection and authentication parameters.
Architectural Patterns and Design Principles
• Modular Design: The project is clearly divided into small, single-responsibility modules (each Python file handles a specific aspect of the workflow).
• Pipeline Flow: The design envisions a linear, multi-stage workflow (from email fetching, data extraction/processing, to email sending) that can be visualized as sequential layers.
• UI-Backend Separation: The Streamlit UI (frontend) acts as a trigger or dashboard interface while all the heavy lifting is done in the backend scripts.
• Pipeline nature: starting with email fetching, then processing (data extraction and merging), and finally sending the processed file.
• How the Streamlit UI integrates with the processing flow by enabling the user to preview and adjust the inserted data position in the template.
• Use of key libraries like pandas and openpyxl in the data processing block, and imaplib/email/smtplib in the email interactions.
• That all key files and directories (attachments, output, and the template) are represented.