25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
docs: add contributing guide and web API examples
老谭b0d655986659
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 2edc1df653..959b6636c5 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -1,112 +1,143 @@# Contributing to DBX-Thanks for helping improve DBX. This repository contains the desktop app, Rust backend, Docker service, documentation site, CLI, MCP server, and optional plugins.+Thanks for taking a look at DBX. Whether you fix a typo, improve docs, or tackle a database-specific bug, every PR helps.-## Project Layout+## Where to Start++1. Browse [open issues](https://github.com/t8y2/dbx/issues). Good first targets are labeled `documentation`, `good first issue`, or issues in a database you already use.+2. Comment on the issue you want to work on. Say what you plan to do so others do not duplicate the effort. For community issues, you can also comment `/claim` when that workflow is enabled.+3. Fork the repo, create a branch, and open a PR against `main`.-- `apps/desktop/` - Vue desktop frontend.-- `crates/dbx-core/` - shared Rust database core.-- `crates/dbx-web/` - Docker/web backend service.-- `src-tauri/` - Tauri desktop shell and native commands.-- `packages/` - Node packages, including CLI, MCP server, shared Node core, and app tests.-- `plugins/` - optional DBX plugins.-- `docs/` - documentation site and docs assets.-- `deploy/` - Docker and deployment assets.+If you are not sure what to pick, documentation and small UX fixes are a solid first contribution. See [examples/](examples/) and the [official docs](https://dbxio.com/en/docs/what-is-dbx) for the current structure.## Development Setup-Required tools:+### Prerequisites-- Node.js `>=22.13.0`-- pnpm `10.27.0`+- Node.js >= 22.13.0+- pnpm 10.27.0+- Rust >= 1.77- Make-- Rust stable-- Java 17, when working on JDBC plugin packaging--Install dependencies:-```bash-make install-```+Linux desktop builds also need WebKit/GTK packages. See [README.md](README.md#getting-started) for the exact commands.-Run the desktop app during development:+### Run Locally```bash+git clone https://github.com/t8y2/dbx.git+cd dbxmake```-Run the web app during development:+`make` installs dependencies when needed and starts the Tauri desktop dev environment.++Useful shortcuts:```bash-make dev-web # frontend-make dev-backend # backend+make dev-fast # skip DuckDB during local dev+make dev-web # frontend only+make dev-backend # web backend only+make docs # preview the documentation site+make cargo-check-fast # fast Rust checks```-Preview the documentation site:+### JDBC Agent Drivers++Agent driver projects live under `agents/`. Java/JDBC driver builds and tests require JDK 21; Gradle can auto-download the toolchain when available.```bash-make docs+cd agents+./gradlew test```-## Checks+## Project Layout++| Path | Purpose |+| --- | --- |+| `src/` | Vue frontend |+| `src-tauri/` | Tauri desktop shell and command layer |+| `crates/dbx-core/` | Shared Rust database logic |+| `crates/dbx-web/` | Docker / Web HTTP backend |+| `packages/cli/` | `@dbx-app/cli` |+| `packages/mcp-server/` | `@dbx-app/mcp-server` |+| `packages/node-core/` | Shared Node.js bridge and direct-query logic |+| `docs/` | Official documentation site |+| `examples/` | Sample configs and automation scripts |+| `agents/` | JDBC agent driver projects |-Before opening a pull request, run:+## Making Changes-```bash-make check-cargo fmt --check-cargo check --workspace --locked-```+### Branch Naming-> [!TIP]-> DuckDB compiles from source and takes a while. Skip it during routine-> development when you're not touching DuckDB features:->-> ```bash-> make cargo-check-fast-> make cargo-test-fast-> make dev-fast-> ```->-> Release builds and CI should always include DuckDB (omit the flag).+Use a short descriptive branch name, for example:-For package changes, also run:+- `docs/web-api-reference`+- `fix/mysql-connection-timeout`+- `feat/redis-key-search`++### Scope++Keep PRs focused. A docs-only PR should not include unrelated code changes. A bug fix should not also refactor nearby modules unless that refactor is required for the fix.++### Commits++Write commit messages in plain language:++- `docs: add web API reference for Docker deployments`+- `fix(redis): handle empty scan cursor`+- `feat(schema): show catalog info for Doris`++### Tests++Run the checks that match your change:```bash-pnpm test:packages-pnpm publish:dry-run+make cargo-check-fast+make cargo-test-fast+pnpm test```-For Docker or deployment changes, run the relevant Docker Compose or Docker build checks from `deploy/`.+For frontend or package changes, run the relevant package tests under `packages/` or `packages/app-tests/`.-## Database Driver Metadata+### Documentation-When adding or changing a database type, update `crates/dbx-core/assets/database-drivers.manifest.json` first. The manifest is the shared source for driver mode, MCP/CLI routing, agent keys, support level, and top-level product capabilities.+User-facing docs live in two places:-Choose the support level conservatively:+- Repository docs: `README.md`, `CONTRIBUTING.md`, package READMEs, and `examples/`+- Website docs: `docs/content/docs/`-- `connect` — connection and SQL/command execution only.-- `browse` — connection plus metadata browsing.-- `understand` — browsing plus higher-level understanding features such as search, object sources, or diagrams.-- `operate` — advanced operation surfaces such as table data editing, structure editing, import, transfer, database creation, explain plans, or user administration.+If you add a new docs page under `docs/content/docs/`, register it in:-Set `capabilities` explicitly for the product surfaces DBX should expose. Keep detailed feature behavior in the owning feature module, such as table structure sub-capabilities or user administration dialects. Custom JDBC support should remain conservative unless dialect inference or a dedicated profile proves the advanced capability works.+- `docs/content/docs/meta.json`+- `docs/content/docs/meta.cn.json`-Then run:+Preview locally with:```bash-cargo test -p dbx-core --test database_capabilities-pnpm --filter @dbx-app/node-core exec tsx --test tests/driver-manifest.test.ts-pnpm --filter @dbx-app/mcp-server exec tsx --test tests/driver-manifest.test.ts+make docs```## Pull Requests-- Keep changes focused and reviewable.-- Include tests for behavior changes when practical.-- Update documentation when user-facing behavior changes.-- Use clear commit messages following Conventional Commits, such as `fix(app): clamp window size`.+1. Push your branch to your fork.+2. Open a PR against `https://github.com/t8y2/dbx` `main`.+3. Link the related issue in the PR description.+4. Explain what changed, how you tested it, and any screenshots if the UI changed.++Small PRs are easier to review and merge.++## What We Are Looking For++- Documentation improvements and translations+- Reproducible bug fixes with clear before/after behavior+- Database-specific fixes where you can verify against a real instance+- Tests for non-trivial logic changes+- Examples that show CLI, MCP, Docker, or Web API usage++## Community-## Reporting Issues+- [Discord](https://discord.gg/W7NyVDRt6a)+- [GitHub Issues](https://github.com/t8y2/dbx/issues)+- [Official docs](https://dbxio.com/en/docs/what-is-dbx)-Use GitHub Issues for reproducible bugs, feature requests, database compatibility reports, and questions. Include the DBX version, operating system, database type, and relevant logs or screenshots when possible.+Merged contributors appear on the [DBX contributors wall](https://dbxio.com/en/community).diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.mdnew file mode 100644index 0000000000..29f398a783--- /dev/null+++ b/CONTRIBUTING.zh-CN.md@@ -0,0 +1,143 @@+# 参与 DBX 贡献++感谢你愿意花时间了解 DBX。不管是改一个错别字、补文档,还是修某个数据库相关的问题,都很有价值。++## 从哪里开始++1. 浏览 [Issues](https://github.com/t8y2/dbx/issues)。优先看 `documentation`、`good first issue`,或者你手头正好有测试环境的数据库相关问题。+2. 在 Issue 下留言说明你想做什么,避免重复劳动。部分社区 Issue 也支持评论 `/claim` 来认领。+3. Fork 仓库,新建分支开发,然后向 `main` 提 PR。++如果暂时不确定做什么,文档和小体验修复很适合第一次贡献。可以先看 [examples/](examples/) 和[官方文档](https://dbxio.com/cn/docs/what-is-dbx) 熟悉项目结构。++## 开发环境++### 环境要求++- Node.js >= 22.13.0+- pnpm 10.27.0+- Rust >= 1.77+- Make++Linux 桌面端还需要 WebKit/GTK 相关依赖,具体命令见 [README.zh-CN.md](README.zh-CN.md#快速开始)。++### 本地运行++```bash+git clone https://github.com/t8y2/dbx.git+cd dbx+make+```++`make` 会在需要时安装依赖,并启动 Tauri 桌面端开发环境。++常用命令:++```bash+make dev-fast # 本地开发跳过 DuckDB+make dev-web # 只启动前端+make dev-backend # 只启动 Web 后端+make docs # 本地预览文档站+make cargo-check-fast # 快速 Rust 检查+```++### JDBC Agent 驱动++Agent 驱动工程在 `agents/` 目录。Java/JDBC 驱动构建和测试需要 JDK 21;环境允许时 Gradle 可以自动下载对应 toolchain。++```bash+cd agents+./gradlew test+```++## 项目结构++| 路径 | 说明 |+| --- | --- |+| `src/` | Vue 前端 |+| `src-tauri/` | Tauri 桌面端壳层与命令层 |+| `crates/dbx-core/` | 共享 Rust 数据库逻辑 |+| `crates/dbx-web/` | Docker / Web HTTP 后端 |+| `packages/cli/` | `@dbx-app/cli` |+| `packages/mcp-server/` | `@dbx-app/mcp-server` |+| `packages/node-core/` | Node.js bridge 与直连查询逻辑 |+| `docs/` | 官方文档站 |+| `examples/` | 配置与自动化示例 |+| `agents/` | JDBC Agent 驱动工程 |++## 开发约定++### 分支命名++分支名尽量简短明确,例如:++- `docs/web-api-reference`+- `fix/mysql-connection-timeout`+- `feat/redis-key-search`++### 控制改动范围++一个 PR 只做一类事。文档 PR 不要夹带无关代码;修 Bug 时也不要顺手大重构,除非重构是修复所必需的。++### 提交说明++提交信息用自然语言写清楚即可:++- `docs: add web API reference for Docker deployments`+- `fix(redis): handle empty scan cursor`+- `feat(schema): show catalog info for Doris`++### 测试++按改动范围跑对应检查:++```bash+make cargo-check-fast+make cargo-test-fast+pnpm test+```++如果改的是前端或某个 package,再补跑对应目录下的测试。++### 文档++用户文档主要分两块:++- 仓库内文档:`README.md`、`CONTRIBUTING.md`、各 package README、`examples/`+- 官网文档:`docs/content/docs/`++如果在 `docs/content/docs/` 新增页面,记得同步更新:++- `docs/content/docs/meta.json`+- `docs/content/docs/meta.cn.json`++本地预览:++```bash+make docs+```++## 提 PR++1. 把分支推到你自己的 Fork。+2. 向 `https://github.com/t8y2/dbx` 的 `main` 提 PR。+3. 在 PR 描述里关联相关 Issue。+4. 写清楚改了什么、怎么验证的;如果涉及 UI,附上截图。++改动越小,越容易 review 和合并。++## 欢迎的贡献类型++- 文档改进与翻译+- 可复现、行为清晰的 Bug 修复+- 你有真实测试环境的数据库专项修复+- 非平凡逻辑的测试补充+- CLI、MCP、Docker、Web API 的使用示例++## 社区++- [Discord](https://discord.gg/W7NyVDRt6a)+- [GitHub Issues](https://github.com/t8y2/dbx/issues)+- [官方文档](https://dbxio.com/cn/docs/what-is-dbx)++合并后的贡献者会出现在 [DBX 贡献墙](https://dbxio.com/cn/community)。diff --git a/README.md b/README.mdindex 7e971b9bba..60b45fe222 100644--- a/README.md+++ b/README.md@@ -343,6 +343,13 @@ The installer will be in `src-tauri/target/release/bundle/`.| Editor | [CodeMirror 6](https://codemirror.net/) || Backend | Rust + [sqlx](https://github.com/launchbadge/sqlx) / [tiberius](https://github.com/prisma/tiberius) / [redis-rs](https://github.com/redis-rs/redis-rs) / [mongodb](https://github.com/mongodb/mongo-rust-driver) |+## Documentation++- [Official docs](https://dbxio.com/en/docs/what-is-dbx) — feature guides and tutorials+- [Contributing](CONTRIBUTING.md) — how to pick up issues and open PRs+- [Web API reference](docs/content/docs/web-api.mdx) — HTTP API for Docker/Web deployments+- [Examples](examples/) — CLI, MCP, Docker, and API samples+## Community<a href="https://discord.gg/W7NyVDRt6a" target="_blank"><img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" alt="Discord" /></a>diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 1267721451..87ae97856f 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -340,6 +340,13 @@ make package| 编辑器 | [CodeMirror 6](https://codemirror.net/) || 后端 | Rust + [sqlx](https://github.com/launchbadge/sqlx) / [tiberius](https://github.com/prisma/tiberius) / [redis-rs](https://github.com/redis-rs/redis-rs) / [mongodb](https://github.com/mongodb/mongo-rust-driver) |+## 文档++- [官方文档](https://dbxio.com/cn/docs/what-is-dbx) — 功能说明与使用教程+- [贡献指南](CONTRIBUTING.zh-CN.md) — 如何认领 Issue 并提交 PR+- [Web API 参考](docs/content/docs/web-api.cn.mdx) — Docker/Web 部署的 HTTP API+- [示例代码](examples/) — CLI、MCP、Docker 与 API 示例+## 社区<a href="https://discord.gg/W7NyVDRt6a" target="_blank"><img src="https://img.shields.io/badge/Discord-加入-5865F2?logo=discord&logoColor=white" alt="Discord" /></a>diff --git a/docs/content/docs/meta.cn.json b/docs/content/docs/meta.cn.jsonindex fec60a96f1..7011633ee2 100644--- a/docs/content/docs/meta.cn.json+++ b/docs/content/docs/meta.cn.json@@ -26,6 +26,7 @@"ai-assistant","cli","mcp",+ "web-api","---设置---","plugins","driver-management",diff --git a/docs/content/docs/meta.json b/docs/content/docs/meta.jsonindex 6db0fccb54..6bdfd1c156 100644--- a/docs/content/docs/meta.json+++ b/docs/content/docs/meta.json@@ -26,6 +26,7 @@"ai-assistant","cli","mcp",+ "web-api","---Settings---","plugins","driver-management",diff --git a/docs/content/docs/web-api.cn.mdx b/docs/content/docs/web-api.cn.mdxnew file mode 100644index 0000000000..ce49ad304a--- /dev/null+++ b/docs/content/docs/web-api.cn.mdx@@ -0,0 +1,331 @@+---+title: Web API 参考+description: DBX Web 与 Docker 部署使用的 HTTP API,适用于自动化与集成场景。+---++<Callout type="warn">这套 API 主要服务于 DBX Web 界面,以及 MCP Web 模式等内部工具。它不是单独对外承诺的集成契约,路由和字段可能随版本调整。做脚本或 Agent 集成时,优先使用 [@dbx-app/cli](/cn/docs/cli) 或 [@dbx-app/mcp-server](/cn/docs/mcp)。</Callout>++## 基础地址++DBX Web 默认监听 `4224` 端口:++```text+http://localhost:4224+```++如果通过反向代理挂在子路径下,需要设置 `DBX_PUBLIC_BASE_PATH`。例如 `/dbx`:++```text+https://example.com/dbx/api/auth/check+```++所有 API 都位于 `/api` 路径下。++## 认证++受保护的路由需要名为 `dbx_session` 的会话 Cookie。++### 检查认证状态++```http+GET /api/auth/check+```++示例响应:++```json+{+ "authenticated": false,+ "required": true,+ "setup_required": false+}+```++| 字段 | 含义 |+| --- | --- |+| `required` | 已启用密码保护 |+| `setup_required` | 仍需首次设置密码 |+| `authenticated` | 当前请求已持有有效会话 |++### 首次设置密码++```http+POST /api/auth/setup+Content-Type: application/json++{+ "password": "your-password"+}+```++### 登录++```http+POST /api/auth/login+Content-Type: application/json++{+ "password": "your-password"+}+```++登录成功后,响应会返回 `Set-Cookie: dbx_session=...`。后续请求带上这个 Cookie 即可。++### 退出登录++```http+POST /api/auth/logout+Cookie: dbx_session=...+```++### 环境变量++| 变量 | 作用 |+| --- | --- |+| `DBX_PASSWORD` | 容器启动时设置初始密码 |+| `DBX_DISABLE_PASSWORD=1` | 完全关闭密码保护 |+| `DBX_PORT` | 修改监听端口,默认 `4224` |+| `DBX_DATA_DIR` | 存放 `dbx.db` 的数据目录 |+| `DBX_PUBLIC_BASE_PATH` | 在子路径下提供服务,例如 `/dbx` |++## 请求约定++- JSON 请求体字段名默认使用 `camelCase`。+- `GET` 请求的查询参数使用 `snake_case`,例如 `connection_id`。+- 出错时通常返回带 `error` 字段的 JSON 和对应 HTTP 状态码。++## 连接相关 API++### 列出连接++```http+GET /api/connection/list+Cookie: dbx_session=...+```++返回已保存的连接配置。密码等敏感信息不会直接出现在返回 JSON 中。++### 保存连接++```http+POST /api/connection/save+Content-Type: application/json+Cookie: dbx_session=...++{+ "configs": [+ {+ "name": "local-mysql",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+ ]+}+```++### 测试连接++```http+POST /api/connection/test+Content-Type: application/json++{+ "config": {+ "name": "temp",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+}+```++### 建立连接++大多数数据类 API 会要求目标连接先处于已连接状态。++```http+POST /api/connection/connect+Content-Type: application/json++{+ "config": {+ "id": "connection-id",+ "name": "local-mysql",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+}+```++### 健康检查++```http+POST /api/connection/check-health+Content-Type: application/json++{+ "connectionId": "connection-id"+}+```++## Schema API++### 列出表++```http+GET /api/schema/tables?connection_id=CONNECTION_ID&database=app&schema=+Cookie: dbx_session=...+```++### 列出字段++```http+GET /api/schema/columns?connection_id=CONNECTION_ID&database=app&schema=&table=users+Cookie: dbx_session=...+```++其他常用 Schema 路由包括:++- `/api/schema/databases`+- `/api/schema/schemas`+- `/api/schema/indexes`+- `/api/schema/foreign-keys`+- `/api/schema/ddl`++## SQL 查询 API++### 执行单条语句++```http+POST /api/query/execute+Content-Type: application/json++{+ "connectionId": "connection-id",+ "database": "app",+ "sql": "select id, name from users limit 10"+}+```++响应示例:++```json+{+ "columns": ["id", "name"],+ "rows": [[1, "Ada"], [2, "Lin"]]+}+```++相关路由:++| 路由 | 作用 |+| --- | --- |+| `/api/query/execute-multi` | 一次请求执行多个结果集 |+| `/api/query/execute-batch` | 执行语句列表 |+| `/api/query/cancel` | 取消正在执行的查询 |+| `/api/query/build-table-select-sql` | 生成表浏览 SQL |++## Redis API++Redis 浏览和命令执行使用独立路由。++```http+POST /api/redis/execute-command+Content-Type: application/json++{+ "connectionId": "redis-id",+ "db": 0,+ "command": "GET mykey"+}+```++其他常见 Redis 路由:++- `/api/redis/scan-keys`+- `/api/redis/get-value`+- `/api/redis/set-string`+- `/api/redis/delete-key`++## MongoDB API++MongoDB 路由都是 `POST` 请求,使用 JSON 请求体。++### 列出集合++```http+POST /api/mongo/list-collections+Content-Type: application/json++{+ "connectionId": "mongo-id",+ "database": "app"+}+```++### 查询文档++```http+POST /api/mongo/find-documents+Content-Type: application/json++{+ "connectionId": "mongo-id",+ "database": "app",+ "collection": "users",+ "skip": 0,+ "limit": 20,+ "filter": "{}"+}+```++其他 MongoDB 路由还包括 `aggregate-documents`、`insert-documents`、`update-documents`、`delete-documents` 等。++## MCP 与 CLI 集成++做自动化时,通常比直接调 Web API 更好维护:++- MCP:[@dbx-app/mcp-server](/cn/docs/mcp)+- CLI:[@dbx-app/cli](/cn/docs/cli)++如果 MCP 连接的是已部署的 Web 实例,可设置:++```json+{+ "env": {+ "DBX_WEB_URL": "http://localhost:4224",+ "DBX_WEB_PASSWORD": "your-password"+ }+}+```++MCP Server 会自动处理登录和会话 Cookie。++## 示例脚本++仓库内示例:++- [examples/web-api/automation.sh](https://github.com/t8y2/dbx/tree/main/examples/web-api/automation.sh)+- [examples/docker/docker-compose.yml](https://github.com/t8y2/dbx/tree/main/examples/docker/docker-compose.yml)+- [examples/cli/basic-workflow.sh](https://github.com/t8y2/dbx/tree/main/examples/cli/basic-workflow.sh)++## 其他路由分组++Web 后端还为界面提供了更多路由,例如:++- `/api/export/*`:导出与下载+- `/api/import/*`:表导入+- `/api/transfer/*`:数据传输任务+- `/api/ai/*`:内置 AI 助手+- `/api/agents/*`、`/api/jdbc/*`:驱动管理+- `/api/history/*`、`/api/saved-sql/*`:编辑器状态++完整路由列表见仓库中的 `crates/dbx-web/src/main.rs`。diff --git a/docs/content/docs/web-api.mdx b/docs/content/docs/web-api.mdxnew file mode 100644index 0000000000..82da55dccc--- /dev/null+++ b/docs/content/docs/web-api.mdx@@ -0,0 +1,331 @@+---+title: Web API Reference+description: HTTP API used by DBX Web and Docker deployments for automation and integrations.+---++<Callout type="warn">This API powers the DBX Web UI and internal tooling such as the MCP Web backend. It is not a separate public integration contract. Endpoints and payloads may change between releases. For scripting and agent workflows, prefer [@dbx-app/cli](/en/docs/cli) or [@dbx-app/mcp-server](/en/docs/mcp) when possible.</Callout>++## Base URL++By default, DBX Web listens on port `4224`:++```text+http://localhost:4224+```++When deployed behind a reverse-proxy subpath, set `DBX_PUBLIC_BASE_PATH` and prefix every route. For example, with `/dbx`:++```text+https://example.com/dbx/api/auth/check+```++All API routes are under `/api`.++## Authentication++Protected routes require a session cookie named `dbx_session`.++### Check Auth State++```http+GET /api/auth/check+```++Example response:++```json+{+ "authenticated": false,+ "required": true,+ "setup_required": false+}+```++| Field | Meaning |+| --- | --- |+| `required` | Password protection is enabled |+| `setup_required` | First-run password setup is still needed |+| `authenticated` | Current request already has a valid session |++### First-Run Setup++```http+POST /api/auth/setup+Content-Type: application/json++{+ "password": "your-password"+}+```++### Login++```http+POST /api/auth/login+Content-Type: application/json++{+ "password": "your-password"+}+```++On success, the response sets `Set-Cookie: dbx_session=...`. Reuse that cookie on later requests.++### Logout++```http+POST /api/auth/logout+Cookie: dbx_session=...+```++### Environment Variables++| Variable | Purpose |+| --- | --- |+| `DBX_PASSWORD` | Set an initial password at container startup |+| `DBX_DISABLE_PASSWORD=1` | Disable password protection entirely |+| `DBX_PORT` | Change the listen port (default `4224`) |+| `DBX_DATA_DIR` | Data directory containing `dbx.db` |+| `DBX_PUBLIC_BASE_PATH` | Serve DBX under a subpath such as `/dbx` |++## Request Format++- JSON request bodies use `camelCase` field names unless noted otherwise.+- Query parameters for `GET` routes use `snake_case`, for example `connection_id`.+- Errors usually return JSON with an `error` field and an HTTP status code.++## Connection APIs++### List Connections++```http+GET /api/connection/list+Cookie: dbx_session=...+```++Returns saved connection profiles. Secrets such as passwords are stored separately from the returned JSON.++### Save Connections++```http+POST /api/connection/save+Content-Type: application/json+Cookie: dbx_session=...++{+ "configs": [+ {+ "name": "local-mysql",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+ ]+}+```++### Test Connection++```http+POST /api/connection/test+Content-Type: application/json++{+ "config": {+ "name": "temp",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+}+```++### Connect++Most data APIs expect the target connection to be active first.++```http+POST /api/connection/connect+Content-Type: application/json++{+ "config": {+ "id": "connection-id",+ "name": "local-mysql",+ "db_type": "mysql",+ "host": "127.0.0.1",+ "port": 3306,+ "username": "root",+ "database": "app"+ }+}+```++### Check Health++```http+POST /api/connection/check-health+Content-Type: application/json++{+ "connectionId": "connection-id"+}+```++## Schema APIs++### List Tables++```http+GET /api/schema/tables?connection_id=CONNECTION_ID&database=app&schema=+Cookie: dbx_session=...+```++### List Columns++```http+GET /api/schema/columns?connection_id=CONNECTION_ID&database=app&schema=&table=users+Cookie: dbx_session=...+```++Other schema routes include:++- `/api/schema/databases`+- `/api/schema/schemas`+- `/api/schema/indexes`+- `/api/schema/foreign-keys`+- `/api/schema/ddl`++## SQL Query APIs++### Execute One Statement++```http+POST /api/query/execute+Content-Type: application/json++{+ "connectionId": "connection-id",+ "database": "app",+ "sql": "select id, name from users limit 10"+}+```++Example response shape:++```json+{+ "columns": ["id", "name"],+ "rows": [[1, "Ada"], [2, "Lin"]]+}+```++Related routes:++| Route | Purpose |+| --- | --- |+| `/api/query/execute-multi` | Execute multiple result sets in one request |+| `/api/query/execute-batch` | Execute a list of statements |+| `/api/query/cancel` | Cancel a running query |+| `/api/query/build-table-select-sql` | Build a table browse query |++## Redis APIs++Redis browser and command execution use dedicated routes.++```http+POST /api/redis/execute-command+Content-Type: application/json++{+ "connectionId": "redis-id",+ "db": 0,+ "command": "GET mykey"+}+```++Other common Redis routes:++- `/api/redis/scan-keys`+- `/api/redis/get-value`+- `/api/redis/set-string`+- `/api/redis/delete-key`++## MongoDB APIs++MongoDB routes are `POST` endpoints with JSON bodies.++### List Collections++```http+POST /api/mongo/list-collections+Content-Type: application/json++{+ "connectionId": "mongo-id",+ "database": "app"+}+```++### Find Documents++```http+POST /api/mongo/find-documents+Content-Type: application/json++{+ "connectionId": "mongo-id",+ "database": "app",+ "collection": "users",+ "skip": 0,+ "limit": 20,+ "filter": "{}"+}+```++Other MongoDB routes include `aggregate-documents`, `insert-documents`, `update-documents`, and `delete-documents`.++## MCP and CLI Integration++For automation, these packages are usually easier to maintain than calling the Web API directly:++- MCP: [@dbx-app/mcp-server](/en/docs/mcp)+- CLI: [@dbx-app/cli](/en/docs/cli)++When MCP runs against a deployed Web instance, set:++```json+{+ "env": {+ "DBX_WEB_URL": "http://localhost:4224",+ "DBX_WEB_PASSWORD": "your-password"+ }+}+```++The MCP server handles login and session cookies for you.++## Example Scripts++See the repository examples:++- [examples/web-api/automation.sh](https://github.com/t8y2/dbx/tree/main/examples/web-api/automation.sh)+- [examples/docker/docker-compose.yml](https://github.com/t8y2/dbx/tree/main/examples/docker/docker-compose.yml)+- [examples/cli/basic-workflow.sh](https://github.com/t8y2/dbx/tree/main/examples/cli/basic-workflow.sh)++## Route Groups++The Web backend exposes many more routes for the UI, including:++- `/api/export/*` for exports and downloads+- `/api/import/*` for table imports+- `/api/transfer/*` for data transfer jobs+- `/api/ai/*` for the built-in AI assistant+- `/api/agents/*` and `/api/jdbc/*` for driver management+- `/api/history/*` and `/api/saved-sql/*` for editor state++Browse `crates/dbx-web/src/main.rs` in the repository for the full route list.diff --git a/examples/README.md b/examples/README.mdnew file mode 100644index 0000000000..8b2918a77d--- /dev/null+++ b/examples/README.md@@ -0,0 +1,40 @@+# DBX Examples++Runnable samples for common DBX workflows.++| Directory | What it shows |+| --- | --- |+| [cli/](cli/) | Terminal queries with `@dbx-app/cli` |+| [mcp/](mcp/) | MCP configs for Cursor and Claude Code |+| [docker/](docker/) | Self-hosted Docker deployment |+| [web-api/](web-api/) | Minimal HTTP API automation against DBX Web |++## Before You Run++1. Install DBX Desktop, or start the Docker/Web version.+2. Create at least one connection in DBX.+3. For CLI examples, install the CLI:++```bash+npm install -g @dbx-app/cli+```++4. For MCP examples, install the MCP server:++```bash+npm install -g @dbx-app/mcp-server+```++## Suggested Learning Path++1. Read [Getting Started](https://dbxio.com/en/docs/getting-started)+2. Try the CLI workflow in `cli/basic-workflow.sh`+3. Copy an MCP config from `mcp/` into your project+4. If you self-host DBX, use `docker/docker-compose.yml`+5. For custom integrations, inspect `web-api/automation.sh`++More docs:++- [CLI reference](https://dbxio.com/en/docs/cli)+- [MCP integration](https://dbxio.com/en/docs/mcp)+- [Web API reference](https://dbxio.com/en/docs/web-api)diff --git a/examples/cli/basic-workflow.sh b/examples/cli/basic-workflow.shnew file mode 100755index 0000000000..19ad684083--- /dev/null+++ b/examples/cli/basic-workflow.sh@@ -0,0 +1,22 @@+#!/usr/bin/env bash+set -euo pipefail++# Basic DBX CLI workflow.+# Replace "local" with one of your saved connection names.++CONNECTION="${DBX_CONNECTION:-local}"++echo "==> Checking local DBX setup"+dbx doctor++echo "==> Listing connections"+dbx connections list --json++echo "==> Listing tables"+dbx schema list "$CONNECTION" --json++echo "==> Running a read-only query"+dbx query "$CONNECTION" "select 1 as ok" --json++echo "==> Building schema context for prompts"+dbx context "$CONNECTION" --tables users,ordersdiff --git a/examples/docker/docker-compose.yml b/examples/docker/docker-compose.ymlnew file mode 100644index 0000000000..399b7112e9--- /dev/null+++ b/examples/docker/docker-compose.yml@@ -0,0 +1,16 @@+services:+ dbx:+ image: t8y2/dbx+ ports:+ - "4224:4224"+ environment:+ # Change this before exposing DBX to a network.+ - DBX_PASSWORD=changeme+ # Uncomment when serving DBX behind a reverse-proxy subpath.+ # - DBX_PUBLIC_BASE_PATH=/dbx+ volumes:+ - dbx-data:/app/data+ restart: unless-stopped++volumes:+ dbx-data:diff --git a/examples/mcp/claude-code.mcp.json b/examples/mcp/claude-code.mcp.jsonnew file mode 100644index 0000000000..da08b4bc25--- /dev/null+++ b/examples/mcp/claude-code.mcp.json@@ -0,0 +1,7 @@+{+ "mcpServers": {+ "dbx": {+ "command": "dbx-mcp-server"+ }+ }+}diff --git a/examples/mcp/cursor.mcp.json b/examples/mcp/cursor.mcp.jsonnew file mode 100644index 0000000000..8b281cfb5d--- /dev/null+++ b/examples/mcp/cursor.mcp.json@@ -0,0 +1,8 @@+{+ "mcpServers": {+ "dbx": {+ "command": "npx",+ "args": ["-y", "@dbx-app/mcp-server"]+ }+ }+}diff --git a/examples/mcp/web-deployment.mcp.json b/examples/mcp/web-deployment.mcp.jsonnew file mode 100644index 0000000000..3fee6e787a--- /dev/null+++ b/examples/mcp/web-deployment.mcp.json@@ -0,0 +1,11 @@+{+ "mcpServers": {+ "dbx": {+ "command": "dbx-mcp-server",+ "env": {+ "DBX_WEB_URL": "http://localhost:4224",+ "DBX_WEB_PASSWORD": "changeme"+ }+ }+ }+}diff --git a/examples/web-api/automation.sh b/examples/web-api/automation.shnew file mode 100755index 0000000000..89089409ec--- /dev/null+++ b/examples/web-api/automation.sh@@ -0,0 +1,26 @@+#!/usr/bin/env bash+set -euo pipefail++# Minimal DBX Web API automation example.+# Requires a running DBX Web/Docker instance.++BASE_URL="${DBX_WEB_URL:-http://localhost:4224}"+PASSWORD="${DBX_WEB_PASSWORD:-changeme}"+COOKIE_JAR="$(mktemp)"+trap 'rm -f "$COOKIE_JAR"' EXIT++echo "==> Checking auth state"+curl -fsS "$BASE_URL/api/auth/check"++echo+echo "==> Logging in"+curl -fsS -c "$COOKIE_JAR" \+ -H "Content-Type: application/json" \+ -d "{\"password\":\"$PASSWORD\"}" \+ "$BASE_URL/api/auth/login" >/dev/null++echo "==> Listing saved connections"+curl -fsS -b "$COOKIE_JAR" "$BASE_URL/api/connection/list" | jq .++echo+echo "Done. Reuse the session cookie for schema and query routes."