DyeForYarn Website
  • Go 46.1%
  • HTML 44.4%
  • CSS 7.4%
  • JavaScript 1.3%
  • Dockerfile 0.7%
  • Other 0.1%
Find a file
2026-03-08 19:53:52 +01:00
.claude Import old PHP app and modernize webpage 2026-03-08 11:48:00 +01:00
.entire Import old PHP app and modernize webpage 2026-03-08 11:48:00 +01:00
cmd Embed static assets. Persist tax rates. 2026-03-08 19:53:43 +01:00
db Embed static assets. Persist tax rates. 2026-03-08 19:53:43 +01:00
internal Embed static assets. Persist tax rates. 2026-03-08 19:53:43 +01:00
static Place tinted area behind intro header text 2026-03-08 16:39:51 +01:00
templates Merge branch 'main' of ssh://git.moebiusband.org:222/jan/dfy-web 2026-03-08 19:53:52 +01:00
.air.toml Import go skeleton 2026-03-08 08:25:32 +01:00
.dockerignore Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
.env.example Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
.gitignore Import go skeleton 2026-03-08 08:25:32 +01:00
assets.go Embed static assets. Persist tax rates. 2026-03-08 19:53:43 +01:00
Caddyfile Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
CLAUDE.md Import old PHP app and modernize webpage 2026-03-08 11:48:00 +01:00
docker-compose.yml Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
Dockerfile Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
go.mod Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
go.sum Add docker build and caddy setup 2026-03-08 14:05:55 +01:00
LICENSE Initial commit 2026-03-08 07:51:31 +01:00
Makefile Import go skeleton 2026-03-08 08:25:32 +01:00
README.md Add README 2026-03-08 14:12:12 +01:00
sqlc.yaml Import go skeleton 2026-03-08 08:25:32 +01:00

DyeForYarn

Go web application for the DyeForYarn shop — chi router, SQLite, server-side HTML templates.

Prerequisites

  • Go 1.25+
  • air for hot-reload (go install github.com/air-verse/air@latest)
  • sqlc for code generation (go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest)
  • Docker + Docker Compose (for production deployment)

Local Development

1. Configure environment

cp .env.example .env
# Edit .env — at minimum set SESSION_SECRET to a random 32+ byte string

2. Seed the admin user

go run cmd/seed/main.go -username admin -password YOUR_PASSWORD

3. Start the dev server

make dev   # hot-reloads on .go and .html changes

The app listens on http://localhost:8080 by default.

Available make targets

Command Description
make dev Hot-reload dev server via air
make build Compile to ./tmp/main
make run Build then run
make sqlc Regenerate internal/db/ from SQL sources
make clean Remove tmp/ and data.db

Static Analysis

No test suite exists yet. Run Go's built-in vet:

go vet ./...

Database

Migrations in db/migrations/ run automatically at startup in filename order.

To modify the schema or queries:

  1. Edit db/migrations/*.sql or db/queries/query.sql
  2. Run make sqlc to regenerate internal/db/
  3. Commit both the SQL files and the regenerated Go files together

Environment Variables

Variable Default Description
PORT 8080 HTTP listen port
DATABASE_URL /app/data/data.db SQLite file path
SESSION_SECRET Random string, min 32 bytes (required)
TLS_ENABLED false Enable built-in TLS
TLS_CERT_FILE Path to TLS certificate (if TLS enabled)
TLS_KEY_FILE Path to TLS private key (if TLS enabled)
GMAIL_CLIENT_ID Google Cloud OAuth2 client ID
GMAIL_CLIENT_SECRET Google Cloud OAuth2 client secret
GMAIL_LABEL Orders Gmail label to fetch orders from
ETSY_API_KEY Etsy Open API v3 key

Production Deployment

Deployment uses Docker Compose with Caddy as a reverse proxy handling automatic HTTPS.

1. Configure the domain

Edit Caddyfile and replace the placeholder hostname with your actual domain:

yourdomain.com {
    reverse_proxy app:8080
    ...
}

2. Configure environment

cp .env.example .env
# Set DATABASE_URL, SESSION_SECRET, GMAIL_*, ETSY_API_KEY

3. Build and start

docker compose up -d --build

Caddy will automatically obtain and renew a Let's Encrypt certificate for your domain.

4. Seed the admin user (first deploy only)

docker compose exec app ./seed -username admin -password YOUR_PASSWORD

Subsequent deploys

docker compose up -d --build

The SQLite database persists in the sqlite-data named volume across rebuilds.

Logs

docker compose logs -f app    # application logs
docker compose logs -f caddy  # Caddy/HTTPS logs