cmd/server/main.gois the entry point for the API server.internal/holds core packages:config,credential,gateway,middleware,signature,vertex, and sharedpkghelpers.internal/gateway/manager/views/contains.templUI templates (generated Go files end with_templ.go).data/stores runtime data (for exampleaccounts.jsonand signatures); avoid committing sensitive values.benchmark.shandbenchmark_results/capture performance profiles and summaries.serveris the built binary;start.shorchestrates build + run.
./start.sh: loads.env, checks required vars, builds templ + Go, and launches the server onHOST:PORT.templ generate internal/gateway/manager/views: regenerates templ views (installed viago install github.com/a-h/templ/cmd/templ@latest).go build -o server ./cmd/server: builds the backend binary.go test ./...: runs unit tests across all packages.docker build -t ant2api .: builds the container image.docker-compose up -d: runs the published image with env overrides.
- Go code should stay
gofmt-clean and follow standard Go package naming (lowercase, no underscores). - Tests live alongside code and use the
*_test.gosuffix. - Environment variables are uppercase snake case and documented in
.env. - Keep gateway-specific code inside
internal/gateway/<provider>/to avoid cross-provider coupling.
- Primary framework is Go’s
testingpackage; rungo test ./...before submitting. - New behavior should include a focused unit test in the same package.
- If adding UI templates, regenerate templ output and ensure tests still pass.
- Commit messages are short and descriptive; history shows both plain Chinese summaries and type prefixes like
chore:. - Prefer imperative, single-scope subjects (example:
chore: ignore accounts.json files). - PRs should include: a brief summary, how to run tests, and any
.envor data format changes. - Include screenshots for UI changes under
internal/gateway/manager/views/.
WEBUI_PASSWORDis required;API_KEYis optional but recommended for protection.- Keep secrets out of Git; use
.envor environment injection in Docker. - Runtime data in
data/should be treated as stateful and backed up before migrations.