feat: 基础框架搭建完毕
Checks / verify (push) Failing after 2m37s

This commit is contained in:
2026-10-07 09:27:47 +08:00
parent ba6dfffab7
commit bffdb3858b
64 changed files with 326 additions and 332 deletions
+21 -11
View File
@@ -25,7 +25,7 @@ cp .env.example .env
将 PostgreSQL 用户名与密码填写到 `.env`。默认数据库名称 `veyra`,默认管理数据库 `postgres`;创建数据库需要连接角色具有 CREATEDB 权限。Redis 无用户名,有密码:在本地 `.env` 配置 `REDIS_PASSWORD`,保持 `REDIS_USERNAME` 为空。`PGSSLMODE=disable` 是本地模板值,如服务器要求 TLS 则修改。
```sh
go mod download -C services/api
go mod download
npm ci
make db-create
make db-migrate
@@ -71,18 +71,28 @@ VEYRA_TEST_DATABASE_URL='postgres://user:password@host:5432/test_db?sslmode=disa
## 目录
```text
apps/admin/ Vite React 管理端
services/api/cmd/api/ API 入口
services/api/cmd/db/ 建库与迁移入口
services/api/cmd/user/ 开发身份初始化入口
services/api/internal/identity/ 身份领域
services/api/internal/portfolio/ 账户领域
services/api/internal/operations/ 服务健康业务
services/api/internal/platform/ 配置与数据库设施
services/api/internal/transport/ HTTP 协议适配
services/api/api/openapi.yaml 当前 HTTP 契约
cmd/
api/ API 入口与依赖装配
db/ 建库与迁移命令
user/ 开发身份初始化命令
internal/
config/ 配置加载与校验
database/migrations/ 数据库连接与版本化迁移
model/ User、Account、Session 等模型
repository/ PostgreSQL 数据访问与事务
service/ 登录、账户和健康检查业务
handler/ HTTP 路由、中间件与协议适配
adminui/ 管理端 embed 资源与静态服务
apperror/ 跨层业务错误
ratelimit/ Redis 登录限流
integration/ 数据库集成测试
web/admin/ Vite React 管理端
api/openapi.yaml HTTP 契约
go.mod / go.sum 根目录唯一 Go module
```
仓库采用根目录 Go 单模块结构,管理端放在 `web/admin`,无需 `go.work`。文件按职责划分,调用方向为 handler → service → repository;接口在 service 中定义,由 repository 实现,避免 service 依赖具体数据库。
采用显式 SQL 和结构体 db tag,避免 ORM 隐式推断表名。迁移打包到 Go 二进制,已执行迁移不可改写,后续修改新增版本。API 启动不自动建库或迁移。健康检查不会返回连接串和供应商错误细节。
## 待完成