# tanishka-birdie/gmail-rag architecture

> Architecture diagram of the GitHub repository tanishka-birdie/gmail-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanishka-birdie/gmail-rag
- Repository: https://github.com/tanishka-birdie/gmail-rag

## Overview

Gmail RAG is a local inbox search-and-chat application. Its main workflow fetches Gmail messages, embeds and saves them locally, retrieves relevant messages for a question, and sends that context to Claude. The Gradio UI orchestrates both ingestion and multi-turn chat; a terminal query path is also documented. Edges follow the supplied source excerpts and README; local files and external services are shown as stores and integrations.

Main entry points: [`gmail-RAG/chatbot.py`](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/chatbot.py) (Gradio chatbot), [`gmail-RAG/query.py`](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py) (Vector retrieval), [`gmail-RAG/store_emails.py`](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/store_emails.py) (Embed and store), [`gmail-RAG/fetch_emails.py`](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/fetch_emails.py) (Gmail fetch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Email ingestion"]
  node_fetch["Gmail fetch<br/>[fetch_emails.py]"]
  node_store["Embed and store<br/>[store_emails.py]"]
  node_localdata[("Vectors and metadata")]
end

subgraph group_retrieval["Search and answering"]
  node_retrieve["Vector retrieval<br/>[query.py]"]
  node_prompt["Context and prompt<br/>[query.py]"]
end

subgraph group_interface["User interfaces"]
  node_gradio["Gradio chatbot<br/>[chatbot.py]"]
  node_terminal["Terminal query<br/>[query.py]"]
end

subgraph group_external["External services"]
  node_gmail[("Gmail inbox")]
  node_anthropic["Claude API"]
end

node_user(("User"))

node_user -->|"uses"| node_gradio
node_gradio -->|"fetches via"| node_fetch
node_fetch -->|"reads messages"| node_gmail
node_gradio -->|"stores via"| node_store
node_store -->|"fetches emails"| node_fetch
node_store -->|"writes embeddings"| node_localdata
node_gradio -->|"retrieves via"| node_retrieve
node_retrieve -->|"loads vectors"| node_localdata
node_retrieve -->|"builds context"| node_prompt
node_prompt -->|"sends prompt"| node_anthropic
node_gradio -->|"sends chat history"| node_anthropic
node_user -->|"asks questions"| node_terminal
node_terminal -->|"calls"| node_retrieve

click node_fetch "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/fetch_emails.py"
click node_store "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/store_emails.py"
click node_retrieve "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py"
click node_prompt "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py"
click node_gradio "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/chatbot.py"
click node_terminal "https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.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_fetch,node_store,node_localdata,node_user toneBlue
class node_retrieve,node_prompt toneAmber
class node_gradio,node_terminal toneMint
class node_gmail,node_anthropic toneRose
```

## Components

### Email ingestion

- [Gmail fetch](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/fetch_emails.py): `gmail-RAG/fetch_emails.py`
- [Embed and store](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/store_emails.py): `gmail-RAG/store_emails.py`
- **Vectors and metadata**

### Search and answering

- [Vector retrieval](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py): `gmail-RAG/query.py`
- [Context and prompt](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py): `gmail-RAG/query.py`

### User interfaces

- [Gradio chatbot](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/chatbot.py): `gmail-RAG/chatbot.py`
- [Terminal query](https://github.com/tanishka-birdie/gmail-rag/blob/main/gmail-RAG/query.py): `gmail-RAG/query.py`

### External services

- **Gmail inbox**
- **Claude API**

### Other components

- **User**

## Connections

- User → Gradio chatbot: uses (evidence: `README.md`)
- Gradio chatbot → Gmail fetch: fetches via (evidence: `gmail-RAG/chatbot.py`)
- Gmail fetch → Gmail inbox: reads messages (evidence: `gmail-RAG/fetch_emails.py`)
- Gradio chatbot → Embed and store: stores via (evidence: `gmail-RAG/chatbot.py`)
- Embed and store → Gmail fetch: fetches emails (evidence: `gmail-RAG/store_emails.py`)
- Embed and store → Vectors and metadata: writes embeddings (evidence: `gmail-RAG/store_emails.py`)
- Gradio chatbot → Vector retrieval: retrieves via (evidence: `gmail-RAG/chatbot.py`)
- Vector retrieval → Vectors and metadata: loads vectors (evidence: `gmail-RAG/query.py`)
- Vector retrieval → Context and prompt: builds context (evidence: `gmail-RAG/query.py`)
- Context and prompt → Claude API: sends prompt (evidence: `gmail-RAG/query.py`)
- Gradio chatbot → Claude API: sends chat history (evidence: `gmail-RAG/chatbot.py`)
- User → Terminal query: asks questions (evidence: `README.md`)
- Terminal query → Vector retrieval: calls (evidence: `gmail-RAG/query.py`)
