A production-ready Go web application template built with the H.A.T. Stack: HTMX, Alpine.js, and Templ.
This bootstrap provides everything you need to start building modern web applications with Go, featuring a clean architecture, type-safe templates, and live-reload development.
Want to get started immediately? Check out the Quick Start Guide for a 5-minute setup!
- What is the H.A.T. Stack?
- Features
- Tech Stack
- Getting Started
- Project Structure
- Architecture
- Development
- Customizing for Your Project
- Contributing
- Why H.A.T. Stack?
- HTMX - Server interactions without writing JavaScript
- Alpine.js - Lightweight client-side reactivity (when you need it)
- Templ - Type-safe Go templates with compile-time checking
Combined with Go's performance and simplicity, the H.A.T. Stack enables rapid development of modern web applications with minimal frontend complexity.
- ✅ Dual Architecture: Support for both JSON API endpoints (
/api/*) and server-rendered HTML pages - ✅ Repository Pattern: Clean data access layer with Google Cloud Datastore
- ✅ Service Layer: Business logic separation with proper dependency injection
- ✅ Type-Safe Templates: Templ provides compile-time type safety for HTML templates
- ✅ Live Reload: Air for automatic rebuilding during development
- ✅ Modern Frontend: HTMX for dynamic interactions, Alpine.js for reactivity, TailwindCSS for styling
- ✅ Cross-Platform: Works on Windows, Linux, and macOS
- Go - Primary language
- Gin - Web framework
- Templ - Type-safe Go templates
- Zerolog - Structured logging
- Google Cloud Datastore - NoSQL database
- HTMX - Server interactions without JavaScript
- Alpine.js - Lightweight client-side reactivity
- TailwindCSS - Utility-first CSS framework
- Go 1.24 or higher - Download Go
- Google Cloud account - For Datastore (optional, can be replaced with another database)
Perfect if you want to start your own repository from scratch:
-
Download the latest release:
# Download and extract curl -L https://github.com/runtime-dynamics/hatstack/archive/refs/heads/main.zip -o hatstack.zip unzip hatstack.zip cd hatstack-main # Or use wget wget https://github.com/runtime-dynamics/hatstack/archive/refs/heads/main.zip unzip main.zip cd hatstack-main
-
Initialize your own Git repository:
rm -rf .git # Remove the bootstrap's git history git init git add . git commit -m "Initial commit from H.A.T. Stack bootstrap"
-
Update the module name in
go.mod:module github.com/yourusername/yourproject
-
Run setup:
Windows:
setup.bat
Linux/Mac:
chmod +x setup.sh ./setup.sh
Best if you want to contribute back or stay updated with bootstrap improvements:
# Clone the repository
git clone https://github.com/runtime-dynamics/hatstack.git
cd hatstack
# Run setup
# Windows:
setup.bat
# Linux/Mac:
chmod +x setup.sh
./setup.shThe setup script will:
- ✅ Install Air (live-reload tool) if not present
- ✅ Install Templ (template generator) if not present
- ✅ Create
.envfile with template (you'll need to configure it) - ✅ Set up platform-specific Air configuration
- ✅ Make scripts executable (Linux/Mac)
Edit the .env file with your settings:
# Google Cloud Configuration
DATASTORE_NAME=your-datastore-name
PUBSUB_TOPIC=your-pubsub-topic
PUBSUB_SUBSCRIPTION=your-pubsub-subscription
# Frontend Configuration
FRONTEND_ENDPOINT=http://local.nitecon.net:8080
# Google Cloud Authentication
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
# OR
GOOGLE_PROJECT_ID=your-project-id
# Development Settings
DEBUG=true
PORT=8080airOr use the quick launcher (Linux/Mac):
./dev.shThe server will:
- ✅ Generate Templ templates automatically
- ✅ Load environment variables from
.env - ✅ Build and start the application
- ✅ Rebuild on file changes (
.go,.templ,.html) - ✅ Hot-reload in your browser
Access the application: http://localhost:8080
You should see the H.A.T. Stack welcome page! 🎉
- Customize the homepage - Edit
views/pages/home.templ - Add your first API endpoint - See
web/api/routes.go - Create a new page - Add a handler in
web/app/and template inviews/pages/ - Read the coding guidelines - Check
Docs/CodingGuidelines.mdfor best practices
.
├── cmd/ # Application entry points
│ └── main.go # Main application
├── config/ # Configuration management
├── data/ # Data layer (repositories)
├── services/ # Business logic layer
├── web/ # Web layer
│ ├── api/ # JSON API handlers (/api/*)
│ └── app/ # HTML page handlers
├── views/ # Templ templates
│ ├── components/ # Reusable UI components
│ ├── layouts/ # Page layouts
│ └── pages/ # Page templates
├── static/ # Static assets (CSS, JS, images)
├── scripts/ # Development scripts
└── Docs/ # Documentation
└── CodingGuidelines.md
API Handlers (web/api/):
- Handle
/api/*routes - Return JSON responses
- Used for AJAX/fetch requests
App Handlers (web/app/):
- Handle all other routes
- Return HTML via Templ templates
- Server-side rendering
Handler → Service → Repository → Datastore
- Handlers: HTTP request/response handling
- Services: Business logic and orchestration
- Repositories: Data access and persistence
templ generateAir runs this automatically before each build.
go build -o ./tmp/main ./cmdgo test ./...After downloading/cloning the bootstrap, you'll want to customize it:
Edit go.mod and change the module path:
module github.com/yourusername/yourprojectThen update all imports in your Go files to match.
- Edit
views/pages/home.templ- Update the homepage content - Replace
static/images/logo-square_128.pngwith your logo - Update
static/favicon.icowith your favicon
The bootstrap uses Google Cloud Datastore by default. To use a different database:
- Update the repository implementations in
data/ - Modify
data/data.goto initialize your database client - Update the
.envconfiguration
The bootstrap includes examples for common patterns. Remove what you don't need:
- Example repositories in
data/ - Example services in
services/ - Example handlers in
web/api/andweb/app/
This project includes a production-ready Dockerfile that can be deployed directly to Google Cloud Run or any container platform.
# Build the Docker image
docker build -t hatstack-app .
# Run locally with Docker
docker run -p 8080:8080 --env-file .env hatstack-app
# Test the container
curl http://localhost:8080# Deploy directly from source
gcloud run deploy hatstack-app --source .
# Or build and deploy
docker build -t gcr.io/YOUR-PROJECT-ID/hatstack-app .
docker push gcr.io/YOUR-PROJECT-ID/hatstack-app
gcloud run deploy hatstack-app --image gcr.io/YOUR-PROJECT-ID/hatstack-appSet these environment variables in your deployment platform:
DATASTORE_NAME- Your Datastore database nameGOOGLE_PROJECT_ID- Your Google Cloud project IDFRONTEND_ENDPOINT- Your application's public URLPORT- Port to listen on (default: 8080)
The Dockerfile is optimized for production:
- ✅ Multi-stage build for minimal image size
- ✅ Templ templates pre-generated
- ✅ Static assets included
- ✅ Non-root user for security
- ✅ Health check endpoint ready
- ✅ Cloud Run compatible
The bootstrap includes comprehensive tests for all components.
Run all tests:
# Linux/Mac
make test
# Windows
test.bat testRun with coverage:
# Linux/Mac
make test-coverage
# Windows
test.bat coverageRun benchmarks:
# Linux/Mac
make bench
# Windows
test.bat benchSee Testing Guide for detailed testing documentation.
- Quick Start Guide - Get started in 5 minutes
- Coding Guidelines - Development standards and patterns
- Testing Guide - Testing strategy and best practices
- Scripts Documentation - Development scripts reference
We welcome contributions to improve the H.A.T. Stack bootstrap!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style and patterns
- Update documentation for any new features
- Keep the bootstrap generic and reusable
- Test on both Windows and Linux/Mac if possible
- GitHub Issues - Report bugs or request features
- Discussions - Ask questions and share ideas
The H.A.T. Stack offers a refreshing alternative to heavy JavaScript frameworks:
- ✅ Less JavaScript - HTMX handles most interactions server-side
- ✅ Type Safety - Templ provides compile-time template checking
- ✅ Fast Development - Live reload and minimal build steps
- ✅ Better Performance - Server-side rendering with minimal client-side JS
- ✅ Easier Debugging - Server-side logic is easier to trace and test
- ✅ SEO Friendly - Full HTML rendering on the server
Perfect for:
- Internal tools and dashboards
- Content-heavy websites
- CRUD applications
- MVPs and prototypes
- Teams that prefer backend development
MIT License - feel free to use this bootstrap for any project!
Copyright © 2025 Runtime Dynamics LLC. All rights reserved.