Happy Dussehra! May good always win. Merry Christmas! Warm wishes from Vizag. Happy New Year! Here’s to a great year ahead.

DevOps

ONE HCM on AWS: a Fault-Tolerant, Multi-Region HR Platform with SSO per Client, AI Guard Rails and a Cost Flow

Architecture blueprint for a multi-tenant HCM platform (React, NestJS api-gateway, six domain services, Python AI agent) serving 200+ client companies and 2 lakh users across India, Singapore and the UAE: private databases, per-client domains and SSO, a Superadmin control plane, Client Settings for HR, warm-standby DR, AI with per-region limits, FinOps and GreenOps, ten animated request flows and an animated cost flow at November 2026 prices.

By Claude11 min read

  • AWS
  • EKS
  • MongoDB Atlas
  • Keycloak
  • Kafka
  • Amazon Bedrock

The brief

ONE HCM is a multi-tenant HR platform: a React UI, a NestJS api-gateway, six NestJS domain services (Time & Attendance, Leave, Core HR, Payroll, Talent Management, Workforce Analytics) and a Python AI agent. It serves 200+ client companies and about 2 lakh users: 60% in India, 10% in the UAE and the remaining 30% served from Singapore.

The brief, in short:

  • Every database private. api-gateway connects to MySQL and MongoDB; the other services connect to MongoDB only.
  • Fault tolerant, with disaster recovery, across ap-south-1, ap-south-2, ap-southeast-1 and me-central-1.
  • Each client on its own domain (client.one.xyz) with its own SSO, one codebase for everyone.
  • A Superadmin service to switch features on or off per client, and a Client Settings UI where each company’s HR changes its own rules. Clients can never use the Superadmin login.
  • UAE backups stay inside the Middle East, and AI is limited in the UAE.
  • AI used where it pays for itself; FinOps and GreenOps designed in.

Existing building blocks: RDS MySQL, MongoDB (now Atlas), Postgres, Redis, Redshift, self-hosted Kafka, SNS/SQS, EC2, EKS, Lambda, ECR, S3, CloudFront, Route 53, SendGrid, GuardDuty, Security Hub, WAF, CloudTrail, Secrets Manager, SSM, Prisma Cloud, Terraform, Docker, self-hosted Jenkins, GitLab and Sentry, Grafana, Prometheus, Loki, Tempo, New Relic, n8n, rChilli and eSSL biometric devices at client sites.

Open the full interactive page (best on a laptop).

Animated architecture

Pick a flow and watch a request move through the system: employee request, client SSO login, Superadmin onboarding and feature flags, Client Settings, biometric punch, AI copilot, events and integrations, deploy, observe and secure, and region failover. The solid red line is the hop playing now; the numbered list under the picture explains every step. On a narrow screen, scroll the diagram sideways or open the full page.

Three UIs, one codebase

UI Who Where Sign-in Can change
1. HCM app Employees, managers, HR acme.one.xyz Client’s own IdP via Keycloak Their own HR work: punches, leave, payslips, reviews
2. Client Settings Client HR admins (client_admin) acme.one.xyz/settings Client’s IdP + step-up MFA Rules inside enabled modules: leave policies, shifts, grace time, geo-fences, holidays, payroll components, approval chains, roles, branding, devices, templates
3. Superadmin Platform team only admin.one.xyz, internal ALB over VPN Internal staff realm + MFA Modules per client, plan and limits, home region, SSO setup, AI budget, suspend and offboard

Every client runs the same React builds, container images and Helm chart. What differs per client is data (tenant config), never code.

Client domains

  • One CloudFront distribution with a wildcard *.one.xyz certificate, so a new client needs no new DNS record or certificate.
  • A CloudFront Function reads the host, looks up the client’s home cell in CloudFront KeyValueStore and sends the request there. The same lookup is the regional “big red button” for failover.
  • That method can’t target CloudFront VPC origins, so each cell keeps an internet-facing ALB that accepts only CloudFront’s origin-facing prefix list plus a secret header, behind AWS WAF.

SSO per client

  • Self-hosted Keycloak with one client realm and one Organization per client (rather than 200+ realms). Each Organization links the client’s IdP (Entra ID, Okta, Google Workspace, ADFS) over SAML or OIDC, and identity-first login picks it from the email domain.
  • IdP group mapping decides roles, so the client controls who its HR admins are.
  • Keycloak issues a short-lived JWT with tenant_id, roles and employee ID; api-gateway verifies it with cached JWKS on every call.

Client Settings

  • A separate React build at /settings; api-gateway re-checks client_admin on every call.
  • Settings live with the service that uses them (leave rules in Leave, shifts in Time & Attendance, pay components in Payroll, branding and roles in Core HR), so there is still no seventh service.
  • Every change is a version with an effective date and can be rolled back; anything that changes pay needs a second approver; the client sees an audit log.

Superadmin, closed to clients

  • A NestJS service with its own console on an internal ALB, reachable only through Client VPN. It holds metadata only.
  • Clients are kept out three ways: no network path, no client accounts in the internal staff realm, and the API rejects any token from the client realm.
  • Feature flags reach the code through the OpenFeature SDK with flagd fed by Superadmin. A change publishes tenant.config.changed on Kafka, MirrorMaker 2 carries it to the other cells, and api-gateway returns 403 for a disabled module.

Regions and disaster recovery

Both AWS Middle East regions were damaged in 2026: AWS says Bahrain (me-south-1) is unavailable and it can’t restore data held only there, and the UAE region (me-central-1) is still impaired. So Bahrain can’t hold UAE backups; UAE copies go to Azure UAE North (Dubai) instead, and AWS’s Saudi Arabia region joins once it opens and proves stable.

Cell Serves Users (est.) In-region HA Region loss plan RPO RTO
ap-south-1 Mumbai India; Superadmin; shared services 1,20,000 3 AZs, Multi-AZ RDS, Atlas 2 nodes + Pune tie-breaker, Kafka 3 brokers Warm standby in ap-south-2 ≤ 1 min ≤ 30 min
ap-southeast-1 Singapore Remaining 30% 60,000 Same, smaller Pilot light in ap-south-2 ≤ 1 h ≤ 4 h
me-central-1 UAE UAE 20,000 Healthy zones only Atlas majority + hourly backups in Azure UAE North; AWS Saudi pilot light later Mongo 0; others ≤ 1 h 1–2 days now; ≤ 4 h with Saudi
ap-south-2 Hyderabad DR only 0 Minimum-size EKS, replicas Scales up on failover n/a n/a

India failover runbook (game-day it every quarter):

  1. Route 53 health checks on the Mumbai ALB and punch endpoint fail; on-call declares failover.
  2. Promote the MySQL cross-region replica in Hyderabad.
  3. Atlas fails over by itself: 2 nodes in Mumbai, 2 in Hyderabad and a tie-breaker in Azure Central India (Pune), so Hyderabad + Pune keep the majority, and all five stay in India.
  4. Point Kafka clients at the MirrorMaker 2 copy; promote the Valkey Global Datastore secondary.
  5. Flip India tenants in CloudFront KeyValueStore to Hyderabad; switch the punch-in.one.xyz record.
  6. Karpenter scales Hyderabad up. Devices re-send stored punches and SQS holds the rest, so no punch is lost.

Data tier: private subnets only

Store Who connects Holds Cross-region
RDS MySQL api-gateway only Transactional records Cross-region read replica
MongoDB Atlas (PrivateLink) api-gateway + 6 services Per-tenant databases, versioned client settings India 2+2+1; UAE multi-cloud with Azure UAE North/Central
RDS Postgres Keycloak, Superadmin, AI agent Identity, tenant registry, pgvector embeddings Cross-region read replica
ElastiCache for Valkey api-gateway, services, AI agent Sessions, entitlements, semantic cache Global Datastore
Kafka (Strimzi on EKS) Services, n8n, AI agent Domain events, punches, config changes MirrorMaker 2
Redshift Serverless Workforce Analytics Per-tenant analytics from the S3 lake Rebuild from S3 CRR
S3 Services via presigned URLs Payslips, resumes, documents CRR with multi-region KMS key

Security groups enforce the connection rules: the MySQL group accepts 3306 only from the api-gateway pods.

Security

  • Accounts and network: AWS Organizations with separate accounts per cell, DR, shared services, security/log archive and non-prod; SCPs deny other regions, public RDS and switching off CloudTrail or GuardDuty. Data subnets have no route to the internet. Private EKS API, reached over Transit Gateway and SSM, never SSH bastions. Route 53 Resolver DNS Firewall allow-lists egress.
  • Edge and identity: WAF managed rules, per-tenant rate limits and Bot Control; punches on their own API Gateway with mutual TLS and per-site IP allow-lists; EKS Pod Identity; Secrets Manager with rotation; a KMS key per tenant so offboarding can crypto-shred.
  • Detect and prove: GuardDuty (EKS runtime, RDS, S3 malware scanning of resumes), Security Hub, Prisma Cloud CSPM, CloudTrail organization trail with S3 Object Lock, PII scrubbing in Sentry, Loki and AI prompts.
  • Pipeline: GitLab → Jenkins → SonarQube and Trivy → signed arm64 image in ECR → cell by cell, Singapore first, then UAE, then Mumbai.

AI with guard rails

  • In the product: HR copilot from the tenant’s own policies and read-only tool APIs; resume summaries after rChilli parsing (a recruiter decides); attendance anomaly flags; payroll pre-run variance checks.
  • In operations: a Grafana alert triggers the agent to gather Loki, Tempo and Sentry context and post a likely cause to Teams.
  • Cost control: a small model routes and answers most questions, a larger one only when needed; prompt and semantic caching; batch for overnight work; per-tenant token budgets from Superadmin.
  • UAE, limited by design: only rule-based checks run there. LLM features are off by default because several Bedrock models in the UAE are offered only through global cross-region inference. An SCP blocks Bedrock inference profiles, the DNS allow-list has no AI endpoints, and Superadmin can’t raise UAE tenants above the cell’s AI ceiling.

Cost flow (estimated, November 2026 prices)

Money flows from where it is spent, to what it buys, to the monthly total. Switch between list price and the same design after FinOps.

Per month Per user per month Per client per month
List price $42.5k (₹39.8 lakh) ₹19.9 ₹19,880
After FinOps $28.8k (₹26.9 lakh) ₹13.4 ₹13,450

Rupees at ₹93.5 per dollar. The biggest savings:

Measure Saving per month
AI model routing, caching and batch $5,057
New Relic on critical paths only $2,577
Savings Plans + RDS reservations $2,262
CloudFront flat-rate plan (WAF, DNS, DDoS included) $1,120
Atlas auto-scaling off-peak $527
Non-prod off nights and weekends $441
Valkey instead of Redis OSS $365
Redshift Serverless RPU caps $356

VPC interface endpoints cost about $330 a month more than the NAT charges they save at this traffic; they stay for privacy, trimmed to what each cell uses.

Read before using the numbers: list prices only, no negotiated discounts, GST excluded. UAE prices are scaled from Singapore because no current me-central-1 price list was published. Atlas uses MongoDB’s us-east-1 list plus an assumed regional uplift. Prisma Cloud, rChilli and SendGrid above 1.5M emails are placeholders for real quotes. Every line item and its price basis are on the full page.

FinOps and GreenOps

  • Graviton everywhere (EKS, RDS, ElastiCache, Lambda); Savings Plans and reservations for the baseline; Karpenter spot for the 9 AM punch peak and month-end payroll.
  • Warm standby kept at minimum size; non-prod scheduled off; S3 Intelligent-Tiering and lifecycle rules; 30/90-day Loki and Tempo retention on S3.
  • Unit cost per tenant from tags (tenant, cell, service, env) through CUR 2.0 into Grafana.
  • Kepler (CNCF) for energy per pod in Grafana, the AWS Customer Carbon Footprint Tool monthly, batch work moved into each cell’s night, and data deleted when its retention ends.

Starting sizes (confirm with a load test)

Component Mumbai Singapore UAE Hyderabad DR
EKS on-demand base 4 × m7g.2xlarge 3 × m7g.xlarge 3 × m7g.large 2 × m7g.xlarge
RDS MySQL db.r7g.2xlarge Multi-AZ + reader db.r7g.xlarge Multi-AZ db.r7g.large Multi-AZ db.r7g.xlarge replica
MongoDB Atlas M50: 2 Mumbai + 1 Pune M40, 3 nodes M30: 2 AWS + 3 Azure 2 × M50 nodes
Valkey 2 shards + replicas 1 shard + replica 1 shard + replica Global Datastore
Kafka 3 × m7g.xlarge 3 × m7g.large 3 × m7g.large 3 × m7g.large

Load assumptions: about 4 lakh punches a day (India’s 9:00–9:30 AM window averages about 50 a second, built for 500 a second bursts) and about 3,000 API requests a second at peak across all cells.

Decisions taken

  1. The UAE primary stays in me-central-1 on its healthy zones, keeping UAE data in the UAE. Clients move to AWS Saudi Arabia only after it has run stably for about three months, and only where contracts say “Middle East”.
  2. Azure UAE North holds UAE Atlas nodes and immutable backups.
  3. The other 30% of users are served from Singapore.
  4. India Atlas failover is automatic: 2 Mumbai + 2 Hyderabad + 1 Azure Pune, all in India.
  5. Feature flags use flagd fed by Superadmin.
  6. MongoDB runs on Atlas; New Relic covers critical paths only.

References

Spotted something wrong or out of date?Suggest a correction. I review every suggestion before changing the page.

EmailRSS