No description
  • TypeScript 49.7%
  • Go 36.4%
  • CSS 5.5%
  • PowerShell 4.6%
  • Shell 3.5%
  • Other 0.3%
Find a file
2026-11-08 00:13:22 +08:00
apps feat: 初始化首页 2026-11-08 00:13:22 +08:00
cmd feat: first commit 2026-11-04 22:52:10 +08:00
db/migrations feat: add skill 2026-11-05 20:45:53 +08:00
deployments/compose feat: first commit 2026-11-04 22:52:10 +08:00
internal feat: add skill 2026-11-05 20:45:53 +08:00
skills feat: add skill 2026-11-05 20:45:53 +08:00
.gitignore feat: first commit 2026-11-04 22:52:10 +08:00
AGENTS.md feat: add skill 2026-11-05 20:45:53 +08:00
config.example.yaml feat: add skill 2026-11-05 20:45:53 +08:00
game_community_architecture.md feat: add skill 2026-11-05 20:45:53 +08:00
go.mod feat: first commit 2026-11-04 22:52:10 +08:00
go.sum feat: first commit 2026-11-04 22:52:10 +08:00
main.go feat: first commit 2026-11-04 22:52:10 +08:00
package.json feat: first commit 2026-11-04 22:52:10 +08:00
pnpm-lock.yaml feat: first commit 2026-11-04 22:52:10 +08:00
pnpm-workspace.yaml feat: first commit 2026-11-04 22:52:10 +08:00
README.md feat: 初始化首页 2026-11-08 00:13:22 +08:00
start.ps1 feat: add skill 2026-11-05 20:45:53 +08:00
start.sh feat: add skill 2026-11-05 20:45:53 +08:00

Ludora

游戏社区平台的初始项目。当前包含 Go API、River Worker、游戏与社区的初始数据库迁移、Web 社区首页预览与游戏目录、Admin 状态页;账号、真实发帖、投票等业务功能尚未实现。Web 首页的示例讨论及交互只在当前页面有效,不写入数据库。设计依据见 架构文档。

本地要求

  • Go 1.26(或允许 Go 自动下载对应工具链)
  • Node.js 20.9+ 与 pnpm 10
  • PostgreSQL 17;可选用 Docker Compose 启动

启动

以下命令在仓库根目录执行。配置可从 config.example.yaml 复制为本地 config.yaml,或使用环境变量;config.yaml 已被忽略,不提交密钥。

启动脚本支持 server(Go API)、web(Next.js 用户端)、all(同时启动);省略参数时显示选择菜单。运行前需配置数据库 DSN、执行迁移并安装前端依赖。脚本从自身所在目录运行,不会自动安装依赖或启动数据库。

bash start.sh all
.\start.ps1 all

Windows 若禁用了 PowerShell 脚本执行,可使用 powershell -ExecutionPolicy Bypass -File .\start.ps1 all。在 all 模式下停止 Web 时,脚本也会停止由它启动的 API。

docker compose -f deployments/compose/dev.yaml up -d
$env:LUDORA_DATABASE_DSN = "postgres://ludora:ludora_dev@localhost:5432/ludora?sslmode=disable"
go run . migrate
go run . api

另开终端启动 Worker:

$env:LUDORA_DATABASE_DSN = "postgres://ludora:ludora_dev@localhost:5432/ludora?sslmode=disable"
go run . worker
pnpm.cmd install
pnpm.cmd dev:web

再开一个终端启动 Admin:

pnpm.cmd dev:admin

Web: http://localhost:3000;Admin: http://localhost:3001;API: http://localhost:8080。前端服务端可用 API_INTERNAL_URL 指定 API 地址。API 健康检查分别为 /health/live 和 /health/ready。当前没有种子数据,游戏目录显示空状态。

根目录 main.go 使用 Cobra 组合 api、worker、migrate 子命令;go run . --help 可查看命令列表。go run . migrate 先执行 db/migrations/ 中的应用迁移,再执行 River 自带迁移;从仓库根目录运行。生产环境应使用独立的迁移任务,不在 API 或 Worker 启动时自动改表。

开发环境可在本地 config.yaml 中设置 environment: development 和 database.auto_migrate: true,API 启动时会用 GORM 同步已注册的 Game、Community Entity。默认值为 production 和 false;正式环境禁止开启自动同步。自动同步只覆盖当前注册的模型,不负责 River 表、数据回填或字段重命名/删除;正式环境继续使用版本化 SQL 迁移。初次建库建议先运行 go run . migrate,之后可在开发环境开启自动同步验证新增的 Entity 字段,避免绕过迁移历史。

后续需求涉及新增或修改表时,开发任务会同时更新 Entity 和版本化 SQL 迁移,并主动对已确认的开发数据库执行 go run . migrate、核对结构和 API 行为。仓库内的操作约定见 skills/local-schema-upgrade/SKILL.md;生产数据库仍按独立部署流程升级。

检查

go test ./...
go build ./...
pnpm.cmd --filter @ludora/web typecheck
pnpm.cmd --filter @ludora/admin typecheck
pnpm.cmd build

当前 Admin 只是服务状态页,未接入认证,不能将其作为可公开访问的管理后台部署。