This project is a web application built with Flask, which allows users to log in with their Google account, fetch Gmail messages, and classify them as "Important" or "Not Important" using a machine learning model from Hugging Face. The application uses Hugging Face models for classification and summarization of emails.
- Google OAuth2 Login: Allows users to log in using their Google account.
- Fetch Gmail Emails: Retrieves the most recent emails from the user's Gmail account.
- Email Classification: Classifies emails into "Important" and "Not Important" categories using a Hugging Face model.
- Email Summarization: Summarizes the email body to provide users with a quick overview.
- Dashboard: Displays classified emails on the dashboard after logging in.
Before running this project, make sure you have the following installed:
- Python 3.x
- Pip (Python package manager)
-
Clone the repository:
git clone https://github.com/dmunasingha/gmail_summarizer cd gmail_summarizer
-
Create a virtual environment (optional but recommended):
python -m venv venv
-
Activate the virtual environment:
- On macOS/Linux:
source venv/bin/activate
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
-
Install the required dependencies:
pip install -r requirements.txt
To use Google OAuth2, you will need to set up OAuth2 credentials through the Google Developer Console.
- Go to Google Developer Console.
- Create a new project or select an existing one.
- Enable the Gmail API for the project.
- Go to APIs & Services > Credentials, and create new OAuth2 credentials.
- Download the
credentials.json
file and place it in the root of the project directory.
If you're using a Hugging Face model for email classification, you need to install the Hugging Face transformers
library and optionally set up an API key.
-
Install Hugging Face transformers:
pip install transformers
-
Set up your Hugging Face API key (optional if using a local model):
huggingface-cli login
-
Start the Flask app:
python app.py
-
Open your browser and go to
http://127.0.0.1:5000/
. -
Log in with your Google account, and the application will fetch your Gmail messages and classify them.
gmail_summarizer/
│
├── app.py # Flask application
├── requirements.txt # List of dependencies
├── credentials.json # Google OAuth2 credentials (Do not share this file)
├── static/ # Static files (CSS, JS, images)
├── templates/ # HTML templates for Flask
│ ├── index.html
│ └── dashboard.html
└── .gitignore # Git ignore file
- Flask
- Flask-OAuthlib
- Google API Python Client
- Hugging Face
transformers
- Requests
You can install the required dependencies using the following command:
pip install -r requirements.txt
This project is licensed under the MIT License - see the LICENSE file for details.
Dunith Munasingha: munasingha.dunith@gmail.com