技术栈与运行部署
Go 单一二进制(CGO_ENABLED=0 兼容信创)+ Vue3 前端 + PostgreSQL/SQLite 双库 + 本地向量/图引擎,单机 5 分钟安装。
技术栈表
| 层次 | 技术选型 | 说明 |
|---|---|---|
| 后端语言 | Go 1.25.8 | 单一二进制,CGO_ENABLED=0 交叉编译支撑信创,无 Python 运行时依赖 |
| Web 框架 | gin v1.12.0 | 各产品 server 路由 + 中间件(JWT 鉴权) |
| ORM | GORM v1.30.2 | PostgreSQL / SQLite 统一访问 + AutoMigrate |
| 前端 | Vue3 + Vite + vue-router + axios | 纯 JS(不强制 TS);按产品选 API 实例(client.js / apolloClient.js) |
| 地图 | Leaflet 1.9.4 | Gotham 地图视图(BSD、离线瓦片友好) |
| 主库 | PostgreSQL 17(chatbi_action_dev) | 四产品共用;PostGIS 可用时地理空间 ST_* 查询 |
| 降级库 | SQLite(glebarez 纯 Go 驱动) | PG 不可用自动降级;MVP/星上场景 |
| 向量库 | milvus / turbovec / disk | 三后端自动降级(本机无 Milvus 时落到 disk) |
| 图存储 | 自研磁盘 JSON | Gotham 内存邻接表 + 快照落盘(temp/gotham_graph.json),Neo4j 留作可替换后端 |
| 国密 | emmansun/gmsm v0.44.1 | SM2/SM3(纯 Go,CGO_ENABLED=0 兼容);Apollo bundle 签名/验签 |
| 主力 LLM | deepseek-v4-flash;embedding dashscope_embedding | 备用 qwen / local_rule 降级;密钥从 .env / 环境变量读取 |
| 配置 | spf13/viper + YAML + 环境变量 | config fallback 防配置归零 |
| 日志 | log/slog + lumberjack | JSON 滚动日志(10MB/5 份/28 天) |
端口与访问方式
| 服务 | 端口 | 访问地址 | 说明 |
|---|---|---|---|
| Web 网关(gateway) | 80 | http://127.0.0.1/ | SPA 静态服务 + 三路反向代理 |
| LightAIP | 18080 | http://127.0.0.1:18080 | NLQ 智能查数,网关前缀 /aip-api |
| LightFoundry | 18081 | http://127.0.0.1:18081 | 本体/指标/管道/血缘,网关前缀 /api |
| LightApollo | 18082 | http://127.0.0.1:18082 | 声明式部署 Hub,网关前缀 /apollo-api |
| LightGotham | 18083 | http://127.0.0.1:18083 | 情报分析,网关前缀 /gotham-api |
| LightSwift | 18084 | http://127.0.0.1:18084 | 星基结算仿真 PoC,网关前缀 /swift-api |
| Vite 开发服务器 | 5173 | http://localhost:5173 | 仅开发模式;按产品前缀分流后端 |
| 网关前缀 | 目标后端 | 说明 |
|---|---|---|
/api/* | Foundry 18081 | 路径不变 |
/apollo-api/* | Apollo 18082 | 前缀重写为 /api |
/aip-api/* | AIP 18080 | 前缀重写为 /api |
/gotham-api/* | Gotham 18083 | 前缀重写为 /api |
/swift-api/* | Swift 18084 | 前缀重写为 /api |
| 其余 | 静态资源 | SPA fallback 到 index.html(防穿越) |
端口约定:勿用 8080(系统 httpd.exe)与 8000(其他进程占用)。Gotham 前端在 Vite 模式需
VITE_PROXY_TARGET=http://127.0.0.1:18083 将 /api 分流。启动命令
一键启动(发布包)
在发布目录(action/release/v2026.08.11/)双击 运行AI商业行动系统.bat:注入 .env LLM Key → 拉起 aip/foundry/apollo/gotham/swift/gateway 六进程 → 自动打开 http://127.0.0.1/ → 任意键停止。bat 必须 GBK+CRLF 编码、括号块内用全角括号。发布包构建:scripts/build_release.bat [版本号]。
源码构建与启动
cd /f/chatBI/chatBI_dev/action
# 五个后端
go build -o temp/aip_server.exe ./products/aip/cmd
go build -o temp/foundry_server.exe ./products/foundry/cmd
go build -o temp/apollo_server.exe ./products/apollo/cmd
go build -o temp/gotham_server.exe ./products/gotham/cmd
go build -o temp/swift_server.exe ./products/swift/cmd
# 分别启动(各占一终端)
./temp/aip_server.exe # 18080
./temp/foundry_server.exe # 18081
./temp/apollo_server.exe # 18082
./temp/gotham_server.exe # 18083
./temp/swift_server.exe # 18084
# Go Web 网关(端口 80)
go build -o temp/gateway.exe ./web/gateway && ./temp/gateway.exe
# V5 embed 单二进制(前端嵌入):
# scripts/build_embed.sh → go build -tags embed ./products/foundry/cmd
健康检查
curl -s http://127.0.0.1:18080/health # {"status":"ok","service":"zy-action-aip"}
curl -s http://127.0.0.1:18081/health # zy-action-foundry
curl -s http://127.0.0.1:18082/health # zy-action-apollo
curl -s http://127.0.0.1:18083/health # zy-action-gotham
curl -s http://127.0.0.1:18084/health # zy-action-swift
curl -s http://127.0.0.1:18081/metrics # Foundry Prometheus 指标(v5,无鉴权)
前端构建(PowerShell)
# npm 在 F:\Program Files\nodejs\npm.cmd
cd /f/chatBI/chatBI_dev/action/web
npm install
npm run build # 产物 dist/
npm run dev # Vite 开发服务器 5173
# PowerShell 启动 Vite(如需):
# & 'F:\Program Files\nodejs\npm.cmd' run dev
停止进程必须用 PowerShell(bash 的 taskkill 经 WOW64 重定向 32 位,无法杀 64 位进程):
Stop-Process -Name 'xxx' -Force。数据库降级
| 产品 | 平台库(PG 不可用时 SQLite) | 演示数据源 |
|---|---|---|
| AIP | temp/aip_platform.db | temp/aip_demo_datasource.db(orders/customers/products) |
| Foundry | temp/foundry_platform.db | temp/foundry_demo.db(本体/指标 demo seed) |
| Apollo | temp/apollo_platform.db | — |
| Gotham | temp/gotham_platform.db | 图存储 temp/gotham_graph.json(删除即重建) |
连接参数支持 DB_* 环境变量(host/port/user/password);PG 默认库 chatbi_action_dev。降级到 SQLite 后冒烟脚本的 psql 断言不可用。
日志位置
- 所有进程在工作目录写
logs/app.log(JSON 格式,lumberjack 滚动:单文件最大 10MB、保留 5 份、28 天)。 - 结构化日志 + trace_id(
platform/logger),供审计与排查。
V5 工程交付(2026-08-30)
| 项 | 说明 |
|---|---|
| Prometheus 可观测 | Foundry/AIP 轻量自实现 /metrics(文本格式,无鉴权):HTTP 请求量/时延、LLM 网关命中与熔断、task 队列深度、scheduler 运行计数;BootstrapSummary 启动自检日志 |
| embed 单二进制 | //go:build embed + webdist_embed.go/webdist_disk.go 条件编译 + scripts/build_embed.sh,前端嵌入二进制,默认构建走磁盘 dist 回退纯 API |
| Docker 镜像 | Dockerfile.foundry/Dockerfile.aip 多阶段(node:20-alpine → golang:1.25-alpine → distroless-static nonroot),本地不跑 Docker,go build -tags embed 验证 |
| 新依赖 | PDF 解析 ledongthuc/pdf(纯 Go,字体大小+加粗推断标题);docx 用 archive/zip+XML 手写零新依赖;MCP/OWL 导出用标准库自实现 |
| 契约一致性 | TestOpenAPIContractRoutes openapi spec ↔ gin 路由双向对拍,白名单未扩大 |
| 任务化长耗时操作 | 元数据导入/评测/管道/同步/实体抽取/图谱化等全部走 platform/task,前端实时看进度 |