Thank you for your interest in contributing to the LLM Proxy project! This document provides guidelines and instructions for contributing.
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone. Please be kind and considerate in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/llm-proxy.git cd llm-proxy - Add the upstream remote:
git remote add upstream https://github.com/sofatutor/llm-proxy.git
- Create a feature branch:
git checkout -b feature/your-feature-name
-
Requirements:
- Go 1.23 or higher
- Docker and Docker Compose (for containerized development)
- Git
-
Setup:
# Install dependencies go mod download # Copy environment configuration and update values as needed cp .env.example .env # Run development server make run
This project strictly follows test-driven development (TDD) principles:
- Write failing tests first - Before implementing any feature or fix
- Implement minimal code to make the tests pass
- Refactor while maintaining passing tests
Coverage Requirements:
- Minimum: 90% code coverage for all packages under
internal/ - Enforcement: CI fails if coverage drops below minimum
- New Code: Must maintain or improve overall coverage percentage
No exceptions: All code changes must be covered by tests.
- Follow Go best practices and the Effective Go guide
- Use
gofmtandgolangci-lintbefore committing - Add comprehensive comments for exported functions, types, and constants
- Each package should have a package-level comment explaining its purpose
- Follow the Code Organization Guide for architecture
Pre-commit Checks:
# Format code
make fmt
# Run linter (required - must pass)
make lint
# Run all tests with race detection
make test
# Check coverage (must be ≥ 90%)
make test-coverage- Use clear, descriptive commit messages
- Reference issue numbers when applicable:
fix: resolve rate limiting issue (#123) - Follow a modified Conventional Commits format:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions or modificationsrefactor:for code refactoringchore:for maintenance tasksstyle:for formatting, missing semicolons, etc.perf:for performance improvements
- Follow TDD Workflow: Write failing tests first, then implement (see Testing Guide)
- Run Pre-Push Checks:
make fmt # Format code make lint # Run linter (must pass) make test # Run tests with race detection make test-coverage # Verify ≥90% coverage
- Update Documentation:
- Update relevant issue docs in
docs/issues/ - Update
PLAN.mdif architecture changes - Add/update package documentation for new components
- Update relevant issue docs in
- Submit PR with:
- Clear description of changes and motivation
- Reference to related issues
- Test coverage impact analysis
- Documentation updates summary
- CI Validation: Ensure all GitHub Actions pass
- Code Review: Address all review feedback before merging
- Test-Driven Development (TDD) Required: Every PR must start with failing tests
- Coverage Enforcement: PRs must maintain or improve the 90%+ coverage target
- Focused Changes: Each PR should address a single logical component or feature
- Documentation First: Update documentation before or with implementation
- Review-Friendly Size: Keep PRs small enough for effective code review
feature/description: New features or enhancementsfix/description: Bug fixesdocs/description: Documentation updatesrefactor/description: Code refactoring without behavior changes
## Summary
Brief description of changes and motivation
## Changes
- List of specific changes made
- Reference to issue docs/checklist items
- Related PLAN.md updates
## Testing
- New tests added (TDD requirement)
- Coverage impact: X% → Y%
- Performance implications
## Documentation
- Updated issue doc: docs/issues/xxx.md
- Other documentation changes
Fixes #issue-numberDocumentation is a critical part of the project. All changes should include appropriate documentation updates:
- Architecture Guide: System design, async event system, and component interactions
- Code Organization: Package structure, layering, and dependency management
- Testing Guide: TDD workflow, coverage requirements, and testing practices
- API Configuration: Advanced proxy configuration and API provider setup
- Security Guide: Production security, secrets management, and best practices
- CLI Reference: Complete command-line interface documentation
- Instrumentation: Event system and observability setup
- Coverage Reports: Live test coverage report
- Coverage Setup: Coverage reporting and CI integration
- PLAN.md: Current project architecture and implementation roadmap
- Issues: Active task tracking and design decisions
- Working Agreement: Core development workflow rules
- Update First: Update documentation before or with code changes
- Clear Examples: Include code examples and usage patterns
- Architecture Changes: Update PLAN.md and architecture diagrams
- API Changes: Update OpenAPI specifications and CLI reference
- Keep Current: Remove outdated information and fix broken links
Comprehensive testing is mandatory. See the Testing Guide for detailed information.
- TDD Mandatory: Write failing tests before implementation
- 90% Coverage: Minimum coverage requirement for all
internal/packages - Race Detection: All tests must pass with
-raceflag - Integration Tests: Test package interactions and external integrations
- Performance Tests: Benchmark critical paths and memory usage
# Quick test run (unit tests only)
make test
# Full test suite with coverage
make test-coverage
# Integration tests
make integration-test
# View coverage report
make test-coverage-htmlCode coverage reports are automatically generated and made available in multiple ways:
Local Development:
# Generate and view HTML coverage report
make test-coverage-html
# This opens the report in your browserCI/CD Artifacts:
- HTML coverage reports are uploaded as build artifacts for each PR and push to main
- Navigate to the Actions tab → Select a workflow run → Download the "coverage-report" artifact
- Extract and open
coverage.htmlin your browser
GitHub Pages (Live):
- Coverage reports for the main branch are automatically deployed to GitHub Pages
- Access the live report at:
https://[your-org].github.io/llm-proxy/ - Updated automatically on each push to main
By contributing, you agree that your contributions will be licensed under the project's MIT License.
If you have questions about contributing, please open an issue or reach out to the maintainers.