Facility Service — Deployment Topology
Status: populated
Owner: TBD
Last updated: 2026-04-17
Companion: 17 Technology Stack · SERVICE_TEMPLATE §12
1. Runtime
| Attribute | Value |
|---|
| Language / runtime | Node 22 / TypeScript 5.x |
| Framework | NestJS 11 |
| Container base | node:22-alpine multi-stage |
| Process model | Single-process per pod; cluster mode disabled (Kubernetes handles replication) |
| Port | 8080 HTTP, 8081 health/metrics |
2. Dependencies
| Dep | Type | Purpose |
|---|
| PostgreSQL 16 | Required | Primary store |
| Redis 7 | Required | Cache, rate limits, idempotency |
| NATS JetStream | Required | Event stream |
| Kong | Required | Edge + auth |
| access-policy | Required | Authorisation |
| identity-service | Required | JWKS |
| audit-service | Soft | Audit sink |
| interop-service | Soft | FHIR projection |
3. Replication & Scaling
| Env | Replicas | Policy |
|---|
| dev | 1 | Manual |
| staging | 2 | HPA CPU ≥ 60 %, p95 latency |
| production | 3–10 | HPA CPU ≥ 70 % or request rate ≥ 800 rps/pod; min=3 |
Redis: ElastiCache cluster mode, 3 shards. Postgres: Aurora-compatible, 1 writer + 2 readers.
4. Regions
| Region | Tenants | Notes |
|---|
af-central-1 | AFG MoPH + AFG private | Local DR in-region |
ae-central-1 | UAE DoH + UAE private | |
eu-central-1 | Future EU pilots | |
Per-region isolation; cross-region reads disabled except by platform-admin with audit.
5. Environment Variables
| Var | Required | Purpose |
|---|
NODE_ENV | ✓ | development|staging|production |
PORT | ✓ | Defaults 8080 |
DATABASE_URL | ✓ | Postgres DSN |
REDIS_URL | ✓ | Redis DSN |
NATS_URL | ✓ | NATS JetStream |
JWKS_URI | ✓ | identity-service JWKS |
ACCESS_POLICY_URL | ✓ | Access-policy internal URL |
LICENSING_URL | ✓ | Licensing internal URL |
OTEL_EXPORTER_OTLP_ENDPOINT | ✓ | Collector |
MODULE_KEY | ✓ | ehr.facility |
FACILITY_CONTEXT_CACHE_TTL_SECONDS | — | Default 300 |
6. Health & Probes
| Probe | Path | Cadence |
|---|
| Liveness | /healthz | 10s |
| Readiness | /readyz (db+redis+nats ping) | 5s |
| Metrics | :8081/metrics | Prometheus scrape 15s |
7. Deploy Process
- Canary 5% / 30min; auto-rollback on SLO breach.
- Blue/green for schema migrations via drizzle + expand-contract pattern.
- Feature flags for FHIR projection and edge snapshot.