Contributing Guide
Thank you for your interest in contributing to the Posthoot backend! This guide will help you get started with the development process.Table of Contents
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Development Workflow
- Coding Standards
- Testing
- Documentation
- Submitting Changes
- Release Process
Code of Conduct
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.Getting Started
Prerequisites
- Go 1.21+ - Download here
- PostgreSQL 14+ - Download here
- Redis 6+ - Download here
- Git - Download here
- Docker (optional) - Download here
Fork and Clone
- Fork the repository on GitHub
- Clone your fork locally:
- Add the upstream remote:
Development Setup
1. Environment Configuration
Create a development environment file:.env.dev with your development settings:
2. Database Setup
Create a development database:3. Install Dependencies
4. Run the Application
5. Using Docker for Development
Create adocker-compose.dev.yml file:
Project Structure
Development Workflow
1. Branch Strategy
We use a feature branch workflow:2. Making Changes
- Create a feature branch from
main - Make your changes following the coding standards
- Write tests for new functionality
- Update documentation as needed
- Commit your changes with clear messages
3. Commit Message Format
Use conventional commit format:4. Keeping Your Branch Updated
Coding Standards
1. Go Code Style
Follow the Go Code Review Comments:- Use
gofmtfor code formatting - Follow naming conventions
- Use meaningful variable names
- Keep functions small and focused
- Add comments for exported functions
2. Code Organization
- Package structure: Follow standard Go package layout
- File naming: Use descriptive names (e.g.,
user_handler.go) - Function organization: Group related functions together
- Import organization: Use standard library, third-party, then local imports
3. Error Handling
4. Database Operations
5. API Design
Testing
1. Unit Tests
Create tests for all new functionality:2. Integration Tests
Test API endpoints with a real database:3. Running Tests
4. Test Database
Use a separate test database:Documentation
1. Code Documentation
Document all exported functions and types:2. API Documentation
Update Swagger documentation for new endpoints:3. README Updates
Update relevant documentation when adding new features:- README.md: Update feature list and installation instructions
- API Documentation: Add new endpoint documentation
- Self-hosting guide: Update configuration options
Submitting Changes
1. Pre-submission Checklist
Before submitting a pull request, ensure:- Code compiles without errors
- Tests pass (unit and integration)
- Code is formatted (
gofmt -w .) - Linting passes (
golangci-lint run) - Documentation is updated
- Commit messages follow conventional format
- Branch is up to date with main
2. Creating a Pull Request
- Push your branch to your fork:
-
Create a pull request on GitHub with:
- Clear title describing the change
- Detailed description of what was changed
- Reference to any related issues
- Screenshots (if UI changes)
- Template for PR description:
3. Code Review Process
- Automated checks will run on your PR
- Reviewers will be assigned automatically
- Address feedback by pushing additional commits
- Maintainers will merge when approved
Release Process
1. Version Management
We use semantic versioning (SemVer):- MAJOR.MINOR.PATCH (e.g., 1.2.3)
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
2. Release Checklist
Before a release:- All tests pass
- Documentation is updated
- Changelog is updated
- Version is bumped
- Release notes are prepared
3. Creating a Release
- Create a release branch:
- Update version in relevant files
- Update changelog with new features/fixes
- Create a PR for the release
- Tag the release after merge:
Getting Help
1. Questions and Discussions
- GitHub Discussions: For general questions and feature discussions
- GitHub Issues: For bug reports and feature requests
- Discord: For real-time discussions (if available)
2. Issue Templates
Use the appropriate issue template:- Bug Report: For reporting bugs
- Feature Request: For suggesting new features
- Documentation: For documentation improvements
3. Community Guidelines
- Be respectful and inclusive
- Provide context when asking questions
- Help others when you can
- Follow the code of conduct
Recognition
Contributors are recognized in several ways:- Contributors list on GitHub
- Release notes for significant contributions
- Special thanks in documentation
- Contributor badges for regular contributors