The backend uses pre-commit hooks to ensure code quality. All linting and type checking is configured in /backend/pyproject.toml.
From the backend directory:
cd backend
uv run pre-commit installThis will install git hooks that run automatically before each commit.
To run all checks on all files:
cd backend
uv run pre-commit run --all-filesTo run checks on staged files only:
cd backend
uv run pre-commit runYou can also run the tools individually:
Ruff (linting and auto-fix):
cd backend
uv run ruff check --fix .Ruff (formatting):
cd backend
uv run ruff format .MyPy (type checking):
cd backend
uv run mypy . --config-file pyproject.toml-
Linting: Ruff with the configuration in
backend/pyproject.toml- Line length: 120 characters
- Target: Python 3.12
- Selected rules: E (pycodestyle errors), W (warnings), F (pyflakes), I (isort), B (bugbear), C4 (comprehensions), UP (pyupgrade)
-
Formatting: Ruff formatter
- Double quotes
- Space indentation
- Auto-formatting before commit
-
Type Checking: MyPy with strict settings
- Check untyped definitions enabled
- Warn on unused configs
- Test files excluded from strict checking
The backend uses a .pre-commit-config.yaml file with three hooks:
- ruff-check: Runs linting and auto-fixes issues
- ruff-format: Formats code according to style guide
- mypy: Type checks all Python code
All hooks use uv run to ensure they run in the correct virtual environment.
- Pre-commit hooks are configured in
/backend/.pre-commit-config.yaml - Always run commands from the
/backenddirectory - The hooks use
pass_filenames: falseto run on all files in the backend directory fail_fast: falsemeans all hooks will run even if one fails
Run tests with pytest:
cd backend
uv run pytestRun tests for a specific app:
cd backend
uv run pytest core/
uv run pytest processor/
uv run pytest storage/
uv run pytest search/Build and run the full stack:
docker compose up -dRebuild specific services:
docker compose build backend backend-worker-processing backend-worker-cleanup
docker compose up -d backend backend-worker-processing backend-worker-cleanupForce rebuild without cache:
docker compose build --no-cache backend backend-worker-processing backend-worker-cleanup- Make your changes
- Run pre-commit hooks:
cd backend && uv run pre-commit run --all-files - Fix any issues reported
- Commit your changes (hooks will run automatically)
- If hooks fail, fix issues and commit again
- Edit
backend/pyproject.toml - Run
cd backend && uv lockto update lockfile - Rebuild Docker containers
- Test the changes
- Ensure all pre-commit hooks pass:
cd backend && uv run pre-commit run --all-files - Run the full test suite:
cd backend && uv run pytest - Test the application with Docker:
docker compose up -d - Verify all services are healthy:
docker compose ps