/GOTTH

Go + Templ + HTMX + Alpine + Tailwind + Node + Chi + SQLC + Postrges

Primary LanguageGo

A Modified GoTTH Stack

Forked from this GoTTH stack walkthrough

Technologies

Backend

We are using NPM to generate our css using tailwind. In development, make sure to clear browser cache to get fresh stylesheets.

npm install

To get started with TailWind CSS, make sure you have the correct binary in the root directory. https://tailwindcss.com/blog/standalone-cli

Templating

go install github.com/a-h/templ/cmd/templ@latest

Server-Side Interactivity

Client-Side Interactivity

Database

The *.sql files in internal/db are in psql syntax. If only SQLC could generate files from the .psql file extension. One can dream

Object Relational Mapping

go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

Server Routing

Getting started

Development Tooling

  • make - utility
    • install for Windows: choco install make
    • install for MacOS: brew install make
    • no need for explanation to linux users
  • air - for development live-reloading
  • npm - for npm packages (Tailwindcss with plugins)
    • install Node
    • install packages run npm i

Environment Variables

Using the Go port of DotEnv. Example .env file for development:

DB_HOST="127.0.0.1"
DB_PORT="5432"
DB_DATABASE="sqlc-example"
DB_USERNAME="postgres"
DB_PASSWORD="password"

Local Development

git clone https://github.com/markkhoo/GOTTH.git
cd GOTTH
make dev

Makefile

This Makefile is designed to simplify common development tasks for your project. It includes targets for building your Go application, watching and building Tailwind CSS, generating templates, and running your development server using Air.

Targets:

This target watches the ./static/css/input.css file and automatically rebuilds the Tailwind CSS styles whenever changes are detected.

make tailwind-watch

This target minifies the Tailwind CSS styles by running the tailwindcss command.

make tailwind-build

This target generates templates using the templ command.

make templ-generate

This target generates database controllers in go using the sqlc command.

make sqlc-generate

This target runs the development server using Air, which helps in hot-reloading your Go application during development.

make dev

This target orchestrates the building process by executing the tailwind-build, templ-generate, sqlc-generate, and go build commands sequentially. It creates the binary output in the ./bin/ directory.

make build