Contributing
Thank you for your interest in contributing to CAR. This guide covers the development workflow, coding conventions, and testing procedures.
Development Setup
Follow the Local Deployment guide to set up a local devcontainer. Once running, you will have:
Django dev server on
http://127.0.0.1:8000/Vite dev server on
http://127.0.0.1:3000/Celery worker processing background tasks
PostgreSQL database
Branch Strategy
master— stable release branchstaging— integration testingFeature branches — branch off
staging, merge back via pull request
Running Tests
All tests live in src/backend/tests/.
cd /container/src/
# Run the full test suite
python3 manage.py test backend --noinput
# Run a specific test module
python3 manage.py test backend.tests.test_api --noinput
# Run a specific test class
python3 manage.py test backend.tests.test_api.TestOTProjectCreateAction --noinput
# Run a specific test method
python3 manage.py test backend.tests.test_api.TestOTProjectCreateAction.test_create_action --noinput
Tip
Always use --noinput to avoid interactive prompts when a stale
test_postgres database exists from interrupted runs.
The test suite includes 1080+ tests covering:
API endpoints and serialisation
Model creation and validation
OT session orchestration and plate layout
Script generation and session visualization
Recipe loading, generation, and validation
Chemistry utilities (SMILES canonicalisation, conversions)
Multichannel pipette grouping and volume calculations
Code Conventions
Backend (Python)
Python 3.9 — use type hints where practical
Django 3.1 coding style
PEP 8 — enforced by linting
Use
snake_casefor functions and variablesUse
CamelCasefor classesKeep business logic in
services/or dedicated modules, not in ViewSetsUse descriptive variable names — avoid single-letter names except in tight loops
Frontend (JavaScript / React)
React 18 with functional components and hooks
Vite for build tooling
Components in
PascalCase.jsxKeep API calls in
common/api/Use Zustand stores (
common/stores/) for global state
Models & Migrations
When modifying Django models:
Make your changes in the appropriate
models/*.pyfileGenerate migrations:
python3 manage.py makemigrations
Apply migrations:
python3 manage.py migrate
Run the test suite to verify nothing is broken
Commit the migration file with your code changes
Adding a New API Endpoint
Add or modify the ViewSet in
api.pyRegister the route in
urls.py(if new)Add/update serializers in
serializers.pyWrite tests in
tests/
Documentation
Documentation is built with Sphinx and hosted on Read the Docs.
cd /container/docs/
sphinx-build -b html source build/html
# Or use make (if available)
make html
Preview the output by opening build/html/index.html.
When adding a new documentation page:
Create a
.rstfile in the appropriate subdirectory (user/,technical/, orreference/)Add the file to the
toctreeinsource/index.rstBuild and verify
Filing Issues
When reporting a bug, include:
Steps to reproduce
Expected vs actual behaviour
Relevant log output (
logs/logfile.logor Celery terminal)Browser console errors (for frontend issues)