Getting Started
This guide will help you set up the Email Assistant on your machine.
Prerequisitesโ
| Requirement | Version |
|---|---|
| Python | 3.11+ |
| Gmail Account | Personal or Google Workspace |
| Google Cloud Project | For Gmail API |
| Gemini API Key | For AI categorization |
Installationโ
1. Clone Repositoryโ
git clone https://github.com/YOUR_USERNAME/emailAssistant.git
cd emailAssistant
2. Create Virtual Environmentโ
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
3. Install Dependenciesโ
# Core dependencies
pip install -r requirements.txt
# For development and testing
pip install -r requirements-dev.txt
4. Configure Gmail APIโ
Create Google Cloud Projectโ
- Go to Google Cloud Console
- Create a new project
- Enable Gmail API
- Enable Google Calendar API (optional)
- Enable Google Tasks API (optional)
Create OAuth Credentialsโ
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Desktop app
- Download
credentials.json - Place in project root
5. Set Gemini API Keyโ
Get your key from Google AI Studio
export GOOGLE_API_KEY='your_api_key_here'
# Add to shell profile for persistence
echo 'export GOOGLE_API_KEY="your_api_key_here"' >> ~/.bashrc
source ~/.bashrc
6. Create Directoriesโ
mkdir -p data/cache data/digest data/metrics data/test_results logs config
7. Configure Applicationโ
cp config/config.example.json config/config.json
Edit config/config.json:
{
"api_settings": {
"gemini_model": "gemini-2.5-flash-lite",
"requests_per_minute": 30,
"max_retries": 3,
"timeout_seconds": 30
},
"gmail_settings": {
"max_emails_to_fetch": 10,
"search_query": "is:unread newer_than:1d"
},
"cache_settings": {
"enabled": true,
"max_cached_emails": 30,
"cache_expiry_hours": 24
}
}
Running the Applicationโ
First Run (CLI)โ
python src/main.py
On first run, you'll be prompted to authenticate:
- Browser opens automatically
- Sign in with your Google account
- Grant permissions
- Token saved to
token.json
Web Interfaceโ
# Start the server
./scripts/start_server.sh
# or
python src/web/server.py
Open: http://localhost:8001
Project Structureโ
emailAssistant/
โโโ src/
โ โโโ main.py # CLI entry point
โ โโโ utils/ # Utility modules
โ โ โโโ email_utils.py # Gmail API operations
โ โ โโโ gemini_utils.py # Gemini AI operations
โ โ โโโ display_utils.py # Digest generation
โ โ โโโ logger_utils.py # Logging configuration
โ โ โโโ metrics_utils.py # Metrics tracking (SQLite)
โ โโโ core/ # Core modules
โ โ โโโ config_manager.py
โ โ โโโ cache_manager.py
โ โโโ web/ # Web interface
โ โโโ server.py # Flask server
โ โโโ templates/ # HTML templates
โ โโโ static/ # CSS and JavaScript
โโโ config/
โ โโโ config.json # Configuration
โโโ data/
โ โโโ cache/ # Email cache
โ โโโ digest/ # Digest data
โ โโโ metrics/ # SQLite database
โโโ logs/
โ โโโ email_assistant.log
โโโ tests/ # Test suite
โโโ requirements.txt
Troubleshootingโ
"No digest data available"โ
Run the main script first:
python src/main.py
"Lock file stuck"โ
If the "Refreshing..." button won't reset:
rm script.lock
"credentials.json not found"โ
Download from Google Cloud Console and place in project root.
"GOOGLE_API_KEY not set"โ
Export the environment variable:
export GOOGLE_API_KEY='your_key_here'
Port Conflictโ
lsof -i :8001
kill -9 <PID>
Import Errorsโ
cd /path/to/emailAssistant
source .venv/bin/activate
pip install -r requirements.txt
Security Notesโ
NEVER commit these files:
credentials.json- OAuth credentialstoken.json- Access tokenconfig/config.json- May contain sensitive datadata/- Contains personal email data.env- Environment variables
These are protected by .gitignore.