Skip to main content

Identity Service — Deployment Topology

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 17 Technology Stack

1. Runtime summary

PropertyValue
RuntimeNode.js 22 LTS
FrameworkNestJS 11
LanguageTypeScript 5.x
Package@ghasi/service-identity
HTTP port3001
HealthcheckGET /health

2. Container topology

3. Replica and scaling policy

DimensionValue
Min replicas3 (one per availability zone)
Max replicas10
Scale-out triggerCPU ≥ 60% avg over 90 s
Scale-in cooldown5 min
Pod anti-affinityrequiredDuringSchedulingIgnoredDuringExecution across zones
Resource requestcpu: 250m, memory: 256Mi
Resource limitcpu: 1000m, memory: 512Mi

4. Regional deployment

RegionRoleNotes
Primary (AF / UAE)Read + writeActive PostgreSQL primary
Secondary (DR)Read standbyStreaming replica; RTO ≤ 30 min
Edge (future)JWKS cache onlyKong plugin caches JWKS; full service not needed at edge PoP

Data residency: tenant rows stay in tenant's assigned region. Module catalogue (no tenant PII) is replicated cross-region for availability.

5. Database connection pools

StorePool sizingNotes
PostgreSQL primarypgBouncer transaction mode, max 20 connsWrites; RLS SET app.tenant_id per transaction
PostgreSQL replicapgBouncer, max 10 connsGET /licensing/nodes/:id/effective read path
Redis 7 Cluster3 shards, ioredis cluster clientSession revocation bitmap; 5-min license cache; rate-limit counters

6. Key management

SecretStoreRotation cadence
JWT RS256 private key (JWKS)AWS KMS asymmetric key90 days; 7-day overlap window
Device certificate signing keyAWS KMS180 days
API key HMAC secretAWS Secrets ManagerOn rotation request
DATABASE_URLKubernetes Sealed SecretQuarterly or on breach
Keycloak client secretKubernetes Sealed Secret90 days

7. Network policies

SourceDestinationPortProtocol
Kongidentity-service3001HTTP/2
identity-servicePostgreSQL5432TCP
identity-serviceRedis6379TCP
identity-serviceNATS4222TCP
identity-serviceAWS KMS endpoint443HTTPS
identity-serviceKeycloak8443HTTPS
tenant-service/internal/identity/*3001HTTP cluster-internal
All services/.well-known/jwks.json3001HTTP cluster-internal

/internal/* routes are IP-restricted to cluster CIDR — no JWT required.

8. Environment variables

VariableDescription
DATABASE_URLPostgreSQL primary connection string
DATABASE_REPLICA_URLPostgreSQL replica connection string
REDIS_URLRedis cluster URL
NATS_URLNATS JetStream URL
IDENTITY_JWT_ISSUERJWT iss claim value
IDENTITY_JWT_AUDIENCEJWT aud claim value
IDENTITY_KMS_KEY_ARNARN of JWT signing key
IDENTITY_DEVICE_CERT_KEY_ARNARN of device cert signing key
IDENTITY_KEYCLOAK_URLKeycloak base URL
IDENTITY_SESSION_ABSOLUTE_TTL_SAbsolute session TTL seconds (default: 28800)
IDENTITY_ARGON2_MEMORY_KIBArgon2id memory parameter (default: 65536)
OTEL_EXPORTER_OTLP_ENDPOINTOpenTelemetry collector
OTEL_SERVICE_NAMEidentity-service

All validated at startup via Zod schema in src/infrastructure/config/env.ts; service exits with code 1 if any required variable is missing.

9. CI/CD pipeline

Automatic rollback triggered when error rate > 1% or p99 latency > 2 s during canary window.