Contributing

PRs welcome! Here's how to get started.

Development Setup

bash
# Clone
git clone https://github.com/Vesper36/snip.git
cd snip

# Build and run
make build
make run

# Run tests
make test

# Run linter
make lint

Project Structure

tree
snip/
  cmd/server/          Entry point, route registration
  internal/
    config/            Environment-based configuration
    models/            Data structures
    store/             SQLite layer (WAL, pure-Go driver)
    auth/              JWT, bcrypt, API tokens
    i18n/              Embedded translations (EN/ZH/JA/FR/DE)
    middleware/         Rate limit, auth, i18n, security
    handlers/          HTTP handlers + embedded templates/static
      templates/       Go html/template (per-page instances)
      static/          CSS, JS, favicon, manifest
  scripts/             CLI tool + install script
  .github/             CI/CD workflows, issue/PR templates

Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes
  4. Run tests: make test
  5. Run linter: make lint
  6. Commit with a descriptive message
  7. Push and create a Pull Request

Commit Convention

format
type(scope): description

# Examples:
feat(api): add paste pagination
fix(auth): prevent token timing attack
docs(readme): update deployment guide
test(store): add CRUD operation tests

Types: feat, fix, docs, test, refactor, perf, chore

Code Style

Adding a New Language

  1. Create internal/i18n/XX.json with translations
  2. Update the //go:embed directive in i18n.go
  3. Add the language code to the supported slice
  4. Add the language label to the Labels map
  5. Add lang_XX keys to all existing translation files
  6. Run tests: go test ./internal/i18n/...

Testing

bash
# Run all tests
make test

# Run with coverage
make cover

# Run benchmarks
make bench

# Run specific package tests
go test ./internal/store/... -v

Architecture

Snip follows a layered architecture:

diagram
HTTP Request
    -> Middleware (auth, rate limit, CORS)
    -> Handler (parse request, format response)
    -> Service (business logic, validation)
    -> Store (database queries)
    -> SQLite

Pull Request Guidelines

Tip: Check the GitHub Issues for good first issues and feature requests.