# README

gothem-stack
An end to end htmx and go-templ template using echo for the web server and mage for deployment. Other than that this is unopinionated so bring all your other favorite technologies :)
Go
Templ
HTMX
Echo
Mage
For the frontend libraries it uses tailwindcss and daisyUI for styling. You can easily integrate alpine-js or hyperscript if you desire. The example integrates with both.
Quickstart
- Install npm in your path
brew install node; brew install npm
- Install mage in your path
brew install mage
. See https://magefile.org/ for other installation instructions - Run
mage install
- Run
mage run
- Open http://localhost:7331 (the server is listening on :4433 but templ injects a watcher with an autoreload script)
When you make changes to your templ files or any of your go code everything will regenerate and then autoreload your web page
Basic Commands
mage run
- Run an interactive development environment that will automatically reload on any file change. Listens on port :4433 and has an autoreload page on :7331
mage install
- Install all the dependencies
mage templ
- Do a one time regeneration of your templ files
mage build
- Do a one time build of the go files
mage tidy
- Run go mod tidy
Cloud Deployment (Optional)
The project also includes optional support for deploying your code to Google Cloud Run and Firebase Hosting. This is by no means required to use this project, if you choose to you can just ignore all these commands and use it without cloud integration. To use these features, you'll need to set up Google Cloud and Firebase projects first.
See the example running at gothem-stack.web.app
Cloud Deployment Commands
mage auth [gcloud|firebase]
- Authenticate with Google Cloud or Firebase services
mage deploy [backend|frontend|all]
- Deploy your application
backend
- Deploys to Google Cloud Runfrontend
- Deploys to Firebase Hostingall
- Deploys both (default if no argument provided)
mage release [backend|frontend|all]
- Move to a specific version of the backend service
mage destroy
- Tear down all cloud infrastructure created during the deployment
Required Environment Variables for Cloud Deployment
If using cloud deployment, you'll need to set these environment variables:
GOOGLE_CLOUD_PROJECT
- Your Google Cloud project IDGOOGLE_CLOUD_REGION
- The region to deploy to (defaults to us-central1)CLOUD_RUN_SERVICE_NAME
- The name of your Cloud Run service
You can place these variables in a env file to declaratively use them. For example you could run
echo "GOOGLE_CLOUD_PROJECT=foobar-123\nGOOGLE_CLOUD_REGION=us-central1\nCLOUD_RUN_SERVICE_NAME=gothem-stack" > gothem-stack.env
Then you can run ENV=gothem-stack mage deploy
to use the configured environment variables.
But Gotham is spelled with an 'a'....
Yea I know it's spelled with an 'a' :] I was trying to come up with a name that was easier to say and interact with than 'htmx-templ-template' and gothem is what I came up with.