Skip to main content

Facility Service — Deployment Topology

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: 17 Technology Stack · SERVICE_TEMPLATE §12

1. Runtime

AttributeValue
Language / runtimeNode 22 / TypeScript 5.x
FrameworkNestJS 11
Container basenode:22-alpine multi-stage
Process modelSingle-process per pod; cluster mode disabled (Kubernetes handles replication)
Port8080 HTTP, 8081 health/metrics

2. Dependencies

DepTypePurpose
PostgreSQL 16RequiredPrimary store
Redis 7RequiredCache, rate limits, idempotency
NATS JetStreamRequiredEvent stream
KongRequiredEdge + auth
access-policyRequiredAuthorisation
identity-serviceRequiredJWKS
audit-serviceSoftAudit sink
interop-serviceSoftFHIR projection

3. Replication & Scaling

EnvReplicasPolicy
dev1Manual
staging2HPA CPU ≥ 60 %, p95 latency
production3–10HPA 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

RegionTenantsNotes
af-central-1AFG MoPH + AFG privateLocal DR in-region
ae-central-1UAE DoH + UAE private
eu-central-1Future EU pilots

Per-region isolation; cross-region reads disabled except by platform-admin with audit.

5. Environment Variables

VarRequiredPurpose
NODE_ENVdevelopment|staging|production
PORTDefaults 8080
DATABASE_URLPostgres DSN
REDIS_URLRedis DSN
NATS_URLNATS JetStream
JWKS_URIidentity-service JWKS
ACCESS_POLICY_URLAccess-policy internal URL
LICENSING_URLLicensing internal URL
OTEL_EXPORTER_OTLP_ENDPOINTCollector
MODULE_KEYehr.facility
FACILITY_CONTEXT_CACHE_TTL_SECONDSDefault 300

6. Health & Probes

ProbePathCadence
Liveness/healthz10s
Readiness/readyz (db+redis+nats ping)5s
Metrics:8081/metricsPrometheus 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.