This webapp provides a frontend interface for pseudonymizing and annotating data and applying AI predictions.
pip install lx-annotate==1.7.7 Copy PIP instructions
LX-Annotate helps clinical teams review and annotate videos, PDFs, and AI outputs. It uses Django and Vue. The project began at Universitätsklinikum Würzburg, Bavaria.
Explore the project through the documentation guide. It links to clinical workflows, technical guidance, and a contribution roadmap. Contributions can include clearer guides, workflow feedback, tests, and code.
For a local setup, follow the development quick start below. Feature requirements and verification evidence live in feature-tracking.
If NumPy or another native dependency fails to import, the shell may lack Nix runtime libraries. Run the backend wrapper to load the devenv environment:
./scripts/run-backend-checks.sh Equivalent Make target:
make test-real Environment Variables and Secrets Production secrets are injected by the host system, LuxNix, or another secret manager. For local development, use either secretspec.toml defaults or a local .env file.
secretspec.toml is the tracked environment contract. It defines profile defaults and variable names, but it must not contain real production secrets. The Django settings flow is:
Production should prefer secret-file variables such as DJANGO_SECRET_KEY_FILE, DJANGO_DB_PASSWORD_FILE, DJANGO_KEYCLOAK_CLIENT_SECRET_FILE, and LX_ANNOTATE_MASTER_KEY_FILE. Compatibility aliases from the current secretspec contract are also accepted, including ALLOWED_HOSTS, OIDC_RP_CLIENT_ID, OIDC_RP_CLIENT_SECRET, and TIME_ZONE.
direnv allow secretspec --provider dotenv --profile development python manage.py runserver Production check example:
secretspec --provider dotenv --profile production \ python -m django check --settings=lx_annotate.settings.settings_prod See docs/guides/wheel-deployment.md for the full runtime contract and https://secretspec.dev/ for secretspec usage.
cd frontend npm install npm run build Hot-reload development:
export DJANGO_SETTINGS_MODULE=lx_annotate.settings.settings_dev python manage.py runserver File Watcher The file watcher ingests media placed in:
./scripts/start_filewatcher.sh dev # or python manage.py run_filewatcher Production HLS Materialization Production video playback uses HLS as the safe streaming path. The watcher or API first creates an UploadJob. The import then stores the source video behind the encrypted storage boundary, creates the anonymized processed_file, and finalizes the video record. After that point the processed video can be materialized into HLS.
Materialization is handled by the Django/Celery task endoreg_db.tasks.video_hls_materialization. The task creates or updates a VideoHlsArtifact record, reads the processed video through the storage boundary, and streams it to FFmpeg. FFmpeg writes a playlist.m3u8 file and seg_*.ts segments into the protected streamable video root. The HLS segments are encrypted with FFmpeg's native HLS encryption, while the HLS content key is managed separately and served through the key endpoint.
Nginx does not serve proprietary LXENC01 encrypted storage files. Django returns protected media responses with X-Accel-Redirect, and Nginx only offloads the standard HLS artifacts from the protected media area. Progressive MP4 streaming is legacy compatibility behavior and redirects to the processed HLS playlist in production.
The LuxNix runtime exposes two HLS systemd services:
Both services call the same guarded wrapper, runLxAnnotateHlsMaterialization. The wrapper always uses processed HLS, dispatches work to the ffmpeg_media queue, and rejects unsafe overrides such as --force, --inline, and --artifact-kind.
Upgrade behavior is intentionally idempotent. The backfill dispatcher runs without --force; existing READY artifacts with valid playlist and segment files are returned as already_ready, while missing or inconsistent artifacts are materialized or fail loudly.
lx-annotate supports two first-class ingest boundaries:
These are parallel ingress modes, not competing ones. The contract for new development is:
The watcher remains the right boundary for local system dropoff and SAP-style handoff flows. The API remains the right boundary for authenticated remote uploads and future hub integrations.
When upgrading to the hub-aware ingest model in endoreg_db, treat these as deployment requirements for LuxNix and host environments:
Outbound hub transfer is tracked as a separate sender workflow from ingest.
The sender-side workflow contract is documented in docs/guides/hub-export-workflow.md.
The Nix package exposes stable runtime entrypoints that do not clone the repo, run uv sync, or install Python packages at service start:
nix build .#lx-annotate ./result/bin/lx-annotate-web ./result/bin/lx-annotate-manage check ./result/bin/lx-annotate-worker --hostname="maintenance@%h" --queues=maintenance,default LX_ANNOTATE_FILEWATCHER_ARGS=--process-existing-once ./result/bin/lx-annotate-watch The primary entrypoints are lx-annotate-web, lx-annotate-manage, lx-annotate-worker, and lx-annotate-watch. lx-annotate-server remains as a compatibility alias for the web command.
The repository flake also exposes the existing devenv environment as a Nix dev shell:
nix develop --no-pure-eval This evaluates devenv.nix through the top-level flake.nix, so the same shell can be entered either with devenv/direnv or directly through nix develop.
The CI pipeline can now build a production wheel with frontend staticfiles included via hatchling. Production runtime no longer needs Node.js or the full devenv shell.
Use make package to build release artifacts locally. That target rebuilds the frontend, verifies that staticfiles/.vite/manifest.json is valid and contains the required src/main.ts mapping, and only then runs python -m build for the wheel and sdist.
This split is required for the next hardening step: encrypting the data path and restricting access to the endoreg-service-user while keeping application code and deployment mechanics separate from protected patient data.
The canonical host-owned runtime variable for this boundary is LX_ANNOTATE_ENCRYPTED_DATA_DIR. The app derives compatibility aliases and managed storage paths from that root.
The same app contract owns DJANGO_SETTINGS_MODULE, DJANGO_ENV, STATIC_URL, MEDIA_URL, NGINX_PROTECTED_MEDIA_URL, and SERVE_WITH_NGINX. Host environment files should provide only host paths, network settings, service endpoints, and secret file references.
New deployment code should anchor path derivation on LX_ANNOTATE_ENCRYPTED_DATA_DIR and leave the derived path variables out of host-owned environment files.
For application-layer envelope encryption, lx_annotate uses lx_annotate.storage.encrypted.EncryptedStorage as the default Django storage backend. Runtime deployments must provide LX_ANNOTATE_MASTER_KEY or LX_ANNOTATE_MASTER_KEY_FILE; production deployments should use the file form through the host secret manager. The backend generates a per-file DEK, wraps it with the service-level KEK, writes ciphertext only under LX_ANNOTATE_ENCRYPTED_DATA_DIR, and encrypts/decrypts in chunks so large uploads do not have to fit into memory. The KEK is intentionally service-scoped rather than tied to a Keycloak session so background workers such as manage.py run_filewatcher can still process stored files.
Encryption itself should not be implemented by generating random keys inside the application process. The app only consumes the mounted/unlocked path. Key management and unlock policy belong in a dedicated LuxNix service or external secrets/KMS layer.
For the architecture and mode selection details, see docs/guides/deployment-strategy.md.
Deployment assets live in deployment_example/:
See docs/guides/wheel-deployment.md for the full host bootstrap and systemd flow.
For the current production-style service environment, including the repo-local-data to /var/lib/lx-annotate/data recovery flow and the SAP IS-H drop-to-watcher import path, see docs/guides/deployment-strategy.md.
Docker images now install Python packages into /app/.devenv/state/venv so the container path matches the repository's preferred virtualenv layout.
This does not mean Docker runs the full Nix/devenv shell. Inside the container, uv creates and manages the environment at that path, and the image PATH is configured to use /app/.devenv/state/venv/bin.
See container/README.md for development and production Docker usage.
The anonymization overview presents import, anonymization, HTTP Live Streaming (HLS) materialization, annotation, and source cleanup as separate state axes. Import jobs expose stable error codes and safe operator messages. A retrying job is a transient dispatch failure with a bounded attempt count and next retry time; error and lost are terminal and require operator review or a safe reimport. Duplicate imports are identified by duplicate_content, never by parsing exception text.
Raw and processed HLS are tracked independently as queued, materializing, ready, or failed, with source and target generation identifiers and the triggering upload job when available. Active import or HLS work disables competing row actions. Quarantine rows are read-only and show their review state and permitted next step without exposing filesystem paths or raw technical errors.
The operational state matrix, retry policy, error-code catalog, diagnostics, and quarantine workflow are maintained in the endoreg-db docs/hub_ingest_operations.md runbook. Feature readiness is tracked only in feature-tracking/ImportMonitoring.yml in endoreg-db.
pytest cd frontend npm run test:unit License MIT. See LICENSE.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




