Skip to main content

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

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.

Getting Started

Prerequisites

Fork and Clone

  1. Fork the repository on GitHub
  2. Clone your fork locally:
  1. Add the upstream remote:

Development Setup

1. Environment Configuration

Create a development environment file:
Edit .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 a docker-compose.dev.yml file:
Run the development environment:

Project Structure

Development Workflow

1. Branch Strategy

We use a feature branch workflow:

2. Making Changes

  1. Create a feature branch from main
  2. Make your changes following the coding standards
  3. Write tests for new functionality
  4. Update documentation as needed
  5. Commit your changes with clear messages

3. Commit Message Format

Use conventional commit format:
Examples:

4. Keeping Your Branch Updated

Coding Standards

1. Go Code Style

Follow the Go Code Review Comments:
  • Use gofmt for 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

  1. Push your branch to your fork:
  1. 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)
  2. Template for PR description:

3. Code Review Process

  1. Automated checks will run on your PR
  2. Reviewers will be assigned automatically
  3. Address feedback by pushing additional commits
  4. 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

  1. Create a release branch:
  1. Update version in relevant files
  2. Update changelog with new features/fixes
  3. Create a PR for the release
  4. 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
Thank you for contributing to the Posthoot backend project! Your contributions help make this project better for everyone.