# raj-git07/e-mail-summariser-and-classifier architecture

> Architecture diagram of the GitHub repository raj-git07/e-mail-summariser-and-classifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raj-git07/e-mail-summariser-and-classifier
- Repository: https://github.com/raj-git07/e-mail-summariser-and-classifier

## Overview

This repository provides two email-intelligence workflows: a browser dashboard backed by FastAPI, and a local CLI that classifies Gmail messages and can summarize them. The web path covers OAuth, inbox retrieval, user-managed labels and stars, search, and on-demand summaries; the CLI path adds local classification and feedback-driven retraining. The graph preserves both modes and their shared external services. Some API and browser source is excerpted only, so edges for documented capabilities cite the README; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/app.py) (CLI workflow), [`api/index.py`](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py) (FastAPI routes), [`public/script.js`](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/script.js) (Dashboard behavior), [`email_summarizer.py`](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_summarizer.py) (CLI summary generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_dashboard["Dashboard interface<br/>[index.html]"]
  node_browser_logic["Dashboard behavior<br/>[script.js]"]
  node_browser_style["Responsive styling<br/>[style.css]"]
  node_local_storage[("Account token storage")]
end

subgraph group_api["Web API"]
  node_fastapi["FastAPI routes<br/>[index.py]"]
  node_web_mail["Web inbox retrieval<br/>[index.py]"]
  node_web_labels["Label and star updates<br/>[index.py]"]
  node_web_summary["Web summary generation<br/>[index.py]"]
end

subgraph group_cli["Local CLI"]
  node_cli_engine["CLI workflow<br/>[app.py]"]
  node_gmail_service["Local Gmail access"]
  node_email_message["Email message model<br/>[email_fetcher.py]"]
  node_cli_summary["CLI summary generation"]
  node_summary_config["Summary configuration<br/>[config.py]"]
end

subgraph group_ml["Classification and feedback"]
  node_classifier["Email classifier"]
  node_model_file[("Serialized classifier")]
  node_feedback_manager["Feedback management"]
  node_feedback_file[("Feedback records")]
end

node_user(("Email user"))
node_oauth["Google OAuth"]
node_gmail_api["Gmail API"]
node_openrouter["OpenRouter summaries"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"drives"| node_browser_logic
node_dashboard -->|"styled by"| node_browser_style
node_browser_logic -->|"stores tokens"| node_local_storage
node_browser_logic -->|"requests"| node_fastapi
node_fastapi -->|"serves"| node_dashboard
node_browser_logic -->|"redirects for login"| node_oauth
node_oauth -->|"returns credentials"| node_browser_logic
node_fastapi -->|"exchanges authorization"| node_oauth
node_fastapi -->|"routes inbox requests"| node_web_mail
node_web_mail -->|"fetches messages"| node_gmail_api
node_fastapi -->|"routes label updates"| node_web_labels
node_web_labels -->|"modifies labels"| node_gmail_api
node_fastapi -->|"routes summary requests"| node_web_summary
node_web_summary -->|"requests summary"| node_openrouter
node_user -->|"runs"| node_cli_engine
node_cli_engine -->|"authenticates and fetches"| node_gmail_service
node_gmail_service -->|"reads messages"| node_gmail_api
node_gmail_service -->|"authenticates"| node_oauth
node_cli_engine -->|"constructs messages"| node_email_message
node_cli_engine -->|"classifies messages"| node_classifier
node_classifier -->|"loads and saves"| node_model_file
node_cli_engine -->|"loads training data"| node_feedback_manager
node_feedback_manager -->|"reads and writes"| node_feedback_file
node_cli_engine -->|"re-trains"| node_classifier
node_cli_engine -->|"summarizes selected mail"| node_cli_summary
node_cli_summary -->|"formats message content"| node_email_message
node_cli_summary -->|"reads settings"| node_summary_config
node_cli_summary -->|"requests summary"| node_openrouter

click node_dashboard "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/index.html"
click node_browser_logic "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/script.js"
click node_browser_style "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/style.css"
click node_fastapi "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py"
click node_web_mail "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py"
click node_web_labels "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py"
click node_web_summary "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py"
click node_cli_engine "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/app.py"
click node_gmail_service "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/gmail_integration.py"
click node_email_message "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_fetcher.py"
click node_classifier "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.py"
click node_model_file "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.joblib"
click node_feedback_manager "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.py"
click node_feedback_file "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_feedback.json"
click node_cli_summary "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_summarizer.py"
click node_summary_config "https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_browser_logic,node_browser_style,node_local_storage,node_user toneBlue
class node_fastapi,node_web_mail,node_web_labels,node_web_summary toneAmber
class node_cli_engine,node_gmail_service,node_email_message,node_cli_summary,node_summary_config,node_gmail_api,node_openrouter toneMint
class node_classifier,node_model_file,node_feedback_manager,node_feedback_file toneRose
class node_oauth toneIndigo
```

## Components

### Web dashboard

- [Dashboard interface](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/index.html): `public/index.html`
- [Dashboard behavior](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/script.js): `public/script.js`
- [Responsive styling](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/public/style.css): `public/style.css`
- **Account token storage**

### Web API

- [FastAPI routes](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py): `api/index.py`
- [Web inbox retrieval](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py): `api/index.py`
- [Label and star updates](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py): `api/index.py`
- [Web summary generation](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/api/index.py): `api/index.py`

### Local CLI

- [CLI workflow](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/app.py): `app.py`
- [Local Gmail access](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/gmail_integration.py): `gmail_integration.py`
- [Email message model](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_fetcher.py): `email_fetcher.py`
- [CLI summary generation](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_summarizer.py): `email_summarizer.py`
- [Summary configuration](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/config.py): `config.py`

### Classification and feedback

- [Email classifier](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.py): `email_classifier.py`
- [Serialized classifier](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.joblib): `email_classifier.joblib`
- [Feedback management](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_classifier.py): `email_classifier.py`
- [Feedback records](https://github.com/raj-git07/e-mail-summariser-and-classifier/blob/main/email_feedback.json): `email_feedback.json`

### Other components

- **Email user**
- **Google OAuth**
- **Gmail API**
- **OpenRouter summaries**

## Connections

- Email user → Dashboard interface: uses (evidence: `README.md`)
- Dashboard interface → Dashboard behavior: drives (evidence: `README.md`)
- Dashboard interface → Responsive styling: styled by (evidence: `README.md`)
- Dashboard behavior → Account token storage: stores tokens (evidence: `README.md`)
- Dashboard behavior → FastAPI routes: requests (evidence: `public/script.js`)
- FastAPI routes → Dashboard interface: serves (evidence: `api/index.py`)
- Dashboard behavior → Google OAuth: redirects for login (evidence: `README.md`)
- Google OAuth → Dashboard behavior: returns credentials (evidence: `README.md`)
- FastAPI routes → Google OAuth: exchanges authorization (evidence: `README.md`)
- FastAPI routes → Web inbox retrieval: routes inbox requests (evidence: `api/index.py`)
- Web inbox retrieval → Gmail API: fetches messages (evidence: `api/index.py`)
- FastAPI routes → Label and star updates: routes label updates (evidence: `api/index.py`)
- Label and star updates → Gmail API: modifies labels (evidence: `api/index.py`)
- FastAPI routes → Web summary generation: routes summary requests (evidence: `api/index.py`)
- Web summary generation → OpenRouter summaries: requests summary (evidence: `README.md`)
- Email user → CLI workflow: runs (evidence: `README.md`)
- CLI workflow → Local Gmail access: authenticates and fetches (evidence: `app.py`)
- Local Gmail access → Gmail API: reads messages (evidence: `README.md`)
- Local Gmail access → Google OAuth: authenticates (evidence: `README.md`)
- CLI workflow → Email message model: constructs messages (evidence: `app.py`)
- CLI workflow → Email classifier: classifies messages (evidence: `app.py`)
- Email classifier → Serialized classifier: loads and saves (evidence: `email_classifier.py`)
- CLI workflow → Feedback management: loads training data (evidence: `app.py`)
- Feedback management → Feedback records: reads and writes (evidence: `email_classifier.py`)
- CLI workflow → Email classifier: re-trains (evidence: `app.py`)
- CLI workflow → CLI summary generation: summarizes selected mail (evidence: `app.py`)
- CLI summary generation → Email message model: formats message content (evidence: `email_summarizer.py`)
- CLI summary generation → Summary configuration: reads settings (evidence: `email_summarizer.py`)
- CLI summary generation → OpenRouter summaries: requests summary (evidence: `email_summarizer.py`)
