Medication Service — Deployment Topology
Status: populated
Owner: TBD
Last updated: 2026-04-17
Companion: Service Template
1. Runtime
| Property | Value |
|---|
| Runtime | Node 22 LTS |
| Framework | NestJS 11 |
| Language | TypeScript 5.x (strict) |
| Container base | gcr.io/distroless/nodejs22-debian12 |
| Startup | node dist/main.js — OpenTelemetry initialized before NestFactory |
2. Replicas / Scaling
| Environment | Baseline | Max | HPA trigger |
|---|
| dev | 1 | 1 | n/a |
| staging | 2 | 4 | CPU 70% |
| prod (M1) | 3 | 10 | CPU 60% or RPS > 500/pod |
| prod (M3+, with pharmacy portal) | 5 | 20 | CPU 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
| Dependency | Purpose |
|---|
| Postgres 16 | Primary DB (schema medication), RLS enforced |
| NATS JetStream | Events |
| Redis (optional) | Idempotency key cache, rate limit, dispense queue hot path |
| Vault | KMS keys, NCPDP certs |
| identity-service | JWT / JWKS |
| tenant-service | Access-Policy |
| ghasi-eprescribing-gateway-service | Gateway FHIR API |
| patient-chart-service | Allergy/problem-list FHIR reads |
| terminology-service | Code lookups |
| audit-service | Audit sink |
| ai-gateway-service | (optional) sig parse, reconciliation summary |
4. Regions & Residency
| Region | Role |
|---|
me-central-1 (UAE) | Primary for AFG + UAE tenants |
eu-west-1 (Ireland) | EU tenants (GDPR) |
| National sovereign regions | Per-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
| Route | Target | Notes |
|---|
/api/v1/medications/* | medication-service | JWT required |
/api/v1/dispenses/* | medication-service | Pharmacist 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-gateway | National interop uses eprescribing-gateway |
/fhir/R4/MedicationAdministration | medication-service via fhir-gateway | |
6. Resource Requests
| Resource | Req | Limit |
|---|
| CPU | 500m | 2 |
| Memory | 512Mi | 1Gi |
| Ephemeral disk | 256Mi | 1Gi |
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.