# 7beshoyarnest/querymind architecture

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

- Interactive diagram: https://gitdiagram.com/7beshoyarnest/querymind
- Repository: https://github.com/7beshoyarnest/querymind

## Overview

QueryMind is a Gradio chatbot backed by a LangGraph agent that answers questions through SQL agents, document retrieval, and web search. The main workflow is user input → chatbot backend → agent graph, which either responds with an LLM or dispatches a tool and feeds its result back to the LLM. The README also documents vector-database preparation and configurable data sources. Edges reflect shown calls and documented setup; some implementation details, particularly travel SQL and vector preparation, were not excerpted.

Main entry points: [`src/agent_graph/build_full_graph.py`](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/build_full_graph.py) (Agent graph builder), [`src/agent_graph/agent_backend.py`](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/agent_backend.py) (Tool dispatch and routing), [`src/chatbot/chatbot_backend.py`](https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/chatbot_backend.py) (Chatbot backend), [`src/agent_graph/load_tools_config.py`](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/load_tools_config.py) (Tool configuration loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_gradio["Gradio chat UI<br/>[app.py]"]
  node_chatbot["Chatbot backend<br/>[chatbot_backend.py]"]
  node_memory[("Chat history<br/>[memory.py]")]
end

subgraph group_agent["Agent runtime"]
  node_graph_builder["Agent graph builder"]
  node_agent_backend["Tool dispatch and routing<br/>[agent_backend.py]"]
  node_primary_llm{{"Primary LLM"}}
end

subgraph group_tools["Query tools"]
  node_chinook["Chinook SQL agent"]
  node_travel["Travel SQL agent"]
  node_policy_rag["Policy document retrieval"]
  node_stories_rag["Stories retrieval"]
  node_tavily_tool["Web search tool"]
end

subgraph group_data["Data and configuration"]
  node_config_loader["Tool configuration loader"]
  node_project_config["Project configuration loader<br/>[load_config.py]"]
  node_tools_yaml["Tool settings<br/>[tools_config.yml]"]
  node_project_yaml["Project settings<br/>[project_config.yml]"]
  node_chinook_db[("Chinook database<br/>[Chinook.db]")]
  node_travel_db[("Travel database<br/>[travel.sqlite]")]
  node_policy_vectors[("Policy vector store")]
  node_story_vectors[("Stories vector store")]
  node_vector_prep["Vector database preparation"]
end

node_user(("User"))
node_groq{{"Groq model service"}}
node_tavily{{"Tavily search service"}}

node_user -->|"enters query"| node_gradio
node_gradio -->|"submits query"| node_chatbot
node_chatbot -->|"streams query"| node_graph_builder
node_chatbot -->|"writes history"| node_memory
node_graph_builder -->|"uses routing"| node_agent_backend
node_graph_builder -->|"binds tools"| node_primary_llm
node_primary_llm -.->|"calls model"| node_groq
node_graph_builder -->|"registers tool"| node_chinook
node_graph_builder -->|"registers tool"| node_travel
node_graph_builder -->|"registers tool"| node_policy_rag
node_graph_builder -->|"registers tool"| node_stories_rag
node_graph_builder -->|"creates and registers"| node_tavily_tool
node_agent_backend -.->|"dispatches tools"| node_chinook
node_agent_backend -.->|"dispatches tools"| node_travel
node_agent_backend -.->|"dispatches tools"| node_policy_rag
node_agent_backend -.->|"dispatches tools"| node_stories_rag
node_agent_backend -.->|"dispatches tools"| node_tavily_tool
node_tavily_tool -->|"searches web"| node_tavily
node_chinook -->|"queries database"| node_chinook_db
node_travel -.->|"queries database"| node_travel_db
node_policy_rag -->|"retrieves documents"| node_policy_vectors
node_stories_rag -->|"retrieves stories"| node_story_vectors
node_config_loader -->|"loads settings"| node_tools_yaml
node_project_config -.->|"loads settings"| node_project_yaml
node_chinook -->|"reads settings"| node_config_loader
node_policy_rag -->|"reads settings"| node_config_loader
node_stories_rag -->|"reads settings"| node_config_loader
node_chatbot -->|"loads tool settings"| node_config_loader
node_chatbot -->|"loads project settings"| node_project_config
node_vector_prep -.->|"prepares vector stores"| node_policy_vectors
node_vector_prep -.->|"prepares vector stores"| node_story_vectors

click node_gradio "https://github.com/7beshoyarnest/querymind/blob/main/src/app.py"
click node_chatbot "https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/chatbot_backend.py"
click node_memory "https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/memory.py"
click node_graph_builder "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/build_full_graph.py"
click node_agent_backend "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/agent_backend.py"
click node_config_loader "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/load_tools_config.py"
click node_project_config "https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/load_config.py"
click node_tools_yaml "https://github.com/7beshoyarnest/querymind/blob/main/configs/tools_config.yml"
click node_project_yaml "https://github.com/7beshoyarnest/querymind/blob/main/configs/project_config.yml"
click node_chinook "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_chinook_sqlagent.py"
click node_travel "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_travel_sqlagent.py"
click node_policy_rag "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_lookup_policy_rag.py"
click node_stories_rag "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_stories_rag.py"
click node_tavily_tool "https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_tavily_search.py"
click node_chinook_db "https://github.com/7beshoyarnest/querymind/blob/main/data/Chinook.db"
click node_travel_db "https://github.com/7beshoyarnest/querymind/blob/main/data/travel.sqlite"
click node_policy_vectors "https://github.com/7beshoyarnest/querymind/tree/main/data/airline_policy_vectordb"
click node_story_vectors "https://github.com/7beshoyarnest/querymind/tree/main/data/stories_vectordb"
click node_vector_prep "https://github.com/7beshoyarnest/querymind/blob/main/src/prepare_vector_db.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_gradio,node_chatbot,node_memory,node_user toneBlue
class node_graph_builder,node_agent_backend,node_primary_llm toneAmber
class node_chinook,node_travel,node_policy_rag,node_stories_rag,node_tavily_tool toneMint
class node_config_loader,node_project_config,node_tools_yaml,node_project_yaml,node_chinook_db,node_travel_db,node_policy_vectors,node_story_vectors,node_vector_prep toneRose
class node_groq,node_tavily toneIndigo
```

## Components

### Chat interface

- [Gradio chat UI](https://github.com/7beshoyarnest/querymind/blob/main/src/app.py): `src/app.py`
- [Chatbot backend](https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/chatbot_backend.py): `src/chatbot/chatbot_backend.py`
- [Chat history](https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/memory.py): `src/chatbot/memory.py`

### Agent runtime

- [Agent graph builder](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/build_full_graph.py): `src/agent_graph/build_full_graph.py`
- [Tool dispatch and routing](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/agent_backend.py): `src/agent_graph/agent_backend.py`
- **Primary LLM**

### Query tools

- [Chinook SQL agent](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_chinook_sqlagent.py): `src/agent_graph/tool_chinook_sqlagent.py`
- [Travel SQL agent](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_travel_sqlagent.py): `src/agent_graph/tool_travel_sqlagent.py`
- [Policy document retrieval](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_lookup_policy_rag.py): `src/agent_graph/tool_lookup_policy_rag.py`
- [Stories retrieval](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_stories_rag.py): `src/agent_graph/tool_stories_rag.py`
- [Web search tool](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/tool_tavily_search.py): `src/agent_graph/tool_tavily_search.py`

### Data and configuration

- [Tool configuration loader](https://github.com/7beshoyarnest/querymind/blob/main/src/agent_graph/load_tools_config.py): `src/agent_graph/load_tools_config.py`
- [Project configuration loader](https://github.com/7beshoyarnest/querymind/blob/main/src/chatbot/load_config.py): `src/chatbot/load_config.py`
- [Tool settings](https://github.com/7beshoyarnest/querymind/blob/main/configs/tools_config.yml): `configs/tools_config.yml`
- [Project settings](https://github.com/7beshoyarnest/querymind/blob/main/configs/project_config.yml): `configs/project_config.yml`
- [Chinook database](https://github.com/7beshoyarnest/querymind/blob/main/data/Chinook.db): `data/Chinook.db`
- [Travel database](https://github.com/7beshoyarnest/querymind/blob/main/data/travel.sqlite): `data/travel.sqlite`
- [Policy vector store](https://github.com/7beshoyarnest/querymind/tree/main/data/airline_policy_vectordb): `data/airline_policy_vectordb`
- [Stories vector store](https://github.com/7beshoyarnest/querymind/tree/main/data/stories_vectordb): `data/stories_vectordb`
- [Vector database preparation](https://github.com/7beshoyarnest/querymind/blob/main/src/prepare_vector_db.py): `src/prepare_vector_db.py`

### Other components

- **User**
- **Groq model service**
- **Tavily search service**

## Connections

- User → Gradio chat UI: enters query (evidence: `src/app.py`)
- Gradio chat UI → Chatbot backend: submits query (evidence: `src/app.py`)
- Chatbot backend → Agent graph builder: streams query (evidence: `src/chatbot/chatbot_backend.py`)
- Chatbot backend → Chat history: writes history (evidence: `src/chatbot/chatbot_backend.py`)
- Agent graph builder → Tool dispatch and routing: uses routing (evidence: `src/agent_graph/build_full_graph.py`)
- Agent graph builder → Primary LLM: binds tools (evidence: `src/agent_graph/build_full_graph.py`)
- Primary LLM → Groq model service: calls model
- Agent graph builder → Chinook SQL agent: registers tool (evidence: `src/agent_graph/build_full_graph.py`)
- Agent graph builder → Travel SQL agent: registers tool (evidence: `src/agent_graph/build_full_graph.py`)
- Agent graph builder → Policy document retrieval: registers tool (evidence: `src/agent_graph/build_full_graph.py`)
- Agent graph builder → Stories retrieval: registers tool (evidence: `src/agent_graph/build_full_graph.py`)
- Agent graph builder → Web search tool: creates and registers (evidence: `src/agent_graph/build_full_graph.py`)
- Tool dispatch and routing → Chinook SQL agent: dispatches tools
- Tool dispatch and routing → Travel SQL agent: dispatches tools
- Tool dispatch and routing → Policy document retrieval: dispatches tools
- Tool dispatch and routing → Stories retrieval: dispatches tools
- Tool dispatch and routing → Web search tool: dispatches tools
- Web search tool → Tavily search service: searches web (evidence: `src/agent_graph/tool_tavily_search.py`)
- Chinook SQL agent → Chinook database: queries database (evidence: `src/agent_graph/tool_chinook_sqlagent.py`)
- Travel SQL agent → Travel database: queries database
- Policy document retrieval → Policy vector store: retrieves documents (evidence: `src/agent_graph/tool_lookup_policy_rag.py`)
- Stories retrieval → Stories vector store: retrieves stories (evidence: `src/agent_graph/tool_stories_rag.py`)
- Tool configuration loader → Tool settings: loads settings (evidence: `src/agent_graph/load_tools_config.py`)
- Project configuration loader → Project settings: loads settings
- Chinook SQL agent → Tool configuration loader: reads settings (evidence: `src/agent_graph/tool_chinook_sqlagent.py`)
- Policy document retrieval → Tool configuration loader: reads settings (evidence: `src/agent_graph/tool_lookup_policy_rag.py`)
- Stories retrieval → Tool configuration loader: reads settings (evidence: `src/agent_graph/tool_stories_rag.py`)
- Chatbot backend → Tool configuration loader: loads tool settings (evidence: `src/chatbot/chatbot_backend.py`)
- Chatbot backend → Project configuration loader: loads project settings (evidence: `src/chatbot/chatbot_backend.py`)
- Vector database preparation → Policy vector store: prepares vector stores (evidence: `README.md`)
- Vector database preparation → Stories vector store: prepares vector stores (evidence: `README.md`)
