Laboratory Service — Deployment Topology
Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD
1. Runtime
| Attribute | Value |
|---|---|
| Runtime | Node 22 / NestJS 11 |
| Language | TypeScript 5.x |
| Process | Single NestJS process per replica |
| Port | 3000 (HTTP) |
| Package name | @ghasi/laboratory-service |
2. Replicas and Scaling
| Environment | Min replicas | Max replicas | Scaling trigger |
|---|---|---|---|
| Production (hub) | 2 | 6 | CPU > 70% or p95 latency > 1.5 s |
| Production (facility node) | 1 | 2 | CPU > 80% |
| Staging | 1 | 2 | Manual |
| Development | 1 | 1 | N/A |
3. Regions / Nodes
| Deployment type | Where | Notes |
|---|---|---|
| Hub deployment | National data center (AFG primary) | Serves multi-tenant API and FHIR endpoints |
| Facility node | Edge deployment at hospital level | Offline-capable; syncs to hub when connected |
| DR site | AFG secondary | Active-passive; failover < 15 min |
4. Dependencies
| Dependency | Type | Notes |
|---|---|---|
| PostgreSQL 16 | Hard | Per-service isolated schema |
| NATS JetStream | Hard | Event publishing and order inbox |
| interop-service FHIR gateway | Hard (for release) | FHIR publish on result release |
| terminology-service | Soft | LOINC validation; degraded mode if unavailable |
| Redis 7 | Soft | Result trending cache; optional |
| Keycloak | Hard | JWT validation |
| Kong | Hard | API routing |
5. Kong Routes
| Route | Upstream |
|---|---|
/v1/laboratory/* | laboratory-service:3000 |
/fhir/R4/Observation (category=laboratory) | Routed by interop-service → laboratory-service |
/fhir/R4/DiagnosticReport (category=LAB) | Routed by interop-service → laboratory-service |
/fhir/R4/Specimen | Routed by interop-service → laboratory-service |
6. Environment Variables
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string |
NATS_URL | Yes | NATS JetStream connection |
KEYCLOAK_JWKS_URI | Yes | JWT validation endpoint |
FHIR_GATEWAY_URL | Yes | interop-service FHIR base URL |
TERMINOLOGY_SERVICE_URL | Yes | Terminology service base URL |
REDIS_URL | No | Trending result cache |
MODULE_LICENSE_KEY | Yes | diag.laboratory entitlement key |
OUTBOX_RELAY_INTERVAL_MS | No | Default 5000 |