Contributing
Thank you for your interest in contributing to PrepArr. This guide covers development setup and contribution guidelines.
Prerequisites
Section titled “Prerequisites”- Bun (latest version)
- Docker and Docker Compose
- PostgreSQL (for local development)
Development Setup
Section titled “Development Setup”# Clone the repositorygit clone https://github.com/robbeverhelst/Preparr.gitcd Preparr
# Install dependenciesbun install
# Run testsbun test
# Run in development mode with watchbun run dev
# Build for productionbun run buildTesting
Section titled “Testing”Unit Tests
Section titled “Unit Tests”# Run all testsbun test
# Run tests in watch modebun test --watch
# Run specific test filebun test src/config/index.test.tsIntegration Tests
Section titled “Integration Tests”# Start test environmentbun run docker:up
# Run integration testsbun run test:integration
# Clean upbun run docker:resetArchitecture Overview
Section titled “Architecture Overview”PrepArr uses a three-container pattern for each Servarr application:
- Init Container (
--initflag) - Sets up databases and config.xml, then exits - Sidecar Container (default mode) - Continuously applies JSON configuration
- Servarr App - Standard Linuxserver container using prepared config
Key Components
Section titled “Key Components”- Configuration Loading (
src/config/) - Zod schemas and multi-source config loading - Database Management (
src/postgres/) - PostgreSQL initialization and user management - Servarr Integration (
src/servarr/) - API interactions via Tsarr client - Step System (
src/steps/) - Modular configuration steps with reconciliation - Health Monitoring (
src/core/health.ts) - Health check endpoints for orchestrators
Code Style
Section titled “Code Style”Formatting and Linting
Section titled “Formatting and Linting”# Check code stylebun run lint
# Fix auto-fixable issuesbun run lint:fix
# Format codebun run format
# Type checkingbun run typecheckGuidelines
Section titled “Guidelines”- Use TypeScript for all code
- Validate inputs with Zod schemas
- Leverage Bun’s native APIs (
Bun.file(),Bun.spawn(), etc.) - Use async/await for all I/O operations
- Follow existing patterns for error handling
- Write tests for new functionality
- Use structured logging with context
Commit Messages
Section titled “Commit Messages”Follow Conventional Commits:
type(scope): description
[optional body]
[optional footer(s)]Types: feat, fix, docs, style, refactor, test, chore
Examples:
feat(config): add prowlarrSync flag for indexer managementfix(postgres): handle connection timeout gracefullydocs(readme): update configuration examples
Development Workflow
Section titled “Development Workflow”Adding New Features
Section titled “Adding New Features”- Create a feature branch:
git checkout -b feat/your-feature - Write tests first (TDD approach preferred)
- Implement the feature following existing patterns
- Update documentation as needed
- Ensure all tests pass and code is formatted
- Submit a pull request with a clear description
Bug Fixes
Section titled “Bug Fixes”- Create an issue describing the bug
- Create a bugfix branch:
git checkout -b fix/issue-number - Add a test that reproduces the issue
- Fix the issue while keeping the test passing
- Submit a pull request referencing the issue
Configuration Changes
Section titled “Configuration Changes”- Update Zod schemas in
src/config/schema.ts - Add validation tests in
src/config/*.test.ts - Update example configs in
examples/ - Update documentation with new options
Docker Development
Section titled “Docker Development”Building Images
Section titled “Building Images”# Build the imagedocker build -t preparr:dev .
# Run development stackbun run docker:upTesting Changes
Section titled “Testing Changes”# Reset environment and test changesbun run docker:reset && bun run docker:up
# Check logsdocker logs preparr-sonarr-sidecar-1
# Inspect running containersdocker psPull Request Guidelines
Section titled “Pull Request Guidelines”Before Submitting
Section titled “Before Submitting”- All tests pass (
bun test) - Code is properly formatted (
bun run format) - TypeScript compiles without errors (
bun run typecheck) - Integration tests pass with Docker stack
- Documentation updated if needed
- Commit messages follow conventional format
PR Description Template
Section titled “PR Description Template”## DescriptionBrief description of changes
## Type of Change- [ ] Bug fix (non-breaking change fixing an issue)- [ ] New feature (non-breaking change adding functionality)- [ ] Breaking change (fix or feature causing existing functionality to break)- [ ] Documentation update
## Testing- [ ] Unit tests added/updated- [ ] Integration tests pass- [ ] Manual testing completed
## Checklist- [ ] Code follows project style guidelines- [ ] Self-review completed- [ ] Documentation updated- [ ] No breaking changes (or clearly documented)Areas for Contribution
Section titled “Areas for Contribution”High Priority
Section titled “High Priority”- Additional Servarr support (Lidarr, Readarr implementation)
- Enhanced error handling and retry logic
- Kubernetes examples and Helm chart improvements
- Monitoring integration (Prometheus metrics)
Medium Priority
Section titled “Medium Priority”- More comprehensive Zod schemas for configuration validation
- Additional integration test scenarios
- Performance optimization (startup time, memory usage)
- Documentation improvements
Good First Issues
Section titled “Good First Issues”- More example configurations for different use cases
- Improved error message clarity
- Additional structured logging context
License
Section titled “License”By contributing to PrepArr, you agree that your contributions will be licensed under the MIT License.