A modern web application that blends Gmail automation with AI-powered summaries and label suggestions so teams can triage every inbox with confidence.
- Login page now highlights the Custom AI Model offering right alongside product/security cards so visitors see the feature before authenticating.
- The login hero references the AI model as part of the product narrative and points to the documentation for generating summaries post-login.
Email Management
- Card-based dashboard with adjustable 1-3 column layouts, search, pagination, and quick All/Inboxes shortcuts
- Multi-select with bulk delete plus per-email delete (mirrors Gmail trash)
- Email detail page redesigned to match the dashboard style with structured metadata and footer actions
Intelligent Labeling
- Hierarchical label tree synced from Gmail (system folders hidden or relocated automatically)
- Drag-and-drop single or multi-selected emails onto labels; Inbox is removed automatically unless you opt out
- Label dropdown in the detail view mirrors the tree logic and syncs changes back to Gmail instantly
User Accounts & Access
- Google OAuth-only login; every action runs on behalf of the signed-in Google Workspace user
- Settings page for personal preferences (auto-sync cadence, Inbox retention toggle, drag-and-drop behavior)
- Admin console for tenant-wide Gmail/OpenAI configuration and user-scoped maintenance commands
Modern Interface
- Sticky header with brand mark, live status cards, and quick actions (Settings, Admin, Logout)
- Hero banner with workflow messaging, auto-sync status, and toolbar for layout/search/bulk delete
- Responsive CSS design system applied consistently across dashboard, email detail, admin, and settings
AI Workflows
- OpenAI-powered summaries replace raw body previews and now render directly beneath the message details with the AI-label icon to highlight their provenance.
- AI suggestions reuse that same icon so both cards and the detail view feel consistent, and clicking a chip applies exactly that label to Gmail.
- Custom AI model training surfaces fine-tuned classifiers and is highlighted on the login hero as part of the product experience.
- Clicking an AI chip applies the label immediately and syncs it to Gmail; Inbox retention obeys user preference
Automation & Sync
- Manual sync with streaming Server-Sent Events feedback (connecting, processing, cleaning, etc.)
- Optional auto sync every n minutes per user; runs silently and updates the "last refreshed" banner text
- Label refresh is part of every sync; drag-and-drop/manual label changes notify Gmail in real time
- Backend: Python (Flask) with Blueprints, Flask-Login, Flask-WTF, and streaming SSE endpoints
- Database: SQLAlchemy ORM on SQLite (default) with lightweight migration helper (
scripts/upgrade_schema.py) - Frontend: Jinja2 templates, custom CSS design system, and vanilla JavaScript modules (
dashboard.js, etc.) - AI: OpenAI API for label suggestions + card summaries, with heuristics in
app/utils/ai_labeler.py - Integrations: Google OAuth 2.0 + Gmail API (labels, message fetch, trash, drag-and-drop syncing)
- Python 3.8+
pip- Google Cloud project with Gmail API enabled
- Clone the repository and move into the folder:
git clone <repo-url> cd Mailosophy
- Create and activate a virtual environment:
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Copy the example environment file and update the values:
Key variables:
cp .env.example .env
FLASK_APP=main.py FLASK_ENV=development SECRET_KEY=your-secret-key-here DATABASE_URL=sqlite:///Mailosophy.db GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=... GOOGLE_REDIRECT_URI=http://localhost:5000/auth/google/callback OPENAI_API_KEY=... - Run the lightweight schema upgrade (creates/updates tables such as
users.last_synced_at):python scripts/upgrade_schema.py
python main.pyVisit http://localhost:5000 and sign in with Google to begin.
- Click Continue with Google on the login screen.
- Approve the Gmail/Workspace scopes.
- You are redirected to the dashboard once OAuth succeeds.
- Press Sync Emails on the hero banner.
- Watch the real-time progress messages (connecting, fetching, cleaning, etc.).
- Enable auto sync in Settings ? Preferences & Automation to run silent refreshes every n minutes.
- The hero status pill displays whether auto sync is enabled and when the last sync finished.
- Browse the Gmail label tree in the sidebar (Inbox lives outside the tree for clarity).
- Click + New Label to create custom tags; they sync to Gmail immediately.
- Drag and drop one or many emails onto a label to move them and (optionally) remove Inbox.
- Use the email detail dropdown to add/remove labels with the same logic as the tree.
- Open any message and click Generate Suggestions on the detail page or on a card.
- AI chips appear both on the detail view and on the dashboard cards.
- Click a chip to apply that label; Gmail is updated instantly.
- Card summaries are AI-authored so you can triage without opening every email, with cached summaries reloaded on page load and refreshable via the Generate Summary button.
- Use the search input for sender/subject/content queries.
- Filter by label nodes or use the All/Inbox quick cards.
- Adjust Cards per row (1/2/3) to match your screen width.
- Multi-select emails to delete them in bulk (deletions sync to Gmail trash).
- Settings: configure auto-sync cadence, Inbox retention for manual labels, drag-and-drop rules, the new auto-add training examples toggle, delete confirmation options, and other user-specific controls.
Mailosophy/
+-- app/
+-- __init__.py # Flask app factory
+-- routes.py # Blueprints (main, auth, email, label)
+-- models/ # SQLAlchemy models (user, email, label, app_config)
+-- utils/ # Gmail helper, AI labeler, OpenAI helper, celery utils
+-- templates/ # base.html, dashboard.html, email_detail.html, admin.html, etc.
+-- static/ # css/style.css, js/dashboard.js, img/logo.svg, ai-label.svg, ...
+-- scripts/
+-- upgrade_schema.py # Lightweight migration helper
+-- docs/ # Setup guides, OAuth walkthroughs, implementation summary
+-- backups/ # Reference copies (pre-IMAP removal)
+-- main.py # Application entry point
+-- requirements.txt # Python dependencies
+-- .env / .env.example # Environment configuration
+-- README.md
- Attachment viewer and Gmail thread context
- Inline reply/forward powered by Gmail send scopes
- Notification center for AI and sync events
- Advanced filtering (date ranges, AI confidence, label combos)
- Team workspaces with audit trails
GET /auth/loginGoogle OAuth entry pointGET /auth/logoutSign outGET /dashboardMain UI (server-rendered)POST /email/syncSSE endpoint to sync Gmail messagesPOST /email/<id>/labelsAssign labels (also triggered via drag-and-drop/AJAX)DELETE /email/<id>/labels/<label_id>Remove labelsPOST /email/<id>/deleteTrash an email in Gmail and the local DBPOST /labels/createCreate custom labels and sync to Gmail
(Additional admin/settings endpoints exist but are primarily exercised through the UI.)
"Email sync not working"
- Ensure you are signed in with Google (banner shows connection status).
- Re-run the Google OAuth flow if you see
401 Invalid Credentials(token revoked). - Check server logs for Gmail quota errors or OpenAI failures.
- Verify
.envcontains valid OpenAI + Google credentials and thatscripts/upgrade_schema.pyhas been run.
Pull requests and issue reports are welcome! Please open an issue first if you plan a large change.
MIT License.
Need help or have ideas? Open an issue in this repository.
Credit the updated UI with sanitized imagery captured locally under . The example below uses placeholder filenames and masked email addresses (e.g., ) to avoid leaking real data:


