# jaswanthsai14/gmail-automation-tool architecture

> Architecture diagram of the GitHub repository jaswanthsai14/gmail-automation-tool, 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/jaswanthsai14/gmail-automation-tool
- Repository: https://github.com/jaswanthsai14/gmail-automation-tool

## Overview

This repository is a Gmail AI assistant: a user submits a request through the Gradio chat interface, a LangGraph workflow routes it to email chat, summaries, drafting, or automation, and the result is formatted for display. The workflow reads and writes ChromaDB memory and uses Gmail services; sending and replying are delegated to Celery tasks. A FastMCP server exposes retrieval, reply, spam-storage, and summarization tools. Internal workflow wiring is only partly excerpted, so documented routes use README evidence; no unshown implementation details are assumed.

Main entry points: [`agent.py`](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py) (Intent routing), [`chroma_l.py`](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/chroma_l.py) (ChromaDB memory), [`server.py`](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py) (FastMCP server), [`auth.py`](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/auth.py) (Gmail authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_assistant["Assistant workflow"]
  node_chat_ui["Gradio chat<br/>[agent.py]"]
  node_workflow["LangGraph workflow<br/>[agent.py]"]
  node_intent["Intent routing<br/>[agent.py]"]
  node_sender_summary["Sender summary<br/>[agent.py]"]
  node_email_chat["Email history chat<br/>[agent.py]"]
  node_unread_summary["Unread summary<br/>[agent.py]"]
  node_automation["Email automation<br/>[agent.py]"]
  node_compose["Email drafting<br/>[agent.py]"]
  node_formatter["Response formatter<br/>[agent.py]"]
end

subgraph group_gmail["Gmail operations"]
  node_gmail_auth["Gmail authentication<br/>[auth.py]"]
  node_task_queue["Celery tasks<br/>[messaging.py]"]
end

subgraph group_tools["MCP tools"]
  node_mcp_server["FastMCP server<br/>[server.py]"]
  node_retriever["Email retriever<br/>[server.py]"]
  node_reply_tool["Reply tool<br/>[server.py]"]
  node_spam_tool["Spam storage<br/>[server.py]"]
  node_spam_log["Spam log<br/>[spam.txt]"]
  node_summarize_tool["Ollama summarizer<br/>[server.py]"]
end

subgraph group_memory["Memory and tasks"]
  node_memory_db[("ChromaDB memory<br/>[chroma_l.py]")]
end

node_user(("User"))
node_gmail_api["Gmail API"]
node_redis["Redis broker"]

node_user -->|"submits prompt"| node_chat_ui
node_chat_ui -->|"invokes workflow"| node_workflow
node_workflow -->|"routes request"| node_intent
node_intent -->|"routes to"| node_sender_summary
node_intent -->|"routes to"| node_email_chat
node_intent -->|"routes to"| node_unread_summary
node_intent -->|"routes to"| node_compose
node_intent -->|"routes to"| node_automation
node_sender_summary -->|"reads messages"| node_gmail_auth
node_sender_summary -->|"stores summary"| node_memory_db
node_email_chat -->|"retrieves history"| node_memory_db
node_unread_summary -->|"reads messages"| node_gmail_auth
node_unread_summary -->|"stores email content"| node_memory_db
node_automation -->|"reads messages"| node_gmail_auth
node_automation -->|"stores results"| node_memory_db
node_compose -->|"retrieves context"| node_memory_db
node_compose -->|"queues send"| node_task_queue
node_workflow -->|"formats response"| node_formatter
node_formatter -->|"returns response"| node_chat_ui
node_gmail_auth -->|"builds service"| node_gmail_api
node_task_queue -->|"uses broker"| node_redis
node_task_queue -->|"sends message"| node_gmail_auth
node_workflow -->|"uses tools"| node_mcp_server
node_mcp_server -->|"registers tool"| node_retriever
node_mcp_server -->|"registers tool"| node_reply_tool
node_mcp_server -->|"registers tool"| node_spam_tool
node_mcp_server -->|"registers tool"| node_summarize_tool
node_retriever -->|"retrieves documents"| node_memory_db
node_reply_tool -->|"queues reply"| node_task_queue
node_spam_tool -->|"appends records"| node_spam_log
node_summarize_tool -.->|"uses embeddings"| node_memory_db

click node_chat_ui "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_workflow "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_intent "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_sender_summary "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_email_chat "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_unread_summary "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_automation "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_compose "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_formatter "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py"
click node_gmail_auth "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/auth.py"
click node_task_queue "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/messaging.py"
click node_mcp_server "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py"
click node_retriever "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py"
click node_reply_tool "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py"
click node_spam_tool "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py"
click node_spam_log "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/spam.txt"
click node_summarize_tool "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py"
click node_memory_db "https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/chroma_l.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_chat_ui,node_workflow,node_intent,node_sender_summary,node_email_chat,node_unread_summary,node_automation,node_compose,node_formatter,node_user toneBlue
class node_gmail_auth,node_task_queue,node_redis toneAmber
class node_mcp_server,node_retriever,node_reply_tool,node_spam_tool,node_spam_log,node_summarize_tool,node_gmail_api toneMint
class node_memory_db toneRose
```

## Components

### Assistant workflow

- [Gradio chat](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [LangGraph workflow](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Intent routing](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Sender summary](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Email history chat](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Unread summary](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Email automation](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Email drafting](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`
- [Response formatter](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/agent.py): `agent.py`

### Gmail operations

- [Gmail authentication](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/auth.py): `auth.py`
- [Celery tasks](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/messaging.py): `messaging.py`

### MCP tools

- [FastMCP server](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py): `server.py`
- [Email retriever](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py): `server.py`
- [Reply tool](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py): `server.py`
- [Spam storage](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py): `server.py`
- [Spam log](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/spam.txt): `spam.txt`
- [Ollama summarizer](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/server.py): `server.py`

### Memory and tasks

- [ChromaDB memory](https://github.com/jaswanthsai14/gmail-automation-tool/blob/main/chroma_l.py): `chroma_l.py`

### Other components

- **User**
- **Gmail API**
- **Redis broker**

## Connections

- User → Gradio chat: submits prompt (evidence: `README.md`)
- Gradio chat → LangGraph workflow: invokes workflow (evidence: `agent.py`)
- LangGraph workflow → Intent routing: routes request (evidence: `README.md`)
- Intent routing → Sender summary: routes to (evidence: `README.md`)
- Intent routing → Email history chat: routes to (evidence: `README.md`)
- Intent routing → Unread summary: routes to (evidence: `README.md`)
- Intent routing → Email drafting: routes to (evidence: `README.md`)
- Intent routing → Email automation: routes to (evidence: `README.md`)
- Sender summary → Gmail authentication: reads messages (evidence: `agent.py`)
- Sender summary → ChromaDB memory: stores summary (evidence: `agent.py`)
- Email history chat → ChromaDB memory: retrieves history (evidence: `agent.py`)
- Unread summary → Gmail authentication: reads messages (evidence: `agent.py`)
- Unread summary → ChromaDB memory: stores email content (evidence: `agent.py`)
- Email automation → Gmail authentication: reads messages (evidence: `agent.py`)
- Email automation → ChromaDB memory: stores results (evidence: `agent.py`)
- Email drafting → ChromaDB memory: retrieves context (evidence: `agent.py`)
- Email drafting → Celery tasks: queues send (evidence: `agent.py`)
- LangGraph workflow → Response formatter: formats response (evidence: `README.md`)
- Response formatter → Gradio chat: returns response (evidence: `README.md`)
- Gmail authentication → Gmail API: builds service (evidence: `auth.py`)
- Celery tasks → Redis broker: uses broker (evidence: `messaging.py`)
- Celery tasks → Gmail authentication: sends message (evidence: `messaging.py`)
- LangGraph workflow → FastMCP server: uses tools (evidence: `README.md`)
- FastMCP server → Email retriever: registers tool (evidence: `server.py`)
- FastMCP server → Reply tool: registers tool (evidence: `server.py`)
- FastMCP server → Spam storage: registers tool (evidence: `server.py`)
- FastMCP server → Ollama summarizer: registers tool (evidence: `server.py`)
- Email retriever → ChromaDB memory: retrieves documents (evidence: `server.py`)
- Reply tool → Celery tasks: queues reply (evidence: `server.py`)
- Spam storage → Spam log: appends records (evidence: `server.py`)
- Ollama summarizer → ChromaDB memory: uses embeddings (evidence: `server.py`)
