Thank you for your interest in contributing to GESIS Surf Backend! This document outlines our development workflow, branching strategy, and commit conventions.
- Development Workflow
- Branching Strategy
- Commit Conventions
- Pull Request Process
- Code Quality
- Getting Started
We follow a Git Flow inspired workflow with continuous integration:
┌─────────────────────────────────────────────────────────────────────┐
│ PRODUCTION │
│ prod │
│ ▲ │
│ │ (admin merge only) │
│ │ │
│ ───────────────────────────┼─────────────────────────────────────── │
│ STAGING │
│ main │
│ ▲ │
│ │ (merge/release) │
│ │ │
│ ───────────────────────────┼─────────────────────────────────────── │
│ DEVELOPMENT │
│ dev │
│ ▲ ▲ ▲ │
│ / │ \ │
│ / │ \ │
│ ─────────────────────/─────┼─────\───────────────────────────────── │
│ FEATURE BRANCHES │
│ │
│ feature/ bugfix/ hotfix/ refactor/ │
│ add-auth fix-login critical cleanup-models │
└─────────────────────────────────────────────────────────────────────┘
| Branch | Purpose | Deployed To | Merge Access |
|---|---|---|---|
prod |
Production-ready code | Production server | Admin only |
main |
Staging/Testing | Staging server | Maintainers |
dev |
Development integration | Development server | Contributors |
feature/* |
New features | Local/PR preview | - |
bugfix/* |
Non-critical bug fixes | Local/PR preview | - |
hotfix/* |
Critical production fixes | Direct to prod | Admin only |
refactor/* |
Code improvements | Local/PR preview | - |
# Start from dev branch
git checkout dev
git pull origin dev
# Create your feature branch
git checkout -b feature/your-feature-nameUse the following prefixes:
| Prefix | Use Case | Example |
|---|---|---|
feature/ |
New functionality | feature/add-user-analytics |
bugfix/ |
Bug fixes | bugfix/fix-scroll-tracking |
hotfix/ |
Urgent production fixes | hotfix/security-patch |
refactor/ |
Code refactoring | refactor/optimize-queries |
docs/ |
Documentation updates | docs/update-api-guide |
test/ |
Test additions | test/add-click-tests |
- Create branch from
dev - Develop your feature with atomic commits
- Push your branch to remote
- Create PR targeting
dev - Code Review by team members
- Merge after approval
- Delete feature branch after merge
feature/* ──▶ dev ──▶ main (staging) ──▶ prod (production)
│ │ │
│ │ └── Admin merge only
│ └── Maintainer merge
└── Contributor merge after review
We use Commitizen with Conventional Commits specification.
<type>(<scope>): <subject>
[optional body]
[optional footer(s)]
| Type | Description | Example |
|---|---|---|
feat |
New feature | feat(auth): add token refresh endpoint |
fix |
Bug fix | fix(clicks): resolve duplicate tracking issue |
docs |
Documentation | docs(readme): update installation steps |
style |
Code style (formatting) | style(models): apply black formatting |
refactor |
Code refactoring | refactor(views): simplify query logic |
perf |
Performance improvement | perf(elasticsearch): optimize bulk indexing |
test |
Adding/updating tests | test(domain): add serializer tests |
build |
Build system changes | build(docker): update base image |
ci |
CI/CD changes | ci(github): add test workflow |
chore |
Maintenance tasks | chore(deps): update dependencies |
# Install commitizen (included in dev dependencies)
poetry install
# Make your changes, then stage them
git add .
# Use commitizen to create a commit
cz commit
# or
poetry run cz commitCommitizen will guide you through creating a properly formatted commit:
? Select the type of change you are committing: feat
? What is the scope of this change? (press enter to skip) auth
? Write a short description: add JWT token refresh endpoint
? Provide additional contextual information: (press enter to skip)
? Is this a BREAKING CHANGE? No
We use pre-commit to ensure code quality before commits:
# Install pre-commit hooks
pre-commit install
# Run manually on all files
pre-commit run --all-files- ✅ Ensure all tests pass:
pytest - ✅ Run linters:
flake8 app/ - ✅ Format code:
black app/ - ✅ Check types:
mypy app/ - ✅ Update documentation if needed
Follow the same format as commits:
feat(scope): description
fix(scope): description
When creating a PR, include:
- Description: What does this PR do?
- Related Issue: Link to issue if applicable
- Type of Change: Feature / Bug fix / Refactor / etc.
- Testing: How was this tested?
- Checklist:
- Tests added/updated
- Documentation updated
- No breaking changes (or documented)
- Feature → Dev: Squash and merge
- Dev → Main: Merge commit (preserves history)
- Main → Prod: Merge commit (admin only)
- Hotfix → Prod: Merge commit (admin only)
We use pre-commit hooks to ensure consistent code quality before every commit and push.
Our .pre-commit-config.yaml includes the following hooks:
| Hook | Purpose |
|---|---|
| check-added-large-files | Prevents large files from being committed |
| check-merge-conflict | Detects unresolved merge conflicts |
| check-toml | Validates TOML file syntax |
| check-yaml | Validates YAML file syntax |
| trailing-whitespace | Removes trailing whitespace |
| end-of-file-fixer | Ensures files end with a newline |
| black | Python code formatting (PEP 8) |
| isort | Sorts and organizes imports |
| autoflake | Removes unused imports |
| flake8 | Linting with plugins (bugbear, bandit, docstrings, etc.) |
| mypy | Static type checking |
| pylint | Code analysis with Django plugin |
| pyupgrade | Upgrades syntax to Python 3.10+ |
| prettier | Formats JS, CSS, Markdown, JSON, YAML |
| eslint | JavaScript linting |
| django-upgrade | Upgrades Django code to 4.2+ syntax |
| djhtml | Formats Django HTML templates |
| curlylint | Lints HTML/Jinja templates |
| blacken-docs | Formats Python code in documentation |
| commitizen | Validates commit message format |
| Hook | Purpose |
|---|---|
| commitizen-branch | Validates branch commit history |
# Install pre-commit (included in dev dependencies)
poetry install
# Install the git hooks
poetry run pre-commit install
poetry run pre-commit install --hook-type pre-push
# Run all hooks on all files (first time or manual check)
poetry run pre-commit run --all-filesOur Flake8 configuration includes these plugins for comprehensive linting:
flake8-bugbear- Finds likely bugs and design problemsflake8-bandit- Security issue detectionflake8-docstrings- Docstring style checkingflake8-comprehensions- Better list/dict/set comprehensionsflake8-annotations- Type annotation checkingflake8-django- Django-specific checksflake8-quotes- Quote consistencypep8-naming- PEP 8 naming conventions
All tools are configured in pyproject.toml and .pre-commit-config.yaml:
| Tool | Purpose | Command |
|---|---|---|
| Black | Code formatting | black app/ |
| isort | Import sorting | isort app/ |
| Flake8 | Linting | flake8 app/ |
| MyPy | Type checking | mypy app/ |
| Pylint | Code analysis | pylint app/ |
| Pytest | Testing | pytest |
# Run all pre-commit hooks
poetry run pre-commit run --all-files
# Or run individual tools
black app/ && isort app/ # Format code
flake8 app/ # Lint
mypy app/ # Type check
pytest # Run testsgit clone https://github.com/YOUR_USERNAME/gesis_surf_backend.git
cd gesis_surf_backend# Install dependencies with Poetry
poetry install
# Install pre-commit hooks
poetry run pre-commit install
# Set up commitizen
poetry run cz init # if not already configuredgit checkout dev
git pull origin dev
git checkout -b feature/your-feature-name# Stage your changes
git add .
# Commit using commitizen
poetry run cz commit
# Push your branch
git push origin feature/your-feature-name- Go to GitHub repository
- Click "Compare & pull request"
- Select
devas base branch - Fill in the PR template
- Request review from team members
We use Commitizen for semantic versioning:
# Bump version based on commits (auto-detects type)
cz bump
# Bump specific version
cz bump --increment MINOR
# Dry run to see what would happen
cz bump --dry-rundev ──────────────────────────────▶ main ──────────────────────────────▶ prod
│ │ │
│ 1. Merge feature PRs │ 1. Review staging tests │
│ 2. Run integration tests │ 2. Version bump (cz bump) │
│ 3. Fix any issues │ 3. Update CHANGELOG │
│ │ 4. Create release PR │
│ │ 5. Admin merge to prod │
│ │ 6. Tag release │
│ │ 7. Deploy to production │
└────────────────────────────────┴────────────────────────────────────┘
- Email: mario.ramirez@gesis.org
- GitHub Issues: Create an issue
Happy Contributing! 🎉