Skip to main content

Medication Service — Deployment Topology

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template

1. Runtime

PropertyValue
RuntimeNode 22 LTS
FrameworkNestJS 11
LanguageTypeScript 5.x (strict)
Container basegcr.io/distroless/nodejs22-debian12
Startupnode dist/main.js — OpenTelemetry initialized before NestFactory

2. Replicas / Scaling

EnvironmentBaselineMaxHPA trigger
dev11n/a
staging24CPU 70%
prod (M1)310CPU 60% or RPS > 500/pod
prod (M3+, with pharmacy portal)520CPU 60% + queue depth > 100

Pharmacy-portal API traffic and clinical-sign traffic share pods; NATS consumers may deploy as separate worker pods (medication-worker) at higher replica counts for event-heavy tenants.

3. Dependencies

DependencyPurpose
Postgres 16Primary DB (schema medication), RLS enforced
NATS JetStreamEvents
Redis (optional)Idempotency key cache, rate limit, dispense queue hot path
VaultKMS keys, NCPDP certs
identity-serviceJWT / JWKS
tenant-serviceAccess-Policy
ghasi-eprescribing-gateway-serviceGateway FHIR API
patient-chart-serviceAllergy/problem-list FHIR reads
terminology-serviceCode lookups
audit-serviceAudit sink
ai-gateway-service(optional) sig parse, reconciliation summary

4. Regions & Residency

RegionRole
me-central-1 (UAE)Primary for AFG + UAE tenants
eu-west-1 (Ireland)EU tenants (GDPR)
National sovereign regionsPer-country controlled-substance records must not leave (config-service gate)

Multi-region DR: primary-only for M1; active-active in M3 (eventual consistency on outbox + inbox).

5. Kong Routes

RouteTargetNotes
/api/v1/medications/*medication-serviceJWT required
/api/v1/dispenses/*medication-servicePharmacist scopes
/api/v1/stock-items/*medication-service
/api/v1/mar/*medication-service
/api/v1/reconciliation/*medication-service
/fhir/R4/MedicationRequest (chart)medication-service via fhir-gatewayNational interop uses eprescribing-gateway
/fhir/R4/MedicationAdministrationmedication-service via fhir-gateway

6. Resource Requests

ResourceReqLimit
CPU500m2
Memory512Mi1Gi
Ephemeral disk256Mi1Gi

7. Canary

  • 5% traffic for 30 minutes. Progressive rollout via Argo Rollouts.
  • SLO gates: sign p95 < 1500ms, dispense error rate < 0.1%, no negative-stock events.