Skip to content

Contributing

Thank you for your interest in contributing to mjr.wtf! This guide will help you get started.

Releases are automated:

  • Release Please opens/updates a Release PR based on conventional commits.
  • Merging that PR creates a semver tag (format: mjrwtf-vX.Y.Z) and publishes a GitHub Release.
  • The published release triggers GoReleaser to upload server + migrate binaries (and checksums), and also triggers the existing Docker publish workflow.

To keep versioning predictable, prefer conventional commits (e.g. feat: ..., fix: ...). Use feat!: ... or a BREAKING CHANGE: footer for breaking changes.

Terminal window
git clone <your-fork-url>
cd mjrwtf
Terminal window
# Install sqlc (for database code generation, requires v1.30.0+)
go install github.com/sqlc-dev/sqlc/cmd/[email protected]
# Install templ (for template code generation)
go install github.com/a-h/templ/cmd/templ@latest
Terminal window
# Copy environment configuration
cp .env.example .env
# Run tests to verify setup (this will automatically run code generation)
make test

Note: The make test, make build, and make check targets automatically run code generation, so you don’t need to run sqlc generate or templ generate manually in most cases.

Alternative: You can also use go generate ./... to run code generation directly.

Terminal window
git checkout -b feature/your-feature-name
# or
git checkout -b fix/bug-description

Follow these guidelines when making changes:

  • Hexagonal Architecture: Keep domain logic in internal/domain/, implementations in internal/adapters/
  • After modifying SQL queries: Run make generate or just sqlc generate
  • After modifying templates: Run make generate or just templ generate
  • Before committing: Run make check (automatically runs code generation, formatting, linting, and tests)
  • Write tests: All new features and bug fixes require tests

Use conventional commit format:

feat: add URL expiration feature
fix: correct click count calculation
docs: update API documentation
test: add tests for URL validation
refactor: simplify repository error handling
  • Fill out the PR template completely
  • Reference related issues (e.g., “Closes #123”)
  • Ensure all tests pass
  • Request review from maintainers
  • All new features must have unit tests
  • All bug fixes must have regression tests
  • Aim for >80% test coverage
  • Test both happy path and error cases
  • Repository tests must cover SQLite behavior
  • Run make lint before committing
  • Fix all linter warnings (except known false positives)
  • Known false positive: “undefined: sqliterepo” - ignore if tests pass
  • Update README.md for user-facing changes
  • Update inline comments for complex logic
  • Add GoDoc comments for exported functions
  • Update schema/migration docs in docs-site/ for database changes (see docs-site/src/content/docs/operations/)

Use conventional commits format:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation only
  • test: - Adding or updating tests
  • refactor: - Code change that neither fixes a bug nor adds a feature
  • chore: - Maintenance tasks

This project is optimized for GitHub Copilot coding agent assistance.

When creating issues for Copilot to work on:

  1. Use issue templates (.github/ISSUE_TEMPLATE/)
  2. Provide clear acceptance criteria using Given-When-Then format
  3. List files that need modification
  4. Specify test requirements
  5. Note any security implications

Excellent for:

  • Implementing new domain entities with validation
  • Adding new repository methods with tests
  • Creating database migrations (SQLite)
  • Writing sqlc queries
  • Adding test cases to existing test suites
  • Fixing bugs with clear reproduction steps
  • Updating documentation

⚠️ Needs Human Guidance:

  • Complex architectural changes spanning multiple layers
  • Performance optimization requiring profiling
  • Security-critical code (always requires human review)
  • Major refactoring (break into smaller issues)
  • Production deployment decisions

Even when Copilot generates the PR, always review:

  • Security implications of changes
  • Performance impact of database queries
  • Breaking changes to public APIs
  • Migration safety (both up and down)
  • Test coverage adequacy
  • Documentation completeness

Domain Layer (internal/domain/):

  • Pure business logic, no external dependencies
  • Define entities with validation
  • Define repository interfaces (ports)
  • Never import database, HTTP, or infrastructure packages

Adapter Layer (internal/adapters/):

  • Implement repository interfaces
  • Use sqlc-generated code for database access
  • Map between domain entities and database models
  • Handle database-specific error mapping

Infrastructure Layer (internal/infrastructure/):

  • Configuration management
  • Logging setup
  • Database connection management
  • Application initialization
Terminal window
make generate # Regenerate database and template code (or just `sqlc generate` / `templ generate`)
go build ./... # Verify compilation
make test # Run all tests (automatically runs generation too)

Note: If you’re running make test or make build, code generation is automatic.

Terminal window
make build-migrate # Rebuild migrate tool (migrations are embedded, automatically runs generation)
make migrate-up # Apply migration
make migrate-status # Verify migration applied
make migrate-down # Test rollback
make migrate-up # Re-apply for final state
Terminal window
make check # Run generate, fmt, vet, lint, test, and validate-openapi

Note: make check automatically runs code generation, so you don’t need to run it separately.

Dependencies flow inward toward the domain:

Infrastructure → Adapters → Domain
↓ ↓ ↑
Config Repositories Entities
Logging (impl) Interfaces
Database Validation

Rules:

  • Domain NEVER imports from adapters or infrastructure
  • Adapters import domain interfaces
  • Infrastructure wires everything together
  • Read first: .github/copilot-instructions.md has comprehensive project documentation
  • Check existing issues: Someone may have already asked
  • Check existing PRs: See how similar changes were implemented
  • Ask in discussions: For questions before opening issues
  • Tag maintainers: For urgent issues or clarifications

Please read and follow CODE_OF_CONDUCT.md.

Quick expectations:

  • Be respectful and inclusive
  • Focus on constructive feedback
  • Help others learn and grow
  • Assume good intentions

By contributing, you agree that your contributions will be licensed under the same license as the project.


Thank you for contributing to mjr.wtf! 🎉