Skip to content

gobijan/go-htmx-todo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-htmx-todo

A real-time TODO application built with Go, HTMX, WebSockets, and DOM morphing. This project demonstrates how to build responsive, interactive web applications without heavy JavaScript frameworks.

Todo App

Features

  • Real-time updates via WebSockets
  • Smooth UI transitions using HTMX and DOM morphing
  • SQLite database with GORM
  • Soft delete functionality
  • Live reload during development

Quick Start

Standard:

go run main.go

With live reload (requires air):

air

Visit http://localhost:8080 in your browser.

Tech Stack

  • Backend: Go with Chi router
  • Database: SQLite + GORM
  • Frontend: HTMX, idiomorph for DOM morphing
  • Real-time: Gorilla WebSocket

Architecture Philosophy

This codebase intentionally prioritizes simplicity and shipping speed over "best practices" and premature abstractions.

Core Principles

1. No layers until needed

  • Handlers call the database directly
  • No repository pattern, service layer, or interfaces
  • Extract to functions (not services) only when repeating 3+ times

2. One file for as long as possible

  • Everything visible at once makes reasoning easier
  • Split files only when navigation becomes genuinely hard
  • "Proper structure" can wait until it's actually painful

3. GORM is fine

  • Schema-as-structs and instant CRUD
  • Optimize when there are actual performance problems, not theoretical ones

4. Add complexity incrementally

  • Start simple, add features one at a time
  • Refactor when pain is real, not anticipated
  • Ship what works now

5. Functions over objects

  • Write functions with explicit parameters
  • Example: toggleTodo(db *gorm.DB, id int) not service.Toggle(id)
  • Dependencies should be visible, not hidden in struct fields

This approach trades "enterprise readiness" for shipping speed. The goal is to build and deploy real features, not to demonstrate architecture knowledge. Complexity can always be added later when actually needed.

Inspired by: Pieter Levels, Jon Calhoun, DHH


If this architecture bothers you, ask whether your suggested changes would help ship faster or just make the code "more correct." We optimize for the former.

Learn More

Read the full blog post: Go, WebSockets, HTMX & Morphing is Fun!

About

This is a Go TODO App using WebSockets, HTMX, and DOM-Morphing brought to you by Bijan.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published