Get started
Project structure
Where each part of a GOTTH+ project lives, and what it is for.
Layout
cmd/server/ entry point: config, database, cache, server start, graceful shutdown
internal/
app/ routes (newMux) and middleware chain (buildHandler), shared by main and the tests
auth/ with sign-in: sessions, the signed-in user, providers, per-account limits
cache/ with --cache: the Redis or Memcached cache and CheckCache
config/ environment loading and validation
csrf/ double-submit-cookie CSRF protection
database/ database connection (GORM: SQLite, Postgres or MySQL)
dto/ validated request shapes
escaper/ SQL LIKE wildcard escaping
factory/ handler constructors (closures over dependencies)
handler/ struct-based handlers (the health check)
helper/ generic helpers
mail/ with password sign-in: emails, by SMTP in production and to the log in development
middleware/ security headers, rate limit, compression, body limit, admin key
model/ domain types
optimistic/ hx-optimistic config builders
repository/ data access behind interfaces, sentinel errors, pagination
requestid/ request IDs in headers and logs
seed/ the dev-only /seed route: creates the tables and loads sample data
service/ business rules
styles/ shared Tailwind class strings
view/ .templ components and their generated *_templ.go
static/
input.css Tailwind entry point
js/app.js Alpine components and htmx hooks
js/*.min.js htmx, its preload extension, Alpine (CSP) and hx-optimistic
font/ icon/ your self-hosted fonts and icons
download-js.sh downloads the JavaScript libraries (make js)
seed.sh runs POST /seed with a CSRF token (make seed)
seedData.json sample data
Makefile every command, run make help
Dockerfile with --docker: the production imageWhere to start
- Pages and components: internal/view. Full pages wrap themselves in Layout; fragments never do.
- Routes: newMux in internal/app/app.go. Register new routes there.
- Handlers: internal/factory. They parse, validate, call a service or repository, then render.
- Client behaviour: static/js/app.js, registered by name, because Alpine runs its CSP build.
Was this page helpful?
Be the first to answer.