Reorganize repo: backend/, deploy/, docs/ layout + AGENTS.md
Restructure the monorepo into clear top-level directories: - backend/: Go module root (cmd, internal, pkg, configs, migrations, docs/swagger, scripts, tests, go.mod, Makefile, .air.toml) - deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd - docs/: project documentation + reports/ (moved from repo root) - AGENTS.md: new AI coding-agent guide at repo root Update all references to the new layout: - Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root) - docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile, env_file ../../.env, volume mounts ../../backend:/app - deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile - CI: working-directory: backend for go commands, file deploy/docker/Dockerfile, coverage path backend/coverage.out, health_check backend/scripts/ - backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../ - README: architecture tree, quickstart, config paths updated Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh, gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to preserve history. Build, vet, SQLite tests, and docker compose config verified.
This commit is contained in:
@@ -18,26 +18,36 @@
|
||||
GoChat 采用 **分层架构** + **模块化设计**:
|
||||
|
||||
```
|
||||
cmd/ # 入口(migrate, server)
|
||||
internal/
|
||||
app/ # 应用启动、graceful shutdown
|
||||
auth/ # JWT认证、Refresh Token、TOTP
|
||||
autoassignment/ # 智能分配
|
||||
channel/provider/ # 渠道抽象层(Telegram/WebWidget/Email)
|
||||
config/ # Viper多环境热加载配置
|
||||
handler/api/v1/ # HTTP Handler(Gin,104+路由)
|
||||
llm/ # CaptainAI LLM Provider(OpenAI/Ollama/volcengine)
|
||||
middleware/ # Auth/CORS/RateLimiting/AccountScope/InputValidation
|
||||
model/ # GORM 数据模型(Base/Account/User/Contact/Inbox等)
|
||||
pubsub/ # Redis Pub/Sub
|
||||
repository/ # 数据访问层(21 repo)
|
||||
service/ # 业务逻辑层
|
||||
ws/ # WebSocket Hub(/cable)
|
||||
pkg/
|
||||
crypto/ # bcrypt Hash/Check
|
||||
validation/ # go-playground/validator/v10 自定义规则
|
||||
tests/
|
||||
e2e/ # 端到端测试(Auth/AccountCRUD/CRM)
|
||||
backend/ # Go 后端(单仓库 monorepo 子目录)
|
||||
cmd/ # 入口(migrate, server)
|
||||
internal/
|
||||
app/ # 应用启动、graceful shutdown
|
||||
auth/ # JWT认证、Refresh Token、TOTP
|
||||
autoassignment/ # 智能分配
|
||||
channel/provider/ # 渠道抽象层(Telegram/WebWidget/Email)
|
||||
config/ # Viper多环境热加载配置
|
||||
handler/api/v1/ # HTTP Handler(Gin,104+路由)
|
||||
llm/ # CaptainAI LLM Provider(OpenAI/Ollama/volcengine)
|
||||
middleware/ # Auth/CORS/RateLimiting/AccountScope/InputValidation
|
||||
model/ # GORM 数据模型(Base/Account/User/Contact/Inbox等)
|
||||
pubsub/ # Redis Pub/Sub
|
||||
repository/ # 数据访问层(21 repo)
|
||||
service/ # 业务逻辑层
|
||||
ws/ # WebSocket Hub(/cable)
|
||||
pkg/
|
||||
crypto/ # bcrypt Hash/Check
|
||||
validation/ # go-playground/validator/v10 自定义规则
|
||||
configs/ # 多环境配置(config.yaml + config.{env}.yaml)
|
||||
migrations/ # SQL 迁移文件
|
||||
docs/ # Swagger/OpenAPI 生成代码
|
||||
scripts/ # 迁移、种子、健康检查等脚本
|
||||
tests/
|
||||
e2e/ # 端到端测试(Auth/AccountCRUD/CRM)
|
||||
deploy/ # 部署相关
|
||||
docker/ # Dockerfile + docker-compose(dev/prod/test)
|
||||
quickstart/ # 本地/UAT 一键启动 Compose 栈
|
||||
fluentd/ # 日志收集配置
|
||||
docs/ # 项目文档(架构、需求、计划、报告)
|
||||
```
|
||||
|
||||
## 快速开始
|
||||
@@ -56,15 +66,16 @@ tests/
|
||||
git clone https://github.com/gochat/gochat.git
|
||||
cd gochat
|
||||
|
||||
# 安装依赖
|
||||
# 安装依赖(在 backend/ 下)
|
||||
cd backend
|
||||
go mod download
|
||||
|
||||
# 配置环境
|
||||
cp .env.example .env
|
||||
# 配置环境(从仓库根目录复制)
|
||||
cp ../.env.example ../.env
|
||||
# 编辑 .env 配置数据库、Redis、JWT等
|
||||
|
||||
# 运行服务
|
||||
go run cmd/server/main.go
|
||||
go run cmd/gochat/main.go serve
|
||||
|
||||
# 运行测试(SQLite模式,无需PG)
|
||||
GOCHAT_TEST_DB=sqlite go test ./internal/... ./pkg/... ./cmd/...
|
||||
@@ -94,9 +105,9 @@ docker compose --profile seed run --rm seed
|
||||
|
||||
GoChat 使用 **Viper 多环境叠加**机制:
|
||||
|
||||
- `configs/default.yaml` — 默认配置
|
||||
- `configs/production.yaml` — 生产覆盖
|
||||
- `configs/development.yaml` — 开发覆盖
|
||||
- `backend/configs/config.yaml` — 默认配置
|
||||
- `backend/configs/config.prod.yaml` — 生产覆盖
|
||||
- `backend/configs/config.dev.yaml` — 开发覆盖
|
||||
- `.env` — 本地覆盖(最高优先级)
|
||||
- 11 个字段支持 **热加载**(无需重启)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user