Contributing Guide¶
Thank you for considering contributing to the NSGG Backend project! This guide will help you understand our development process and standards.
Getting Started¶
- Fork the repository
- Clone your fork:
- Create a new branch:
- Set up your development environment following our Getting Started Guide
Development Process¶
1. Install Dependencies¶
2. Make Your Changes¶
- Write clean, maintainable code
- Follow our coding standards
- Include tests for new features
- Update documentation as needed
3. Commit Your Changes¶
Follow our commit message conventions:
Types:
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes (formatting, etc.)
- refactor: Code refactoring
- test: Test changes
- chore: Maintenance tasks
Example:
feat(products): add bulk creation endpoint
- Add bulk creation endpoint for products
- Implement validation for bulk requests
- Add tests for bulk creation
Closes #123
4. Push Your Changes¶
5. Create a Pull Request¶
- Use our pull request template
- Link related issues
- Provide a clear description of changes
- Include any necessary documentation
- Ensure all tests pass
Code Standards¶
Python Style Guide¶
We follow PEP 8 with some modifications:
- Line length: 100 characters
- Use double quotes for strings
- Use trailing commas in multi-line statements
Django Best Practices¶
-
Models:
class Product(models.Model): name = models.CharField(max_length=255) price = models.DecimalField(max_digits=10, decimal_places=2) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: ordering = ["-created_at"] def __str__(self): return self.name -
Views:
-
Serializers:
Testing Standards¶
-
Test file organization:
-
Test naming:
Documentation¶
Docstrings¶
Use Google-style docstrings:
def calculate_total(items: List[OrderItem]) -> Decimal:
"""Calculate the total price for a list of order items.
Args:
items: List of OrderItem objects.
Returns:
Decimal: The total price of all items.
Raises:
ValueError: If any item has an invalid price.
"""
API Documentation¶
Document API endpoints using drf-spectacular:
@extend_schema(
description="Create a new product",
request=ProductSerializer,
responses={201: ProductSerializer},
)
def create(self, request, *args, **kwargs):
return super().create(request, *args, **kwargs)
Review Process¶
Pull Request Reviews¶
- Code quality
- Follows style guide
- No duplicate code
-
Proper error handling
-
Functionality
- Implements requirements
- Handles edge cases
-
Includes error scenarios
-
Testing
- Adequate test coverage
- Tests pass
-
Tests are meaningful
-
Documentation
- Updated as needed
- Clear and accurate
- Includes examples
Review Comments¶
- Be constructive and respectful
- Explain the reasoning
- Provide examples when helpful
Release Process¶
- Version Bump
- Update version in
__init__.py -
Update CHANGELOG.md
-
Create Release Branch
-
Create Release PR
- Include version changes
-
Include CHANGELOG updates
-
After Merge
- Tag the release
- Deploy to staging
- Deploy to production
Getting Help¶
- Join our Slack channel
- Check existing issues
- Ask questions in discussions
- Contact maintainers