# niuhuoshan/dsh-connect architecture

> Architecture diagram of the GitHub repository niuhuoshan/dsh-connect, 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/niuhuoshan/dsh-connect
- Repository: https://github.com/niuhuoshan/dsh-connect

## Overview

dsh-connect is a DSH connector plugin for read-only database discovery/querying and administrator-configured HTTP API tools. Users configure connections and APIs in the settings UI; Host RPC validates and handles operations, while registered Agent tools expose metadata, SQL, and enabled APIs to conversations. Database scanning discovers physical structure, enriches semantic profiles, and persists profiles, metrics, jobs, and change records. The README documents additional metadata editing, YAML export, metrics, and scan modes. Some RPC internals and UI call details are unsampled, so only documented or indexed relationships are shown.

Main entry points: [`src/host/rpc.ts`](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/rpc.ts) (Host RPC), [`src/index.ts`](https://github.com/niuhuoshan/dsh-connect/blob/main/src/index.ts) (Plugin runtime), [`src/host/datasource/index.ts`](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/index.ts) (Provider registry), [`src/host/store.ts`](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/store.ts) (Connect store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Settings UI"]
  node_client_ui["Connector settings"]
  node_client_rpc["RPC client<br/>[rpc.ts]"]
end

subgraph group_host["Host runtime"]
  node_plugin["Plugin runtime<br/>[index.ts]"]
  node_rpc["Host RPC<br/>[rpc.ts]"]
  node_provider_registry["Provider registry<br/>[index.ts]"]
  node_provider_contract["Provider contract<br/>[provider.ts]"]
  node_mysql["MySQL provider<br/>[mysql.ts]"]
  node_postgres["PostgreSQL provider<br/>[postgresql.ts]"]
  node_clickhouse["ClickHouse provider<br/>[clickhouse.ts]"]
end

subgraph group_metadata["Metadata"]
  node_profiler["Metadata profiler<br/>[profiler.ts]"]
  node_enricher["Semantic enricher<br/>[enricher.ts]"]
  node_metadata_tools["Metadata tools<br/>[tools.ts]"]
  node_governance["Metadata governance<br/>[governance.ts]"]
end

subgraph group_http["HTTP APIs"]
  node_api_registry["API tool registry<br/>[tools.ts]"]
  node_http_executor["HTTP executor<br/>[executor.ts]"]
  node_http_security["Outbound security<br/>[security.ts]"]
  node_conversation_api["API creation tool"]
end

subgraph group_persistence["Persistence"]
  node_store["Connect store<br/>[store.ts]"]
  node_domain[("Domain tables<br/>[domain.ts]")]
end

node_user(("Administrator"))
node_agent(("DSH Agent"))
node_db[("Database")]
node_external_api["Configured API"]

node_user -->|"configures"| node_client_ui
node_client_ui -->|"sends RPC"| node_client_rpc
node_plugin -->|"creates"| node_store
node_plugin -->|"creates"| node_profiler
node_plugin -->|"registers tools"| node_api_registry
node_plugin -->|"registers tools"| node_metadata_tools
node_plugin -->|"registers tool"| node_conversation_api
node_plugin -->|"routes RPC"| node_rpc
node_client_rpc -->|"calls"| node_rpc
node_rpc -->|"reads and writes"| node_store
node_store -->|"persists records"| node_domain
node_rpc -->|"selects provider"| node_provider_registry
node_provider_registry -->|"dispatches"| node_mysql
node_provider_registry -->|"dispatches"| node_postgres
node_provider_registry -->|"dispatches"| node_clickhouse
node_mysql -.->|"discovers and queries"| node_db
node_postgres -->|"discovers and queries"| node_db
node_clickhouse -.->|"discovers and queries"| node_db
node_mysql -->|"implements"| node_provider_contract
node_postgres -->|"implements"| node_provider_contract
node_clickhouse -->|"implements"| node_provider_contract
node_rpc -->|"starts scans"| node_profiler
node_profiler -->|"discovers objects"| node_provider_registry
node_profiler -->|"enriches profiles"| node_enricher
node_profiler -->|"persists profiles"| node_store
node_metadata_tools -->|"reads metadata"| node_store
node_metadata_tools -->|"queries data"| node_provider_registry
node_metadata_tools -->|"uses governance"| node_governance
node_agent -.->|"invokes tools"| node_metadata_tools
node_agent -.->|"invokes enabled tools"| node_api_registry
node_rpc -.->|"refreshes registrations"| node_api_registry
node_api_registry -->|"loads definitions"| node_store
node_api_registry -->|"executes tools"| node_http_executor
node_http_executor -->|"checks targets"| node_http_security
node_http_executor -.->|"sends request"| node_external_api
node_rpc -->|"tests API requests"| node_http_executor
node_rpc -->|"validates and saves"| node_conversation_api
node_agent -->|"proposes API config"| node_conversation_api
node_conversation_api -->|"requests approval save"| node_rpc

click node_client_ui "https://github.com/niuhuoshan/dsh-connect/blob/main/src/client/ConnectSettings.tsx"
click node_client_rpc "https://github.com/niuhuoshan/dsh-connect/blob/main/src/client/rpc.ts"
click node_plugin "https://github.com/niuhuoshan/dsh-connect/blob/main/src/index.ts"
click node_rpc "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/rpc.ts"
click node_store "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/store.ts"
click node_domain "https://github.com/niuhuoshan/dsh-connect/blob/main/src/domain.ts"
click node_provider_registry "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/index.ts"
click node_provider_contract "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/provider.ts"
click node_mysql "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/mysql.ts"
click node_postgres "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/postgresql.ts"
click node_clickhouse "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/clickhouse.ts"
click node_profiler "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/profiler.ts"
click node_enricher "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/enricher.ts"
click node_metadata_tools "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/tools.ts"
click node_governance "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/governance.ts"
click node_api_registry "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/tools.ts"
click node_http_executor "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/executor.ts"
click node_http_security "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/security.ts"
click node_conversation_api "https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/conversation-api.ts"

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_client_ui,node_client_rpc toneBlue
class node_plugin,node_rpc,node_provider_registry,node_provider_contract,node_mysql,node_postgres,node_clickhouse,node_db toneAmber
class node_profiler,node_enricher,node_metadata_tools,node_governance,node_external_api toneMint
class node_api_registry,node_http_executor,node_http_security,node_conversation_api toneRose
class node_store,node_domain,node_user,node_agent toneIndigo
```

## Components

### Settings UI

- [Connector settings](https://github.com/niuhuoshan/dsh-connect/blob/main/src/client/ConnectSettings.tsx): `src/client/ConnectSettings.tsx`
- [RPC client](https://github.com/niuhuoshan/dsh-connect/blob/main/src/client/rpc.ts): `src/client/rpc.ts`

### Host runtime

- [Plugin runtime](https://github.com/niuhuoshan/dsh-connect/blob/main/src/index.ts): `src/index.ts`
- [Host RPC](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/rpc.ts): `src/host/rpc.ts`
- [Provider registry](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/index.ts): `src/host/datasource/index.ts`
- [Provider contract](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/provider.ts): `src/host/datasource/provider.ts`
- [MySQL provider](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/mysql.ts): `src/host/datasource/mysql.ts`
- [PostgreSQL provider](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/postgresql.ts): `src/host/datasource/postgresql.ts`
- [ClickHouse provider](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/datasource/clickhouse.ts): `src/host/datasource/clickhouse.ts`

### Metadata

- [Metadata profiler](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/profiler.ts): `src/host/metadata/profiler.ts`
- [Semantic enricher](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/enricher.ts): `src/host/metadata/enricher.ts`
- [Metadata tools](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/tools.ts): `src/host/metadata/tools.ts`
- [Metadata governance](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/metadata/governance.ts): `src/host/metadata/governance.ts`

### HTTP APIs

- [API tool registry](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/tools.ts): `src/host/http/tools.ts`
- [HTTP executor](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/executor.ts): `src/host/http/executor.ts`
- [Outbound security](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/security.ts): `src/host/http/security.ts`
- [API creation tool](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/http/conversation-api.ts): `src/host/http/conversation-api.ts`

### Persistence

- [Connect store](https://github.com/niuhuoshan/dsh-connect/blob/main/src/host/store.ts): `src/host/store.ts`
- [Domain tables](https://github.com/niuhuoshan/dsh-connect/blob/main/src/domain.ts): `src/domain.ts`

### Other components

- **Administrator**
- **DSH Agent**
- **Database**
- **Configured API**

## Connections

- Administrator → Connector settings: configures (evidence: `README.md`)
- Connector settings → RPC client: sends RPC (evidence: `src/client/ConnectSettings.tsx`)
- Plugin runtime → Connect store: creates (evidence: `src/index.ts`)
- Plugin runtime → Metadata profiler: creates (evidence: `src/index.ts`)
- Plugin runtime → API tool registry: registers tools (evidence: `src/index.ts`)
- Plugin runtime → Metadata tools: registers tools (evidence: `src/index.ts`)
- Plugin runtime → API creation tool: registers tool (evidence: `src/index.ts`)
- Plugin runtime → Host RPC: routes RPC (evidence: `src/index.ts`)
- RPC client → Host RPC: calls (evidence: `README.md`)
- Host RPC → Connect store: reads and writes (evidence: `src/host/rpc.ts`)
- Connect store → Domain tables: persists records (evidence: `src/host/store.ts`)
- Host RPC → Provider registry: selects provider (evidence: `src/host/rpc.ts`)
- Provider registry → MySQL provider: dispatches (evidence: `src/host/datasource/index.ts`)
- Provider registry → PostgreSQL provider: dispatches (evidence: `src/host/datasource/index.ts`)
- Provider registry → ClickHouse provider: dispatches (evidence: `src/host/datasource/index.ts`)
- MySQL provider → Database: discovers and queries
- PostgreSQL provider → Database: discovers and queries (evidence: `src/host/datasource/postgresql.ts`)
- ClickHouse provider → Database: discovers and queries
- MySQL provider → Provider contract: implements (evidence: `src/host/datasource/mysql.ts`)
- PostgreSQL provider → Provider contract: implements (evidence: `src/host/datasource/postgresql.ts`)
- ClickHouse provider → Provider contract: implements (evidence: `src/host/datasource/clickhouse.ts`)
- Host RPC → Metadata profiler: starts scans (evidence: `src/host/rpc.ts`)
- Metadata profiler → Provider registry: discovers objects (evidence: `src/host/metadata/profiler.ts`)
- Metadata profiler → Semantic enricher: enriches profiles (evidence: `src/host/metadata/profiler.ts`)
- Metadata profiler → Connect store: persists profiles (evidence: `src/host/metadata/profiler.ts`)
- Metadata tools → Connect store: reads metadata (evidence: `src/host/metadata/tools.ts`)
- Metadata tools → Provider registry: queries data (evidence: `src/host/metadata/tools.ts`)
- Metadata tools → Metadata governance: uses governance (evidence: `src/host/metadata/tools.ts`)
- DSH Agent → Metadata tools: invokes tools
- DSH Agent → API tool registry: invokes enabled tools
- Host RPC → API tool registry: refreshes registrations (evidence: `src/host/rpc.ts`)
- API tool registry → Connect store: loads definitions (evidence: `src/host/http/tools.ts`)
- API tool registry → HTTP executor: executes tools (evidence: `src/host/http/tools.ts`)
- HTTP executor → Outbound security: checks targets (evidence: `src/host/http/executor.ts`)
- HTTP executor → Configured API: sends request
- Host RPC → HTTP executor: tests API requests (evidence: `src/host/rpc.ts`)
- Host RPC → API creation tool: validates and saves (evidence: `src/host/rpc.ts`)
- DSH Agent → API creation tool: proposes API config (evidence: `src/host/http/conversation-api.ts`)
- API creation tool → Host RPC: requests approval save (evidence: `src/host/http/conversation-api.ts`)
