搭建后端工程骨架(Go + Gin + PostgreSQL)

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

@linuxsuren-fs is already working on this.

Since Nov 14, 2026.

  • #21 by @linuxsuren-fs — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
go, postgresql

Research direction

Review issues #1, #2, #3, and #6 first; this work depends on their decisions, and an open linked pull request (#21) indicates implementation is already underway. The issue names the intended entry points, including cmd/server/main.go, internal/config, internal/repository, migrations/, and docs/openapi.yaml. Done means the listed build, test, health check, migration, middleware, and tooling requirements are met.

Written by the indexing model from the issue text.

Description

help wanted P0

Background

TickFlow 后端基座。总体方案见 #1、API 契约见 #3、隔离与权限见 #6、数据模型见 #2。本 issue 只落地工程骨架,不实现业务功能。

Technical requirement

  • Go module github.com/LinuxSuRen/tick-flow,后端代码在仓库顶层 cmd/ + internal/;
  • Web 框架 Gin;
  • 配置:环境变量优先,可选 YAML 覆盖(监听地址、PostgreSQL DSN、SMTP、上传目录、JWT secret);
  • 目录结构:
cmd/server/main.go
internal/
  config/        # 配置加载
  router/        # 路由注册
  middleware/     # RequireAuth / RequireRole / recovery / request id / 访问日志
  handler/       # HTTP 入参出参
  service/       # 领域逻辑(状态机、事件发布)
  repository/    # 数据访问,统一 tenant scope
  model/         # 表模型
  events/        # 领域事件定义与分发
migrations/      # golang-migrate 迁移文件
docs/openapi.yaml
  • 日志:标准库 log/slog,JSON 结构化、分级(高频路径 debug,关键链路出入口 info);
  • 迁移:golang-migrate,落地 #2 评审通过的初始迁移;
  • repository 层提供统一 scope(ctx) helper(见 #6),附单测;
  • GET /healthz:含数据库 ping;
  • Makefile:make build / test / lint / run;Dockerfile 多阶段构建(预留前端产物嵌入路径);
  • 禁止任何硬编码默认账号或默认密码;首启引导走 POST /api/auth/setup。

Expect

  • go build ./... 与 go test ./... 通过;本地启动后 /healthz 返回 200;
  • PR 描述附目录结构说明与启动方式。

Potential TODO list

  • go mod init 与目录骨架
  • 配置加载 + slog 接入
  • golang-migrate 初始迁移(依赖 #2 评审通过)
  • auth / role 中间件 + tenant scope helper(含单测)
  • healthz、panic recovery、request id、访问日志
  • Makefile + Dockerfile

依赖

#2、#3、#6 评审通过。

Dominant language
No language data
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LinuxSuRen/tick-flow

All issues in LinuxSuRen/tick-flow

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.