Contributing¶
Development Environment¶
The project includes a DevContainer configuration for VS Code:
- Base image: the NetBox image pinned by
NETBOX_VARIANTin.devcontainer/Dockerfile-plugin_dev - Database:
postgis/postgis:16-3.4(PostgreSQL 16 + PostGIS 3.4) - Cache: Redis 7 Alpine
- Tools: fish shell, oh-my-fish, GitHub CLI
Getting Started¶
- Clone the repository
- Open in VS Code with the Dev Containers extension
- The container automatically installs the plugin in editable mode
Running the Dev Server¶
Running Migrations¶
netbox-branching¶
The devcontainer installs netbox-branching
(the 1.2.x line, which targets NetBox 4.7) for manual testing of pathway
changes inside branches. .devcontainer/configuration/configuration.py wraps
DATABASES in DynamicSchemaDict and sets the BranchAwareRouter, and
netbox_branching is listed last in PLUGINS as its install docs require.
After rebuilding the container run python manage.py migrate to create the
branching tables.
pytest inside the devcontainer loads the same configuration directory, so both
configuration.py and plugins.py leave branching out (no DynamicSchemaDict,
no router, no netbox_branching plugin) whenever the configuration is loaded
by pytest; tests always run without branching. Set NETBOX_BRANCHING=false in
.devcontainer/env/local.env to turn branching off for runserver and the
worker as well.
Code Style¶
Python¶
- Linter: ruff
- Line length: 120 characters
- Target: Python 3.12+
- Enabled rules: E, F, W, I, N, UP, S, B, A, C4, DJ, PIE
Run the linter:
TypeScript¶
- Target: ES2016
- Strict mode: enabled
- Build: esbuild (IIFE bundles)
Run type checking:
Build bundles:
Testing¶
Tests use pytest with pytest-django:
pytest
pytest -v # verbose
pytest tests/test_registry.py # specific file
pytest -k "test_register" # by name pattern
Coverage report:
Test Structure¶
tests/
├── conftest.py # Shared fixtures
├── test_registry.py # Map layer registry tests
├── test_external_geo.py # External GeoJSON endpoint tests
└── ...
Commit Messages¶
Format: topic(subtopic): description
| Topic | Use |
|---|---|
feat |
New feature |
fix |
Bug fix |
refactor |
Code restructure (no behavior change) |
chore |
Maintenance, dependencies |
docs |
Documentation |
tests |
Test additions/changes |
linting |
Code style fixes |
Examples:
feat(models): add Structure and Pathway models
fix(views): correct conduit bank queryset
chore(deps): update ruff to 0.9.x
docs(map): add interactive map documentation
Warning
A git hook rejects commit messages containing AI attribution lines (Co-Authored-By:, Generated by/with). Do not include these in commit messages.
Pull Requests¶
- Create a feature branch from
main - Make your changes with tests
- Run linting and tests:
ruff check . && pytest - Run Django system checks:
python manage.py check --deploy - Push and create a PR
Architecture Notes¶
- Follow NetBox plugin conventions for views, forms, tables, and serializers
- Use the NetBox layout system (
SimpleLayout+ panels) for detail views - All geographic fields use PostGIS via
django.contrib.gis - GeoJSON endpoints use
djangorestframework-gisserializers - Frontend TypeScript targets ES2016 for browser compatibility
- Leaflet is loaded from vendor files, not bundled