easyai-ai-gateway/README.md
wangbo 6323e70e49 Initial project scaffold
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 14:36:35 +08:00

61 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# EasyAI AI Gateway
独立的 AI 网关中台脚手架,用于把现有 `integration-platform` 的平台管理、模型路由、计费预估、队列执行、Chat / 生图 / 生视频等生成能力逐步从 `easyai-server-main` 拆成可独立运行的项目。
## 技术选型
- 后端Go + PostgreSQL复用 Agent memory 的 `easyai-pgvector`,保留 `server-main` 的 JWT / API Key 授权语义。
- 前端React + TypeScript + TSXUI 体系按 `shadcn-ui` / Radix / Tailwind 方向沉淀,先提供运维控制台骨架。
- MonorepoNx 负责任务编排Go 使用 `go.work` 管理模块。
- 集成:完成后由 `easyai-server-main` 通过内部 HTTP SDK 直连本服务,前端经网关访问本服务。
## 目录
```text
apps/
api/ Go HTTP API, auth middleware, PG store, migrations
web/ React TSX admin console
packages/
contracts/ Shared TypeScript DTO contracts
docs/
design.md Detailed architecture and migration design
```
## 本地启动
```bash
cp .env.example .env
pnpm install
pnpm dev
```
服务默认地址:
- API: `http://localhost:8088`
- Web: `http://localhost:5178`
- PostgreSQL: 默认使用宿主机 `localhost:5432` 上的 `postgres` 容器,并使用独立库 `easyai_ai_gateway`
默认 EasyAI 部署里,`easyai-pgvector` 在容器网络内的连接串是:
```dotenv
AI_GATEWAY_DATABASE_URL=postgresql://easyai:easyai2025@easyai-pgvector:5432/easyai_ai_gateway?schema=public
```
宿主机直跑时需要使用宿主机可访问的 Postgres 地址。如果 `easyai-pgvector``5432` 映射到了本机,可使用:
```dotenv
AI_GATEWAY_DATABASE_URL=postgresql://easyai:easyai2025@localhost:5432/easyai_ai_gateway?sslmode=disable
```
如果现有 `easyai-pgvector` 没有把 `5432` 映射到宿主机,就需要补端口映射,或者把 AI Gateway 后端容器化后接入同一个 `easyai` Docker network。
## 迁移原则
1. 新服务先并行运行,不直接删除 `easyai-server-main` 内现有模块。
2. 授权先复用 `server-main` 的 JWT secret、claim、角色权限模型。
3. OpenAPI `sk-*` 校验、文件上传、扣费结算仍由 `server-main` 承担。
4. 网关服务负责基准模型库、平台模型路由、TPM/RPM/并发限流、任务队列、三方平台执行、任务进度推送。
5. 切流时优先让 `server-main``OpenaiService` 变成薄门面,内部调用本服务。
详细设计见 [docs/design.md](docs/design.md)。