Thank you for your interest in contributing to Ratelink! This guide will help you get started.
Be respectful, inclusive, and constructive. We're here to build great software together.
- Check existing issues first
- Use the bug report template
- Include:
- Python version
- Ratelink version
- Minimal reproducible example
- Expected vs actual behavior
- Relevant logs/tracebacks
- Check discussions first
- Open an issue with
[Feature Request]prefix - Describe:
- Use case and motivation
- Proposed API/behavior
- Alternatives considered
- Willingness to implement
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add/update tests
- Update documentation
- Run quality checks (see below)
- Commit with clear messages
- Push and create a PR
- Python 3.7+
- Git
- (Optional) Docker for Redis/PostgreSQL
# Clone your fork
git clone https://github.com/YOUR-USERNAME/ratelink.git
cd ratelink
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with all dependencies
pip install -e ".[dev,all]"
# Install pre-commit hooks (optional but recommended)
pre-commit installratelink/
├── ratelink/ # Source code
│ ├── algorithms/ # Rate limiting algorithms
│ ├── backends/ # Storage backends
│ ├── core/ # Core RateLimiter class
│ ├── advanced/ # Advanced features
│ ├── observability/ # Metrics, logging, tracing
│ ├── integration/ # Framework integrations
│ ├── utils/ # Key generators, decorators
│ └── testing/ # Testing utilities
│
├── tests/ # Test suites
│ ├── algorithms/
│ ├── backends/
│ ├── core/
│ ├── advanced/
│ ├── observability/
│ ├── integration/
│ └── testing/
│
├── docs/ # Documentation
├── examples/ # Example applications
├── benchmarks/ # Performance benchmarks
└── pyproject.toml # Project configuration
# Run all tests
pytest
# Run specific test file
pytest tests/algorithms/test_token_bucket.py
# Run with coverage
pytest --cov=ratelink --cov-report=html
# Run specific markers
pytest -m "not slow" # Skip slow tests
pytest -m integration # Only integration tests
pytest -m redis_required # Tests requiring RedisWe use several tools to maintain code quality:
# Format code with black
black ratelink tests
# Check formatting
black --check ratelink tests
# Lint with flake8
flake8 ratelink tests
# Type check with mypy
mypy ratelink
# Security check with bandit
bandit -r ratelink
# Run all checks
./scripts/quality-check.sh # If available- Black: Line length 100, Python 3.7+ target
- Type hints: Required for all public APIs
- Docstrings: Google style for all public functions/classes
- Imports: Organized with isort (black compatible)
- Coverage: Aim for >90% coverage on new code
- Test Types:
- Unit tests for algorithms and backends
- Integration tests for framework integrations
- Functional tests for end-to-end scenarios
- Markers: Use appropriate pytest markers
@pytest.mark.slow @pytest.mark.integration @pytest.mark.redis_required
- Fixtures: Use provided fixtures from
ratelink.testing.fixtures - Assertions: Use helper assertions from
ratelink.testing.assertions
Documentation is as important as code:
-
Docstrings: All public APIs must have docstrings
def check(self, key: str, weight: int = 1) -> Tuple[bool, Dict[str, Any]]: """ Check if a request should be allowed. Args: key: Rate limit key (e.g., "user:123") weight: Request weight (default: 1) Returns: Tuple of (allowed, state) where: - allowed: True if request allowed, False otherwise - state: Dict with remaining, limit, retry_after, etc. Example: >>> limiter = RateLimiter(algorithm="token_bucket", limit=100, window=60) >>> allowed, state = limiter.check("user:123") >>> if allowed: ... process_request() """
-
Markdown Docs: Update relevant docs in
docs/ -
Examples: Add runnable examples for new features
-
Changelog: Add entry to
CHANGELOG.md
Use clear, descriptive commit messages:
feat: Add support for custom key extractors
fix: Correct token bucket refill calculation
docs: Update FastAPI integration guide
test: Add tests for sliding window algorithm
refactor: Simplify Redis backend connection handling
Prefixes:
feat: New featurefix: Bug fixdocs: Documentationtest: Testsrefactor: Code refactoringperf: Performance improvementchore: Maintenance tasks
- Title: Clear, descriptive (
feat: Add MongoDB backend) - Description:
- What and why
- Link to related issues
- Breaking changes (if any)
- Checklist:
- Tests added/updated
- Documentation updated
- Changelog updated
- All checks passing
- Review: Address feedback constructively
- Merge: Squash and merge (we'll handle this)
- Be open to feedback
- Respond to comments
- Ask questions if unclear
- Keep PRs focused and reasonably sized
- Be constructive and specific
- Explain the "why" not just "what"
- Approve when ready, request changes when needed
- Respond promptly
# Start Redis with Docker
docker run -d -p 6379:6379 redis
# Run Redis tests
pytest -m redis_required# Start PostgreSQL with Docker
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres
# Run PostgreSQL tests
pytest -m postgres_required# Use docker-compose (if available)
docker-compose up -d
# Run all integration tests
pytest -m integration- Update version in
pyproject.toml - Update
CHANGELOG.md - Run full test suite
- Build:
python -m build - Test on TestPyPI
- Publish to PyPI:
twine upload dist/* - Tag release:
git tag v1.0.0 - Create GitHub release
- General Questions: GitHub Discussions
- Bug Reports: GitHub Issues
- Security Issues: Email vladlen.codes@gmail.com (do not open public issues)
Contributors are listed in:
- GitHub contributors page
- Release notes
- Documentation acknowledgments
Thank you for contributing to Ratelink! 🎉