# mailrate-gmail/dify-sqlbot architecture

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

- Interactive diagram: https://gitdiagram.com/mailrate-gmail/dify-sqlbot
- Repository: https://github.com/mailrate-gmail/dify-sqlbot

## Overview

This repository packages a Dify + SQLBot demo environment. The main user flow is to submit a natural-language question in a Dify workflow, invoke the SQLBot MCP adapter, and return a formatted answer; SQLBot can query a configured PostgreSQL source, optionally reached through the local bridge. The repository also provides business-data import assets and deployment configuration. Relationships for unsampled deployment and integration files are based on README statements; the adapter’s request handling and formatting are supported by the excerpted source.

Main entry points: [`sqlbot-dify-mcp/sqlbot_dify_mcp.py`](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/sqlbot-dify-mcp/sqlbot_dify_mcp.py) (MCP adapter), [`scripts/import_business_data.sh`](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/scripts/import_business_data.sh) (Business data importer), [`dify-apps/integrated-sqlbot-demo.yml`](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/dify-apps/integrated-sqlbot-demo.yml) (Dify demo workflow), [`docker-compose.sqlbot.yaml`](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/docker-compose.sqlbot.yaml) (SQLBot service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Applications"]
  node_workflow["Dify demo workflow"]
  node_dify["Dify services"]
  node_sqlbot["SQLBot service"]
end

subgraph group_integration["MCP integration"]
  node_adapter["MCP adapter<br/>[sqlbot_dify_mcp.py]"]
  node_formatter["Answer formatter<br/>[sqlbot_dify_mcp.py]"]
end

subgraph group_data["Data and access"]
  node_dbsource[("Business PostgreSQL")]
  node_proxy["Local DB proxy"]
  node_importer["Business data importer"]
  node_seed["Business schema and data"]
end

node_user(("Workflow user"))

node_user -->|"submits question"| node_workflow
node_workflow -->|"runs in"| node_dify
node_dify -->|"invokes MCP"| node_adapter
node_adapter -->|"calls API"| node_sqlbot
node_adapter -->|"formats answer"| node_formatter
node_sqlbot -->|"connects through"| node_proxy
node_proxy -->|"forwards traffic"| node_dbsource
node_importer -->|"imports SQL"| node_seed
node_importer -->|"loads data into"| node_dbsource

click node_workflow "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/dify-apps/integrated-sqlbot-demo.yml"
click node_sqlbot "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/docker-compose.sqlbot.yaml"
click node_adapter "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/sqlbot-dify-mcp/sqlbot_dify_mcp.py"
click node_formatter "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/sqlbot-dify-mcp/sqlbot_dify_mcp.py"
click node_proxy "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/docker-compose.sqlbot.yaml"
click node_importer "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/scripts/import_business_data.sh"
click node_seed "https://github.com/mailrate-gmail/dify-sqlbot/blob/main/seed/business_schema_and_data.sql"

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_workflow,node_dify,node_sqlbot,node_user toneBlue
class node_adapter,node_formatter toneAmber
class node_dbsource,node_proxy,node_importer,node_seed toneMint
```

## Components

### Applications

- [Dify demo workflow](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/dify-apps/integrated-sqlbot-demo.yml): `dify-apps/integrated-sqlbot-demo.yml`
- **Dify services**
- [SQLBot service](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/docker-compose.sqlbot.yaml): `docker-compose.sqlbot.yaml`

### MCP integration

- [MCP adapter](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/sqlbot-dify-mcp/sqlbot_dify_mcp.py): `sqlbot-dify-mcp/sqlbot_dify_mcp.py`
- [Answer formatter](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/sqlbot-dify-mcp/sqlbot_dify_mcp.py): `sqlbot-dify-mcp/sqlbot_dify_mcp.py`

### Data and access

- **Business PostgreSQL**
- [Local DB proxy](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/docker-compose.sqlbot.yaml): `docker-compose.sqlbot.yaml`
- [Business data importer](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/scripts/import_business_data.sh): `scripts/import_business_data.sh`
- [Business schema and data](https://github.com/mailrate-gmail/dify-sqlbot/blob/main/seed/business_schema_and_data.sql): `seed/business_schema_and_data.sql`

### Other components

- **Workflow user**

## Connections

- Workflow user → Dify demo workflow: submits question (evidence: `README.md`)
- Dify demo workflow → Dify services: runs in (evidence: `README.md`)
- Dify services → MCP adapter: invokes MCP (evidence: `README.md`)
- MCP adapter → SQLBot service: calls API (evidence: `sqlbot-dify-mcp/sqlbot_dify_mcp.py`)
- MCP adapter → Answer formatter: formats answer (evidence: `sqlbot-dify-mcp/sqlbot_dify_mcp.py`)
- SQLBot service → Local DB proxy: connects through (evidence: `README.md`)
- Local DB proxy → Business PostgreSQL: forwards traffic (evidence: `README.md`)
- Business data importer → Business schema and data: imports SQL (evidence: `README.md`)
- Business data importer → Business PostgreSQL: loads data into (evidence: `README.md`)
