Back to archive
II. Clinical AI & Health Platformsshowcaseleadclient anonymised

Lab Processor — Temporal × LangGraph

A medical microservice (Healthcare platform platform): analysis of lab results via AI. A two-layer orchestration — Temporal (durability) on top of LangGraph (parallel LLM DAG), PydanticAI for type-safe LLM outputs, HL7/PDF on input.

Status
active
Period
2025-09-05 → 2025-12-09
AI sessions
Stack
Languages
Python
Frameworks · Infra
FastAPITemporalLangGraphPydanticAIPydantic v2Keycloak
§01

Overview

  • What it is: a Python microservice that accepts lab data (HL7 message, PDF, or structured JSON), runs it through an AI pipeline (medical consultations per panel, health summary, high-level consultation, lifestyle recommendations) and assembles a final report (JSON + HTML), sending it to the PHI service. Part of the Healthcare platform medical platform.
  • Type / status / role: api (microservice) · active · lead — 44 of 72 commits from the user (Davron 42 + Dave93 2), co-author aniashev (27, same person as in deutsch-cookbook), Ramiro (3), Alisher (1).
  • Activity window: 2025-09-05 → 2025-12-09 (~3 months of dense work).
§02

Stack

  • Languages: Python 3.11+.
  • Frameworks/libraries: FastAPI + Uvicorn; Temporal (temporalio) — durable workflow orchestration with retries; LangGraph (StateGraph) — parallel AI DAG; PydanticAI (Azure OpenAI / Groq) — type-safe LLM interfaces; Pydantic v2 + pydantic-settings; hl7 + hl7conv2 (medical HL7 standard); PyMuPDF (PDF); Jinja2 (HTML reports); python-jose (JWT); Keycloak (realm-based auth); HashiCorp Vault (hvac); loguru; httpx.
  • Infra/deploy: Docker (separate Dockerfile for API and Dockerfile.worker for the Temporal worker), docker-compose (external temporal-network); dual CI — GitLab CI (.gitlab-ci.yml, install/lint/build/deploy stages) + GitHub Actions; uv (package manager, uv.lock); pre-commit; ruff + mypy (strict typing).
  • Data: doesn't store data itself; integrates with the PII (patient search/create) and PHI (HL7 processing, sending analyses) microservices; Vault for secrets.
  • Notable tooling: PydanticAI testing utils for LLM mocks; MemorySaver checkpointing in LangGraph.
§03

What was shipped

Major authored commits (by diff/files):

  • Temporal orchestration (587a922, 2025-10-30, 20 files, +1449): LabReportProcessingWorkflow with activities generate_lab_analysissubmit_analysis_to_phi_service, worker, retry policies.
  • Keycloak auth + HL7 (4fcdb98, 2025-10-21, 19 files, +1791): JWT validation, AuthenticationMiddleware, HL7 handling on lab endpoints, new dependencies.
  • Multi-realm Keycloak (9f57ea8): token validation without a hard-coded realm → multiple realms supported on endpoints.
  • Dynamic public-endpoint matching (d794004): path normalization + API v1 prefix from settings.
  • Docker + CI (13bf773 Docker +220, 999210a GitLab CI +95, d92cb3e GitHub Actions +114): full deploy pipeline, separate worker image.
  • mypy / typing (bc1fc18, e484245): type stubs (hvac, jinja2), strict typing of LLM outputs.
  • Volume: 72 commits over 3 months; the user is the lead author of the architecture (Temporal + auth + infra).
§04

Technical challenges

By actual code (user authorship confirmed by major commits):

  • Two-layer orchestration Temporal × LangGraph (src/temporal/workflows.py, src/workflows/lab_graph.py): the outer Temporal layer provides durability (per-activity RetryPolicy with exponential backoff: initial_interval=5s, maximum_interval=30s, backoff_coefficient=2.0, maximum_attempts=3, explicit start_to_close_timeout), the inner LangGraph layer is a parallel DAG: the medical chain (consultations → health_summary → high_level) and lifestyle recommendations run concurrently, then converge in report_assembly. Correct Temporal idiom workflow.unsafe.imports_passed_through() for importing activities. → Demonstrates: durable execution, recovery after worker crash, AI-pipeline parallelism, engineering maturity.
  • Type-safe AI pipeline (PydanticAI + LabAnalysisState TypedDict): all LLM outputs are Pydantic models; shared state is merged by LangGraph across parallel branches; provider abstraction Azure/Groq. → Type-safe LLMs, testability via mocks.
  • Enterprise auth (Keycloak realms: partner-api / internal-service / b2c; two token types — service for PII, partner for PHI; permission-based DI require_permission). → A serious access model for medical data.
  • Medical standards: HL7 parsing of incoming messages, PDF (PyMuPDF), Vault for secrets. → Domain maturity in healthcare.
§05

AI-assisted development

  • Sessions found: 0 under the full-path-normalized key for this project (verified). Likely worked from a monorepo / main healthcare-platform repo. A detailed CLAUDE.md (365 lines) + PYTHON_SERVICE_INTEGRATION_GUIDE.md (33 KB) — a sign of AI-assisted development.
  • What was done with AI: no transcripts here; but the project itself is an AI service (LLM orchestration), and the documentation is structured for Claude Code.
  • AI workflow patterns: CLAUDE.md as an architectural reference + integration guide.
§06

Achievements & metrics

  • Production medical AI microservice: 6 LangGraph nodes, 2 Temporal activities, 2 API routers (partner/B2C), integration with 2 microservices (PII/PHI) + Vault + Keycloak.
  • Dual CI/CD, API+worker containerization, strict typing (mypy) and lint (ruff).
§07

Contributors

git shortlog · all branches

  1. Dave9344
  2. aniashev27
  3. Ramiro3
  4. Alisher Mukhtorov1
4 contributors75 commits total
Currently

Open to Senior / Staff engineering roles and selective freelance — production AI, platform, and full-stack work.

Get in touch