Imported from VolynkinS/simple-service (
AGENTS.md). Install upstream withnpx skills add VolynkinS/simple-service. Copyright stays with the author.
Repository Guidelines
Project Structure & Module Organization
Simple Service is a Go REST API built on Fiber with PostgreSQL persistence. Core layout:
cmd/main.goboots the HTTP server, loads env config, and registers routes.internal/apiholds handlers and middleware; align new feature folders with existing modules.internal/serviceencapsulates business rules and relies oninternal/repofor pgx-based data access.pkg/validatorhosts reusable helpers with dedicated tests inpkg/validator/validator_test.go.migrations/postgresstores ordered SQL migrations applied automatically by Docker.docscaptures generated Swagger artifacts; regenerate instead of editing manually.
Build, Test, and Development Commands
docker-compose up -d postgresstarts PostgreSQL with seed migrations.make depssyncs Go modules.make buildproducesbin/simple-service.make runlaunches the API usinglocal.env.make testrunsgo test -v ./... -cover.make lintexecutesgolangci-lint run; ensure the binary is on PATH.make swagger-genrefreshes OpenAPI docs fromcmd/main.goannotations.
Coding Style & Naming Conventions
- Format with
go fmt ./...; do not commit unformatted code. - Keep lint clean; follow the guidance emitted by
golangci-lint. - Use UpperCamelCase for exported identifiers and lowerCamelCase for internals; file names stay snake_case.
- Group feature-specific DTOs under
internal/dtoand keep middleware small and focused.
Testing Guidelines
- Prefer table-driven tests in
_test.gofiles alongside the code they verify. - Maintain or improve coverage reported by
make test; add service and repo assertions when adjusting business rules. - Seed integration tests against Docker DB via
local.envcredentials; clean up created rows.
Commit & Pull Request Guidelines
- Follow Conventional Commits (
feat:,fix:,chore:) as seen ingit log. - Keep commits scoped narrowly and include related migrations or docs updates.
- PRs need a short summary, testing notes (e.g.,
make test), and linked issues or TODO references; attach Swagger screenshots when endpoints change. - Request review only after lint and tests pass locally.
Environment & Configuration Tips
- Copy
local.envas the base for new environment files; never commit secrets. - Update
Dockerfileanddocker-compose.ymltogether when adding config variables. - Document new env vars in
README.mdand ensure sensible defaults exist for local development.