Skip to content

Contributing

Guidelines for contributing to Campaign Brain.

Development Setup

# Clone repository
git clone git@github.com:Nominate-AI/cbtenant.git
cd cbtenant

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run tests
python -m pytest tests/

# Start development servers
./startit.sh

Code Style

Python

  • Follow PEP 8
  • Use type hints
  • 4-space indentation
  • Docstrings for all public functions
def create_tenant(name: str, slug: str) -> Tenant:
    """Create a new tenant instance.

    Args:
        name: Display name for the tenant
        slug: URL-safe identifier

    Returns:
        Created Tenant object

    Raises:
        ValueError: If slug already exists
    """
    ...

Naming Conventions

Type Convention Example
Classes PascalCase TenantConfig
Functions snake_case create_tenant
Variables snake_case tenant_id
Constants UPPER_SNAKE MAX_TENANTS

Imports

# Standard library
import os
from pathlib import Path

# Third-party
from fastapi import FastAPI
from sqlalchemy import Column

# Local
from db.models import Tenant
from api.auth import get_current_user

Git Workflow

Branch Naming

  • feature/description - New features
  • fix/description - Bug fixes
  • docs/description - Documentation
  • refactor/description - Code refactoring

Commit Messages

type: short description

Longer description if needed.

Closes #123

Types: feat, fix, docs, refactor, test, chore

Pull Requests

  1. Create feature branch
  2. Make changes
  3. Run tests
  4. Create PR with description
  5. Wait for review
  6. Merge after approval

Testing

Running Tests

# All tests
python -m pytest

# Specific file
python -m pytest tests/test_tenants.py

# With coverage
python -m pytest --cov=api

Writing Tests

def test_create_tenant(client, db):
    """Test tenant creation."""
    response = client.post("/api/tenants", json={
        "name": "Test Campaign",
        "slug": "test-campaign"
    })
    assert response.status_code == 201
    assert response.json()["name"] == "Test Campaign"

Documentation

  • Update docs when changing features
  • Use MkDocs for documentation
  • Include code examples
  • Add diagrams where helpful
# Preview docs locally
mkdocs serve

# Build docs
mkdocs build

Release Process

  1. Update VERSION file
  2. Update CHANGELOG
  3. Create git tag
  4. Push to GitHub
  5. Deploy to tenants

Getting Help

See Also