kra-new/README.md

57 lines
1.7 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.

# Kra
Kra 是基于 Kratos 生命周期与 Wire 依赖注入、使用 Gin 提供管理端 HTTP API 的前后端管理系统。
## 目录
```text
cmd/ 服务入口与 Wire
configs/ 运行配置
internal/biz/ 领域对象、用例和仓储接口(按 system/payment/integration/task 拆分)
internal/config/ Viper 配置模型、加载和热更新
internal/data/ 数据库、缓存、对象存储及仓储实现
internal/initialize/ 首次安装、配置保存和重载编排
internal/server/ Gin 服务、路由、中间件和 Handler
internal/service/ 按业务模块组织的 HTTP 输入输出与领域对象转换
internal/worker/ 定时任务调度与后台工作进程
web/ Vue 管理端
```
## 启动后端
先修改 `configs/config.yaml`。首次启动时,如果目标数据库不可用,服务会保留初始化接口;在管理端初始化页面完成建库、建表和种子数据写入后即可登录。
```shell
go run ./cmd -conf ./configs
```
默认 HTTP 地址为 `http://127.0.0.1:8000`。生产环境必须替换 JWT 签名密钥和数据库凭据。
配置文件发生变化时会自动刷新内存配置管理端“重载服务”会进一步重建数据库、Redis、对象存储连接并重新载入定时任务。路由前缀和 HTTP 监听地址需要重启进程后生效。
## 启动前端
```shell
cd web
pnpm install
pnpm dev
```
构建产物和依赖目录 `web/dist/`、`web/node_modules/` 已加入 Git 忽略规则。
## 生成代码
修改 Wire Provider 或构造函数后执行:
```shell
go generate ./cmd
```
## 检查
```shell
go test ./...
go vet ./...
cd web && pnpm lint && pnpm build
```