CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/go-project-structure

Go project structure -- cmd/internal layout, handler/service/repository layers, Makefile, config from environment, domain error types, test placement, dependency injection

90

1.02x
Quality

84%

Does it follow best practices?

Impact

100%

1.02x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-2/

{
  "context": "Tests whether the agent creates a Go inventory API with proper cmd/internal layout, three-layer architecture, domain types and errors, config from environment, Makefile, and correct test placement.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "cmd/ entry point",
      "description": "main.go is in cmd/<name>/ and wires dependencies using constructors -- no business logic or SQL in main",
      "max_score": 7
    },
    {
      "name": "internal/ for all app code",
      "description": "All application packages are inside internal/ (handler, service, repository, domain, config)",
      "max_score": 8
    },
    {
      "name": "Handler package with struct",
      "description": "internal/handler/ has a Handler struct with injected service dependencies and a route registration method",
      "max_score": 7
    },
    {
      "name": "Service layer with repository interfaces",
      "description": "internal/service/ contains business logic and defines interfaces for its repository dependencies",
      "max_score": 8
    },
    {
      "name": "Repository layer",
      "description": "internal/repository/ or internal/store/ has concrete database implementations separate from handlers",
      "max_score": 6
    },
    {
      "name": "Domain package with models",
      "description": "Domain types (Product, StockLevel, InventoryMovement) are in internal/domain/ or internal/model/ with no external dependencies",
      "max_score": 6
    },
    {
      "name": "Domain error types defined",
      "description": "Error types (NotFound, Validation, Conflict) with HTTP status mapping are in a domain or errors package",
      "max_score": 7
    },
    {
      "name": "Centralized error response",
      "description": "A writeError helper maps domain errors to HTTP status codes using errors.As or type switching",
      "max_score": 5
    },
    {
      "name": "Config from environment with defaults",
      "description": "internal/config/ loads PORT, DATABASE_URL, and timeouts from env vars with sensible defaults",
      "max_score": 7
    },
    {
      "name": "Makefile with build and test",
      "description": "Makefile has at least build, test (with -race), and run targets",
      "max_score": 6
    },
    {
      "name": "Tests alongside source code",
      "description": "Test files are in the same directory as source (e.g., internal/service/inventory_test.go), not in a tests/ directory",
      "max_score": 7
    },
    {
      "name": "Table-driven tests",
      "description": "At least one test file uses table-driven test pattern with t.Run subtests",
      "max_score": 5
    },
    {
      "name": "go.mod present",
      "description": "go.mod exists with a module path",
      "max_score": 4
    },
    {
      "name": ".gitignore for Go",
      "description": ".gitignore includes bin/, *.test, coverage.out, .env",
      "max_score": 4
    },
    {
      "name": "Graceful shutdown",
      "description": "main.go handles OS signals for graceful HTTP server shutdown",
      "max_score": 4
    },
    {
      "name": "HTTP server timeouts",
      "description": "http.Server is configured with ReadTimeout and WriteTimeout from config, not using default zero values",
      "max_score": 4
    }
  ]
}

evals

tile.json