How codetheuri/tusk works
Project type and purpose
• This is a Go-based API starter template (“Tusk”) implementing a backend service with no frontend shipped.
• Purpose: Provide a clean-architecture foundation with modules (auth, todo), CLI tools (migrate, genmodule), middleware, logging, and database support to accelerate API development.
File structure
• Top-level:
• cmd/ → entrypoints for server (cmd/main.go), migration CLI (cmd/migrate), module generator CLI (cmd/genmodule)
• internal/ → core application code organized by layer and module
• pkg/ → shared utilities (auth token, errors, logger, mailer, middleware, pagination, validators, web helpers)
• config/, database/, docker-compose.yml, Dockerfile → configuration and infrastructure
• internal/app:
• routers/ → HTTP router initialization (using chi)
• auth/ → auth handlers, services, repositories, models, JWT & Bcrypt flows
• todo/ → todo domain handlers, services, repositories, models
• module.go → module registration interfaces
• internal/platform/database → GORM setup
• internal/bootstrap/app.go → app assembly, module registration, middleware wiring
• database/migrations & seeders → schema definitions and initial data
• pkg middleware & utils used across handlers and services
Key insights from README
• Clean Architecture layering: handlers → services → repositories → models
• Uses Go-Chi for routing, GORM for ORM and migrations
• JWT-based authentication, Bcrypt hashing
• CLI tools for migrations and scaffolding new modules
• Logging, validation, error handling, pagination, mailer all pluggable via pkg/
Detailed capture of essential elements
• Middleware chain wrapping handlers
• Interface boundaries: service interfaces and repository interfaces in modules
• Module generator CLI interacting with the file system to scaffold new code directories