···11-.PHONY: build run dev templ css clean
22-33-# Build the application
44-build: templ css
55- go build -o bin/arabica cmd/server/main.go
66-77-# Generate templ files
88-templ:
99- templ generate
1010-1111-# Build CSS with Tailwind
1212-css:
1313- tailwindcss -i web/static/css/style.css -o web/static/css/output.css --minify
1414-1515-# Run the application
1616-run: build
1717- ./bin/arabica
1818-1919-# Clean build artifacts
2020-clean:
2121- rm -rf bin/
2222- rm -f arabica.db
2323- rm -f web/static/css/output.css
2424- find . -name "*_templ.go" -delete
2525-2626-# Initialize database (for testing)
2727-init-db:
2828- rm -f arabica.db
2929- @echo "Database will be created on first run"
+12-51
README.md
···11# Arabica - Coffee Brew Tracker
2233-A self-hosted web application for tracking your coffee brewing journey. Built with Go, Templ, and SQLite.
33+A self-hosted web application for tracking your coffee brewing journey. Built with Go and SQLite.
4455## Features
66···16161717- **Backend**: Go 1.22+ (using stdlib router)
1818- **Database**: SQLite (via modernc.org/sqlite - pure Go, no CGO)
1919-- **Templates**: Templ (type-safe HTML templates)
1919+- **Templates**: html/template (Go standard library)
2020- **Frontend**: HTMX + Alpine.js
2121- **CSS**: Tailwind CSS
2222- **PWA**: Service Worker for offline support
···3030│ ├── database/ # Database interface & SQLite implementation
3131│ ├── models/ # Data models
3232│ ├── handlers/ # HTTP handlers
3333-│ └── templates/ # Templ templates
3333+│ └── templates/ # HTML templates
3434├── web/static/ # Static assets (CSS, JS, PWA files)
3535-├── migrations/ # Database migrations
3636-└── Makefile # Build commands
3535+└── migrations/ # Database migrations
3736```
38373938## Getting Started
40394140### Prerequisites
42414343-- Go 1.22+
4444-- Templ CLI
4545-- Tailwind CSS CLI
4646-- (Optional) Air for hot reload
4747-4848-Or use Nix:
4242+Use Nix for a reproducible development environment with all dependencies:
49435044```bash
5145nix develop
5246```
53475454-### Installation
5555-5656-1. Clone the repository:
5757-```bash
5858-cd arabica-site
5959-```
4848+### Running the Application
60496161-2. Install dependencies:
5050+1. Enter the Nix development environment:
6251```bash
6363-make install-deps
5252+nix develop
6453```
65546666-3. Build the application:
5555+2. Build and run the server:
6756```bash
6868-make build
6969-```
7070-7171-4. Run the server:
7272-```bash
7373-make run
5757+go run ./cmd/server
7458```
75597660The application will be available at `http://localhost:8080`
7777-7878-### Development
7979-8080-For hot reload during development:
8181-8282-```bash
8383-make dev
8484-```
8585-8686-This uses Air to automatically rebuild when you change Go files or templates.
8787-8888-### Building Assets
8989-9090-```bash
9191-# Generate templ files
9292-make templ
9393-9494-# Build Tailwind CSS
9595-make css
9696-9797-# Or build everything
9898-make build
9999-```
1006110162## Usage
10263···164125165126- **Go**: Fast compilation, single binary deployment, excellent stdlib
166127- **modernc.org/sqlite**: Pure Go SQLite (no CGO), easy cross-compilation
167167-- **Templ**: Type-safe templates, better than text/template for HTML
128128+- **html/template**: Built-in Go templates, no external dependencies
168129- **HTMX**: Progressive enhancement without heavy JS framework
169169-- **Nix**: Reproducible builds across environments
130130+- **Nix**: Reproducible development environment
170131171132### Database Schema
172133
-22
build.sh
···11-#!/usr/bin/env bash
22-set -e
33-44-echo "🔧 Building Arabica..."
55-66-# Generate templ files
77-echo "📝 Generating templates..."
88-templ generate
99-1010-# Build CSS
1111-echo "🎨 Building CSS..."
1212-tailwindcss -i web/static/css/style.css -o web/static/css/output.css --minify
1313-1414-# Build Go binary
1515-echo "🚀 Building Go application..."
1616-mkdir -p bin
1717-go build -o bin/arabica cmd/server/main.go
1818-1919-echo "✅ Build complete!"
2020-echo ""
2121-echo "Run './bin/arabica' to start the server"
2222-echo "Or run 'make dev' for hot reload development mode"
+5-7
flake.nix
···99 in {
1010 devShells = forAllSystems (pkgs: system: {
1111 default =
1212- pkgs.mkShell { packages = with pkgs; [ go templ tailwindcss ]; };
1212+ pkgs.mkShell { packages = with pkgs; [ go tailwindcss ]; };
1313 });
14141515 packages = forAllSystems (pkgs: system: rec {
···1919 src = ./.;
20202121 # Vendor hash for Go dependencies
2222- vendorHash = "sha256-7QYmui8+jyG/QOds0YfZfgsKqZcvm/RLQCkDFUk+xUc=";
2222+ vendorHash = "sha256-4Z6KAxox3EY9RGtFKUcqxtB/kj3Ed+o+ggPwtLSPctU=";
23232424- nativeBuildInputs = with pkgs; [ templ tailwindcss ];
2424+ nativeBuildInputs = with pkgs; [ tailwindcss ];
25252626 preBuild = ''
2727- # Generate templates before building
2828- templ generate
2929-3027 # Build Tailwind CSS
3128 tailwindcss -i web/static/css/style.css -o web/static/css/output.css --minify
3229 '';
···4239 mkdir -p $out/bin
4340 mkdir -p $out/share/arabica
44414545- # Copy static files and migrations
4242+ # Copy static files, migrations, and templates
4643 cp -r web $out/share/arabica/
4744 cp -r migrations $out/share/arabica/
4545+ cp -r internal $out/share/arabica/
48464947 # Install the actual binary
5048 cp arabica $out/bin/arabica-unwrapped
···81818282 return string(jsonBytes)
8383}
8484+8585+// intPtrEquals checks if a *int pointer equals an int value
8686+func intPtrEquals(ptr *int, val int) bool {
8787+ if ptr == nil {
8888+ return false
8989+ }
9090+ return *ptr == val
9191+}
9292+9393+// intPtrValue returns the dereferenced value of a *int, or 0 if nil
9494+func intPtrValue(ptr *int) int {
9595+ if ptr == nil {
9696+ return 0
9797+ }
9898+ return *ptr
9999+}