Contributing
Thank you for your interest in contributing to BigBrotr! This guide will help you get started.
Ways to Contribute
Section titled “Ways to Contribute”- Bug Reports: Found a bug? Open an issue on GitHub
- Feature Requests: Have an idea? Start a discussion
- Code Contributions: Fix bugs or add features
- Documentation: Improve docs, fix typos, add examples
- Testing: Write tests or report test failures
Development Setup
Section titled “Development Setup”Prerequisites
Section titled “Prerequisites”- Python 3.9 or higher
- Docker and Docker Compose
- Git
Setup Steps
Section titled “Setup Steps”# Clone repositorygit clone https://github.com/bigbrotr/bigbrotr.gitcd bigbrotr
# Create virtual environmentpython3 -m venv .venvsource .venv/bin/activate # Linux/macOS# or: .venv\Scripts\activate # Windows
# Install dependenciespip install -r requirements.txt -r requirements-dev.txt
# Install pre-commit hookspre-commit install
# Verify installationpython -c "from core import Pool, Brotr, BaseService, Logger; print('OK')"Running Tests
Section titled “Running Tests”# All unit testspytest tests/unit/ -v
# With coveragepytest tests/unit/ --cov=src --cov-report=html
# Specific test filepytest tests/unit/test_synchronizer.py -v
# Pattern matchingpytest -k "health_check" -vCode Quality
Section titled “Code Quality”# Lintingruff check src/ tests/
# Formattingruff format src/ tests/
# Type checkingmypy src/
# All pre-commit hookspre-commit run --all-filesGit Workflow
Section titled “Git Workflow”Branches
Section titled “Branches”- main: Stable releases
- develop: Active development
- feature/*: New features
- fix/*: Bug fixes
- docs/*: Documentation updates
Creating a Feature Branch
Section titled “Creating a Feature Branch”# Update developgit checkout developgit pull origin develop
# Create feature branchgit checkout -b feature/my-featureCommit Messages
Section titled “Commit Messages”We use conventional commits:
feat: add API service with REST endpointsfix: handle connection timeout in poolrefactor: simplify retry logic in pooldocs: update architecture documentationtest: add monitor health check testschore: update dependenciesPull Request Process
Section titled “Pull Request Process”- Fork the repository (if external contributor)
- Create branch from
develop - Make changes and commit
- Run tests and quality checks
- Push to your fork/branch
- Create PR to
developbranch (ormainfor releases)
PR Checklist
Section titled “PR Checklist”Before submitting:
- Tests pass:
pytest tests/unit/ -v - Code quality:
pre-commit run --all-files - Documentation updated if needed
- Commit messages follow conventions
- PR description explains changes
Code Standards
Section titled “Code Standards”Type Hints
Section titled “Type Hints”All public interfaces must have type hints:
def insert_events(self, events: list[dict[str, Any]]) -> int: """Insert events to database.""" ...Docstrings
Section titled “Docstrings”Classes and public methods need docstrings:
class MyService(BaseService[MyServiceConfig]): """ My Service implementation.
Provides X, Y, Z functionality. """
async def run(self) -> None: """Execute single service cycle.""" ...Async/Await
Section titled “Async/Await”Use async/await for all I/O operations:
# Goodasync def fetch_data(self) -> list[dict]: return await self._brotr.pool.fetch("SELECT * FROM relays")
# Baddef fetch_data(self) -> list[dict]: return self._brotr.pool.fetch("SELECT * FROM relays") # Blocking!Pydantic Configuration
Section titled “Pydantic Configuration”All configuration uses Pydantic models:
from pydantic import BaseModel, Field
class MyServiceConfig(BaseModel): interval: float = Field(default=300.0, ge=60.0) some_option: str = Field(default="value")Project Structure
Section titled “Project Structure”bigbrotr/├── src/│ ├── core/ # Core layer (foundation)│ │ ├── pool.py # PostgreSQL connection pool│ │ ├── brotr.py # Database interface│ │ ├── base_service.py # Abstract service base│ │ └── logger.py # Structured logging│ ││ └── services/ # Service layer (business logic)│ ├── __main__.py # CLI entry point│ ├── initializer.py│ ├── finder.py│ ├── monitor.py│ └── synchronizer.py│├── implementations/ # Implementation layer│ ├── bigbrotr/ # Full-featured│ └── lilbrotr/ # Lightweight│├── tests/│ └── unit/ # Unit tests│└── docs/ # DocumentationAdding a New Service
Section titled “Adding a New Service”- Create service file (
src/services/myservice.py):
SERVICE_NAME = "myservice"
class MyServiceConfig(BaseModel): interval: float = Field(default=300.0, ge=60.0)
class MyService(BaseService[MyServiceConfig]): SERVICE_NAME = SERVICE_NAME CONFIG_CLASS = MyServiceConfig
async def run(self) -> None: # Service logic pass-
Add configuration (
yaml/services/myservice.yaml) -
Register service (
src/services/__main__.py):
SERVICE_REGISTRY = { "myservice": (MyService, MyServiceConfig),}- Export (
src/services/__init__.py):
from services.myservice import MyService, MyServiceConfig- Write tests (
tests/unit/test_myservice.py)
Review Process
Section titled “Review Process”- CI Checks: All automated checks must pass
- Code Review: At least one approval required
- Comments: Address all review feedback
- Squash: Commits may be squashed if requested
Getting Help
Section titled “Getting Help”- Issues: GitHub Issues
- Discussions: GitHub Discussions
Code of Conduct
Section titled “Code of Conduct”We follow the Contributor Covenant. Please be respectful and inclusive in all interactions.
License
Section titled “License”By contributing, you agree that your contributions will be licensed under the MIT License.