DyeForYarn Website
- Go 46.1%
- HTML 44.4%
- CSS 7.4%
- JavaScript 1.3%
- Dockerfile 0.7%
- Other 0.1%
| .claude | ||
| .entire | ||
| cmd | ||
| db | ||
| internal | ||
| static | ||
| templates | ||
| .air.toml | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| assets.go | ||
| Caddyfile | ||
| CLAUDE.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| sqlc.yaml | ||
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:
- Edit
db/migrations/*.sqlordb/queries/query.sql - Run
make sqlcto regenerateinternal/db/ - 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