service.xpcool.com/PROJECT_STRUCTURE.md
夏犀麟 5cd8f0f551 refactor(api): 契约文件 index.go 重命名为 <功能名>.go
- tools/{uuid,md5,random,time,ip}/index.go → 对应 <功能名>.go(git mv 保留历史)
- 目录名=包名=文件名三一致,扩展时目录内按功能加文件(ocr.go → + idcard.go + invoice.go)
- doc.go / AGENTS.md / PROJECT_STRUCTURE.md 同步规则说明
- 冒烟测试 5 端点全部通过
2026-08-24 18:07:33 +08:00

2.1 KiB

Production layout

service.xpcool.com/
├── api/                         # HTTP contracts and Swagger metadata
│   ├── user/v1/                 # /api/v1 - client-facing API
│   ├── admin/v1/                # /admin/v1 - administration API
│   └── open/v1/                 # /api/open/v1 - open API for frontends (no auth)
│       └── tools/               #   one dir per sub-feature: tools/<name>/<name>.go
├── common/                      # public reusable module (no internal/ deps)
│   └── tools/                   # utility toolbox: md5, cryptox, uuid, random,
│                                #   timex, convertx, strx, slicex, ip, filex
├── internal/
│   ├── cmd/                     # application bootstrap and route isolation
│   ├── consts/                  # application error codes and constants
│   ├── controller/              # API-to-service adapters only (incl. open/ open API)
│   ├── service/                 # domain use cases and provider interfaces
│   ├── dao/                     # generated by gf gen dao; never hand edited
│   ├── model/
│   │   ├── entity/              # generated database entities
│   │   ├── do/                  # generated Data Objects
│   │   ├── dto/                 # service boundary input/output
│   │   └── vo/                  # API view models
│   ├── middleware/              # configurable route-group middleware
│   └── library/                 # JWT, response, pagination primitives
├── docs/change-log/             # per-request change records (agent context)
├── manifest/
│   ├── config/                  # config.dev/test/prod.yaml
│   └── sql/                     # ordered MySQL migrations
└── utility/                     # optional cross-cutting helpers

dao, model/do and model/entity are generated after migration, so their schema never drifts from MySQL. Controllers do not access DAO; only services do.

See AGENTS.md for the agent-facing conventions and the context-memory system.