Thank you for your interest in contributing to Bambuddy! This document provides guidelines and instructions for contributing.
Please read and follow our Code of Conduct to keep our community welcoming and respectful.
Every contribution starts with an issue. Before writing any code or opening a pull request:
No assigned issue = no PR. Pull requests without a corresponding assigned issue will be closed.
This keeps everyone on the same page, avoids wasted effort on changes that may not fit the project's direction, and prevents multiple contributors from working on the same thing.
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/bambuddy.git
cd bambuddy
Add the upstream remote:
git remote add upstream https://github.com/maziggy/bambuddy.git
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt # Dev/test dependencies (pytest, ruff, bandit, etc.)
# Install pre-commit hooks
pip install pre-commit
pre-commit install
# Run backend
DEBUG=true uvicorn backend.app.main:app --reload --host 0.0.0.0 --port 8000
cd frontend
# Install dependencies
npm install
# Run development server
npm run dev
The frontend will be available at http://localhost:5173 and will proxy API requests to the backend.
# Run the full application
docker compose up -d --build
# Run tests in Docker (mirrors CI)
docker compose -f docker-compose.test.yml run --rm backend-test
docker compose -f docker-compose.test.yml run --rm frontend-test
Create a branch from dev for your changes:
git checkout dev
git pull upstream dev
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix
Make your changes following our code style guidelines
Test your changes thoroughly
Commit your changes with clear, descriptive messages:
git commit -m "Add feature: description of what you added"
feature/ - New featuresfix/ - Bug fixesdocs/ - Documentation changesrefactor/ - Code refactoringtest/ - Test additions or fixesWe use Ruff for linting and formatting. Configuration is in pyproject.toml.
# Check linting
ruff check backend/
# Auto-fix issues
ruff check --fix backend/
# Format code
ruff format backend/
# Check formatting without changes
ruff format --check backend/
We use ESLint for linting and TypeScript for type checking:
cd frontend
# Lint
npm run lint
# Type check
npx tsc --noEmit
Pre-commit hooks run automatically on git commit and include Ruff linting/formatting, trailing whitespace fixes, YAML/JSON validation, and import shadowing checks. To run manually:
pre-commit run --all-files
The frontend uses react-i18next for all user-facing text. Never hardcode user-visible strings — always use translation keys.
Translations live in frontend/src/i18n/locales/:
| File | Language |
|---|---|
en.ts |
English (primary) |
de.ts |
German |
fr.ts |
French |
ja.ts |
Japanese |
pt-BR.ts |
Brazilian Portuguese |
Use the useTranslation hook in your component:
import { useTranslation } from 'react-i18next';
function MyComponent() {
const { t } = useTranslation();
return <span>{t('section.myNewKey')}</span>;
}
Keys are organized by feature (e.g., spoolman., nav., common.)
Bambuddy has an optional authentication system. When auth is enabled, API endpoints are protected by granular permissions.
Authentication is opt-in — when disabled, all endpoints are open. The system uses RequirePermissionIfAuthEnabled which:
Use the RequirePermissionIfAuthEnabled dependency in your route:
from backend.app.core.auth import RequirePermissionIfAuthEnabled
from backend.app.core.permissions import Permission
@router.get("/my-resource")
async def get_my_resource(
_: User | None = RequirePermissionIfAuthEnabled(Permission.RESOURCE_READ),
):
...
Permissions follow the resource:action pattern (e.g., filaments:read, printers:control). Standard actions:
| Action | Usage |
|---|---|
read |
View/list resources |
create |
Create new resources |
update |
Modify existing resources |
delete |
Remove resources |
Some resources have additional actions (e.g., printers:control for start/stop, printers:files for file transfer).
Permission enum in backend/app/core/permissions.pyPERMISSION_CATEGORIESAdministrators gets all, Operators and Viewers as appropriate)RequirePermissionIfAuthEnabled| Group | Access Level |
|---|---|
| Administrators | All permissions |
| Operators | Full control of printers, own items in archives/queue, read-only settings |
| Viewers | Read-only access to all resources |
The easiest way to run tests is with the provided scripts in the project root:
./test_frontend.sh # TypeScript check + ESLint + Vitest
./test_backend.sh # Ruff lint/format + pytest (parallel)
./test_docker.sh # Full Docker build, unit tests, and integration tests
./test_all.sh # All of the above (frontend → backend → docker)
./test_security.sh # Security scans (bandit, pip-audit, npm-audit)
test_docker.sh supports flags like --backend-only, --skip-integration, --fresh — run with --help for details.
test_security.sh runs fast scans by default. Use --full for the complete suite (CodeQL, Trivy, etc.) or specify individual scans like ./test_security.sh bandit codeql.
Backend — tests are in backend/tests/ with unit/ and integration/ subdirectories:
pytest backend/tests/ -v # All tests
pytest backend/tests/unit/ # Unit tests only
pytest backend/tests/ --cov=backend # With coverage
Frontend — tests use Vitest and are in frontend/src/__tests__/:
cd frontend
npm run test:run # Single run
npm test # Watch mode
npm run test:coverage # With coverage
Pull requests trigger automated CI checks via GitHub Actions (.github/workflows/ci.yml):
All checks must pass before merging. Run ./test_all.sh locally before pushing to catch issues early.
Push your branch to your fork:
git push origin feature/your-feature-name
Create a Pull Request on GitHub:
dev branch as the base branch (not main)Wait for review - maintainers will review your PR and may request changes
Use the Bug Report template and include:
Use the Feature Request template and include:
Thank you for contributing to Bambuddy!