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

task.mdevals/scenario-1/

Scaffold a Go Blog API with Posts and Comments

Problem/Feature Description

A developer is building a blog platform backend in Go. The API needs to manage blog posts (create, read, update, delete) and comments on posts. Posts have an author, title, body, tags, and publication status (draft/published). Comments belong to a post and have an author name and body.

The developer previously had everything in one big main.go and wants to restructure it properly from scratch.

Output Specification

Produce a complete project structure with:

  • go.mod with module path
  • cmd/api/main.go -- entry point with dependency wiring (repository -> service -> handler), HTTP server with read/write timeouts from config, graceful shutdown
  • internal/config/config.go -- Config loading PORT, DATABASE_URL, ALLOWED_ORIGINS from environment with defaults
  • internal/domain/models.go -- Post (ID, AuthorID, Title, Body, Tags, Status, CreatedAt, UpdatedAt), PostStatus (draft/published), Comment (ID, PostID, AuthorName, Body, CreatedAt), CreatePostRequest, UpdatePostRequest, CreateCommentRequest
  • internal/domain/errors.go -- AppError, NotFoundError, ValidationError
  • internal/handler/ -- Handler struct, route registration with middleware (logging, recovery, CORS), POST/GET/PUT/DELETE for posts, POST/GET for comments on a post, writeJSON and writeError helpers
  • internal/service/posts.go -- PostService with business logic (validate required fields, check status transitions), defines PostRepository interface
  • internal/service/comments.go -- CommentService, defines CommentRepository interface
  • internal/repository/posts.go -- SQL-based PostRepo
  • internal/repository/comments.go -- SQL-based CommentRepo
  • Makefile with build, run, test, lint, fmt, tidy targets
  • .gitignore for Go projects
  • internal/service/posts_test.go with table-driven tests for post creation validation and status transitions

evals

scenario-1

criteria.json

task.md

tile.json