A production-ready, full-stack web application template designed for radical simplicity and zero maintenance for 50+ years.
This template embodies permacomputing principles:
- Zero external dependencies at runtime
- Single binary deployment
- No build tools required
- No npm, no webpack, no transpilers
- Standard library first
- Simple, readable code
- Backend: Go 1.22+ (using new
http.ServeMuxfeatures) - Database: SQLite with WAL mode
- Frontend: HTMX for dynamic interactions
- Templating: Go
html/template - Styling: Modern CSS with semantic HTML
- ✅ Single binary compilation via
//go:embed - ✅ Automatic database migrations
- ✅ HTMX-powered dynamic UI (no JavaScript frameworks)
- ✅ Logging middleware
- ✅ Panic recovery middleware
- ✅ Responsive design with dark mode support
- ✅ Zero configuration required
.
├── main.go # Entry point
├── internal/
│ ├── db/
│ │ └── db.go # SQLite setup and migrations
│ └── handlers/
│ └── routes.go # HTTP handlers
├── ui/
│ ├── html/
│ │ ├── base.layout.tmpl # Base template
│ │ └── home.page.tmpl # Home page
│ └── static/
│ ├── css/
│ │ └── style.css # Semantic CSS
│ └── js/
│ └── htmx.min.js # HTMX library
└── app.db # SQLite database (auto-created)
- Go 1.22 or higher
- That's it!
Before building, download the HTMX library:
curl -sL https://unpkg.com/htmx.org@1.9.10/dist/htmx.min.js -o ui/static/js/htmx.min.jsOr with wget:
wget https://unpkg.com/htmx.org@1.9.10/dist/htmx.min.js -O ui/static/js/htmx.min.jsgo mod downloadgo run main.goThe application will start on http://localhost:8080
Build a single binary with all assets embedded:
go build -o perma-app main.goThe resulting binary is completely self-contained. Copy it anywhere and run:
./perma-appFor a smaller binary size:
go build -ldflags="-s -w" -o perma-app main.goOptional: Compress with UPX:
upx --best --lzma perma-appThe application uses sensible defaults. You can modify these constants in main.go:
const (
dbPath = "./app.db" // Database file path
port = "8080" // Server port
timeout = 30 * time.Second
)SQLite is configured with:
- WAL mode for better concurrency
- Automatic migrations on first run
- Connection pooling with reasonable limits
The database file app.db is created automatically on first run.
The application includes a "click-to-edit" user profile example demonstrating:
- Inline editing without page reloads
- HTML over the wire (no JSON APIs needed)
- Graceful degradation
Try it:
- Visit
http://localhost:8080 - Click "Edit" on any user card
- Modify the user's name or email
- Click "Save" or "Cancel"
Two middleware functions are implemented:
- Logging: Logs all HTTP requests with duration
- Panic Recovery: Catches panics and returns 500 errors gracefully
The CSS uses a semantic/classless approach:
- CSS custom properties (variables) for easy theming
- Automatic dark mode support via
prefers-color-scheme - Mobile-responsive design
- No CSS frameworks, no build steps
- Build the binary:
go build -ldflags="-s -w" -o perma-app main.go - Copy the binary to your server
- Run it:
./perma-app - Optional: Set up systemd service for auto-restart
Create /etc/systemd/system/perma-app.service:
[Unit]
Description=Permacomputing Web Application
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/perma-app
ExecStart=/opt/perma-app/perma-app
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl enable perma-app
sudo systemctl start perma-app- Define the handler in
internal/handlers/routes.go - Register it in
main.go:
mux.HandleFunc("GET /your-route", app.YourHandler)- Create
ui/html/yourpage.page.tmpl - Use
{{template "base" .}}to include the base layout - Render it from your handler:
app.Templates.ExecuteTemplate(w, "yourpage.page.tmpl", data)- Add migration SQL to
internal/db/db.goin themigrationsslice - Delete
app.dbto re-run migrations (or write a proper migration system)
This template is designed for low resource usage:
- Binary size: ~10-15MB (uncompressed)
- Memory usage: <50MB for typical workloads
- Startup time: <100ms
- Use HTTPS in production (reverse proxy with Caddy/Nginx recommended)
- Implement authentication/authorization as needed
- Validate all user input
- Use prepared statements (already done via
database/sql) - Keep Go updated for security patches
- Fast, compiled language
- Excellent standard library
- Single binary deployment
- Strong backward compatibility
- Zero configuration
- File-based (no separate server)
- ACID compliant
- Battle-tested and reliable
- <15KB library
- No build step required
- Hypermedia-driven (REST-ful)
- Works without JavaScript (progressive enhancement)
- Less code to maintain
- Fewer dependencies to break
- Better performance
- Easier to understand and modify
This template is released into the public domain. Use it however you want.
This is a template project. Fork it and make it your own!
For issues or questions, please open an issue on the repository.
To support the developer, you can make a donation here.
Built with ❤️ for longevity and simplicity