# priyanshg786/deep_agent architecture

> Architecture diagram of the GitHub repository priyanshg786/deep_agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshg786/deep_agent
- Repository: https://github.com/priyanshg786/deep_agent

## Overview

Deep Agent Chat is a Streamlit assistant that authenticates users, manages chat sessions, and routes prompts to conversational, document-retrieval, or live-research handling. The main workflow starts in the UI and enters the agent; PDF ingestion and retrieval use PostgreSQL/pgvector, while research accesses MCP web and weather tools. Session conversation memory is held in the agent process. The graph reflects documented capabilities, but some UI-to-RAG wiring is only visible through the source index and README, not the partial UI excerpt.

Main entry points: [`agent_copy.py`](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py) (Agent Orchestrator), [`stream_app.py`](https://github.com/priyanshg786/deep_agent/blob/main/stream_app.py) (Streamlit UI), [`rag_pgvector.py`](https://github.com/priyanshg786/deep_agent/blob/main/rag_pgvector.py) (PDF Ingestion & Search), [`tavily_mcp_server.py`](https://github.com/priyanshg786/deep_agent/blob/main/tavily_mcp_server.py) (Tavily MCP Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat Experience"]
  node_stream["Streamlit UI<br/>[stream_app.py]"]
  node_auth["Account Auth<br/>[auth.py]"]
  node_titles["Chat Titles<br/>[title_app.py]"]
end

subgraph group_agent["Agent Runtime"]
  node_agent_entry["Agent Orchestrator<br/>[agent_copy.py]"]
  node_routing{{"Query Router<br/>[agent_copy.py]"}}
  node_chat["Chat Response<br/>[agent_copy.py]"]
  node_memory[("Session Memory<br/>[agent_copy.py]")]
  node_planner["Research Planner<br/>[agent_copy.py]"]
  node_research["Research Synthesis<br/>[agent_copy.py]"]
end

subgraph group_knowledge["Document Retrieval"]
  node_rag["PDF Ingestion &amp; Search<br/>[rag_pgvector.py]"]
  node_pgvector[("PostgreSQL pgvector")]
end

subgraph group_integrations["Research Integrations"]
  node_tavily_server["Tavily MCP Server"]
  node_weather_server["Weather MCP Server<br/>[weather_mcp1.py]"]
end

node_user(("User"))
node_tavily_api["Tavily Search API"]
node_open_meteo["Open-Meteo APIs"]

node_user -->|"submits prompt"| node_stream
node_stream -->|"authenticates accounts"| node_auth
node_stream -->|"runs prompt"| node_agent_entry
node_stream -->|"generates title"| node_titles
node_stream -->|"uploads PDFs"| node_rag
node_agent_entry -->|"selects route"| node_routing
node_agent_entry -->|"checks and searches"| node_rag
node_agent_entry -->|"reads and updates"| node_memory
node_agent_entry -->|"invokes chat"| node_chat
node_agent_entry -->|"invokes research"| node_research
node_research -->|"plans searches"| node_planner
node_rag -->|"stores and retrieves"| node_pgvector
node_research -->|"calls MCP tools"| node_tavily_server
node_research -->|"connects MCP"| node_weather_server
node_tavily_server -->|"searches web"| node_tavily_api
node_weather_server -->|"geocodes and forecasts"| node_open_meteo

click node_stream "https://github.com/priyanshg786/deep_agent/blob/main/stream_app.py"
click node_auth "https://github.com/priyanshg786/deep_agent/blob/main/auth.py"
click node_titles "https://github.com/priyanshg786/deep_agent/blob/main/title_app.py"
click node_agent_entry "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_routing "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_chat "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_memory "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_planner "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_research "https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py"
click node_rag "https://github.com/priyanshg786/deep_agent/blob/main/rag_pgvector.py"
click node_tavily_server "https://github.com/priyanshg786/deep_agent/blob/main/tavily_mcp_server.py"
click node_weather_server "https://github.com/priyanshg786/deep_agent/blob/main/weather_mcp1.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_stream,node_auth,node_titles,node_user toneBlue
class node_agent_entry,node_routing,node_chat,node_memory,node_planner,node_research toneAmber
class node_rag,node_pgvector,node_tavily_api,node_open_meteo toneMint
class node_tavily_server,node_weather_server toneRose
```

## Components

### Chat Experience

- [Streamlit UI](https://github.com/priyanshg786/deep_agent/blob/main/stream_app.py): `stream_app.py`
- [Account Auth](https://github.com/priyanshg786/deep_agent/blob/main/auth.py): `auth.py`
- [Chat Titles](https://github.com/priyanshg786/deep_agent/blob/main/title_app.py): `title_app.py`

### Agent Runtime

- [Agent Orchestrator](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`
- [Query Router](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`
- [Chat Response](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`
- [Session Memory](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`
- [Research Planner](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`
- [Research Synthesis](https://github.com/priyanshg786/deep_agent/blob/main/agent_copy.py): `agent_copy.py`

### Document Retrieval

- [PDF Ingestion & Search](https://github.com/priyanshg786/deep_agent/blob/main/rag_pgvector.py): `rag_pgvector.py`
- **PostgreSQL pgvector**

### Research Integrations

- [Tavily MCP Server](https://github.com/priyanshg786/deep_agent/blob/main/tavily_mcp_server.py): `tavily_mcp_server.py`
- [Weather MCP Server](https://github.com/priyanshg786/deep_agent/blob/main/weather_mcp1.py): `weather_mcp1.py`

### Other components

- **User**
- **Tavily Search API**
- **Open-Meteo APIs**

## Connections

- User → Streamlit UI: submits prompt (evidence: `readme.md`)
- Streamlit UI → Account Auth: authenticates accounts (evidence: `stream_app.py`)
- Streamlit UI → Agent Orchestrator: runs prompt (evidence: `stream_app.py`)
- Streamlit UI → Chat Titles: generates title (evidence: `stream_app.py`)
- Streamlit UI → PDF Ingestion & Search: uploads PDFs (evidence: `readme.md`)
- Agent Orchestrator → Query Router: selects route (evidence: `agent_copy.py`)
- Agent Orchestrator → PDF Ingestion & Search: checks and searches (evidence: `agent_copy.py`)
- Agent Orchestrator → Session Memory: reads and updates (evidence: `agent_copy.py`)
- Agent Orchestrator → Chat Response: invokes chat (evidence: `agent_copy.py`)
- Agent Orchestrator → Research Synthesis: invokes research (evidence: `agent_copy.py`)
- Research Synthesis → Research Planner: plans searches (evidence: `agent_copy.py`)
- PDF Ingestion & Search → PostgreSQL pgvector: stores and retrieves (evidence: `rag_pgvector.py`)
- Research Synthesis → Tavily MCP Server: calls MCP tools (evidence: `agent_copy.py`)
- Research Synthesis → Weather MCP Server: connects MCP (evidence: `agent_copy.py`)
- Tavily MCP Server → Tavily Search API: searches web (evidence: `tavily_mcp_server.py`)
- Weather MCP Server → Open-Meteo APIs: geocodes and forecasts (evidence: `weather_mcp1.py`)
