How maddalax/htmgo works
htmgo is a Go framework and toolchain for building interactive, server-rendered websites with htmx. Its principal workflow is to define pages and partials in Go, register routes, handle requests through the framework, and render HTML responses; the CLI supports project setup and development workflows. Separate branches cover WebSocket interactions, HTML-to-Go conversion, and the project’s own website. Some subsystems are represented from README or source-index references because their implementation excerpts were not provided; edges are limited to documented or visible relationships.
Main entry points: app.go HTTP App Server · runner.go CLI Runner · main.go HTML-to-Go Converter · handler.go WebSocket HTTP Handler
Components 28
Web Framework
- Go Page and Partial Authoring
framework/h - HTTP App Server
framework/h/app.go - Request Lifecycle
framework/h/lifecycle.go - htmx Support
framework/hx - Service Locator
framework/service/locator.go - HTML Rendering
framework/h/render.go - JS Commands
framework/js/commands.go
CLI Tooling
- CLI Runner
cli/htmgo/runner.go - Page Registration
cli/htmgo/tasks/astgen/entry.go - Template Setup
cli/htmgo/tasks/downloadtemplate/main.go - Build and Watch Tasks
cli/htmgo/tasks
WebSocket Extension
- WebSocket HTTP Handler
extensions/websocket/internal/wsutil/handler.go - Socket and Room Manager
extensions/websocket/internal/wsutil/manager.go - WebSocket Event Handlers
extensions/websocket/ws/handler.go - Socket Sessions
extensions/websocket/session/session.go
Project Website
- Website App
htmgo-site/main.go - Website Pages
htmgo-site/pages/index.go - Website Layout and Navigation
htmgo-site/partials/navbar.go - Markdown and Site Helpers
htmgo-site/internal
HTML Converter
- HTML-to-Go Converter
tools/html-to-htmgo/htmltogo/main.go - HTML Parser Adapter
tools/html-to-htmgo/internal/adapters/services/parser/parser.go - Parsed Node Model
tools/html-to-htmgo/internal/domain/node.go - Go Formatter Adapter
tools/html-to-htmgo/internal/adapters/services/formatter/formatter.go
Other components
- Developer
- Website Visitor
- Browser
- HTML Input
- Go Markup Output
Connections 27
- Developer → CLI Runner: runs commands
cli/htmgo/runner.go - CLI Runner → Page Registration: invokes registration
cli/htmgo/runner.go - CLI Runner → Template Setup: invokes setup
cli/htmgo/runner.go - CLI Runner → Build and Watch Tasks: runs tasks
cli/htmgo/runner.go - Developer → Go Page and Partial Authoring: defines pages
- Go Page and Partial Authoring → HTTP App Server: registers pages
- HTTP App Server → Request Lifecycle: handles requests
- HTTP App Server → htmx Support: uses htmx headers
framework/h/app.go - HTTP App Server → Service Locator: provides services
framework/h/app.go - Request Lifecycle → htmx Support: uses htmx helpers
framework/h/lifecycle.go - Browser → HTTP App Server: sends requests
framework/h/app.go - HTTP App Server → HTML Rendering: renders responses
- HTML Rendering → Browser: returns HTML
- JS Commands → Go Page and Partial Authoring: uses markup API
framework/js/commands.go - HTTP App Server → WebSocket HTTP Handler: serves socket handler
- WebSocket HTTP Handler → Socket and Room Manager: adds and dispatches
extensions/websocket/internal/wsutil/handler.go - Socket and Room Manager → WebSocket Event Handlers: emits socket events
- WebSocket Event Handlers → Socket and Room Manager: reads socket state
extensions/websocket/ws/handler.go - WebSocket HTTP Handler → Socket Sessions: uses sessions
- Website Visitor → Website App: visits site
htmgo-site/main.go - Website App → Markdown and Site Helpers: registers services
htmgo-site/main.go - Website Pages → Website Layout and Navigation: wraps page
- HTML Input → HTML-to-Go Converter: provides markup
tools/html-to-htmgo/htmltogo/main.go - HTML-to-Go Converter → HTML Parser Adapter: parses input
tools/html-to-htmgo/htmltogo/main.go - HTML Parser Adapter → Parsed Node Model: builds nodes
tools/html-to-htmgo/internal/adapters/services/parser/parser.go - HTML-to-Go Converter → Go Formatter Adapter: formats nodes
tools/html-to-htmgo/htmltogo/main.go - HTML-to-Go Converter → Go Markup Output: returns Go markup
tools/html-to-htmgo/htmltogo/main.go