How aharikrishnan0810/ai_email-roadmap works
1. This is a single-process Python web application, not a distributed system. The architecture is a Flask-based monolith with separate modules for Gmail access, email extraction, classification, roadmap generation, persistence, and web rendering.
2. The main user entry point is the browser UI in templates/ plus static/. Users interact with pages like inbox, email detail, roadmap, and index; the frontend is mostly server-rendered HTML with a small amount of client-side JavaScript in static/js/app.js for actions like fetching or triggering updates.
3. main.py and app.py appear to be the application bootstrap and routing layer. This is the orchestration boundary: it receives HTTP requests, calls backend services, and returns rendered templates or JSON-like responses to the frontend.
4. gmail_service.py is the external integration layer. It handles Gmail API access through OAuth 2.0, pulling email data from Google as the system’s source of truth. This is the main outbound dependency and the first step in the email ingestion flow.
5. db.py provides local persistence, likely SQLite based on the README and file naming. The database stores fetched emails and related metadata so the app can display inbox history, deduplicate messages, and reuse previously processed content without re-querying Gmail every time.
6. extractor.py is the text normalization layer. It turns raw Gmail payloads into usable subject/body text and likely strips formatting or MIME noise so downstream modules work with clean content rather than raw email structures.
7. classifier.py is the intent-filtering subsystem. It distinguishes placement-related emails from general mail using heuristic or rule-based keyword logic, creating a boundary between noisy inbox content and messages worth generating roadmaps for.
8. roadmap.py is the AI synthesis layer. It takes extracted email content and converts it into a structured study or action roadmap, using Google Gemini as the external reasoning service. This is the second major outbound integration, and it is used after classification so only relevant emails trigger roadmap generation.
9. The main data flow is: Gmail API fetch → email extraction/normalization → classification → store in SQLite → render inbox/detail views → generate roadmap on demand. The roadmap generation path typically reads email content from the database, sends it to Gemini, and returns structured output for the roadmap page.
10. The app’s key boundaries are: Google services on the outside, Flask orchestration in the middle, and local persistence plus business logic inside. The UI is a thin presentation layer, while the real system behavior lives in the service modules.
11. templates/inbox.html, templates/email_detail.html, and templates/roadmap.html map to distinct workflow stages: inbox browsing, message inspection, and AI-generated planning. templates/index.html likely acts as the landing or control page for starting the email fetch and navigation flow.
12. Overall, the architecture is best drawn as a layered web application with two external systems: Gmail for input and Gemini for intelligence. SQLite is the local data store, Flask is the coordinator, and the domain modules implement email parsing, filtering, and roadmap creation.
Main entry points: app.py app.py · roadmap.py Roadmap · gmail_service.py Gmail Service · db.py db.py
Components 15
Presentation
Server-rendered UI and client-side assets
- Index · Landing and control page
templates/index.html - Inbox · Email list view
templates/inbox.html - Email Detail · Single-message inspection view
templates/email_detail.html - Roadmap · Generated plan display
templates/roadmap.html - app.js · Client-side actions and fetch triggers
static/js/app.js - style.css · UI styling
static/css/style.css
Web App
Flask bootstrap and request routing
Domain Logic
Email parsing, filtering, and roadmap generation
- Extractor · Turns raw message payloads into clean text
extractor.py - Classifier · Selects placement-related emails
classifier.py - Roadmap · Builds structured roadmap content
roadmap.py
External Services
Outbound APIs used by the app
- Gmail Service · OAuth-backed Gmail API access and email fetch
gmail_service.py - Gmail API · Source email system
- Gemini · Generative reasoning service
Connections 16
- main.py → app.py: starts · Bootstraps the Flask application
- app.py → Index: renders · Serves landing page
- app.py → Inbox: renders · Serves inbox view
- app.py → Email Detail: renders · Serves email detail view
- app.py → Roadmap: renders · Serves roadmap view
- app.py → app.js: serves · Provides client-side interaction layer
- app.py → Gmail Service: orchestrates · Triggers email sync and retrieval
- Gmail Service → Gmail API: fetches · Reads mail from Google
- Gmail Service → Extractor: hands off · Passes raw payloads for normalization
- Extractor → Classifier: feeds · Provides clean text for filtering
- Classifier → db.py: stores · Persists selected messages and metadata
- app.py → db.py: reads · Loads inbox and message state
- app.py → Roadmap: requests · Generates roadmap on demand
- Roadmap → db.py: reads · Uses stored email content as input
- Roadmap → Gemini: calls · Sends content for roadmap synthesis
- app.js → app.py: fetches · Invokes backend actions from the browser