Multi-Region Design
PPP holds sensitive medical data — surgical logbooks, CPD records, wellness assessments, 360 reviews — for doctors in multiple jurisdictions. UK data-protection law and Australian privacy law both pull us towards data sovereignty: UK doctor data stays in the UK, Australian doctor data stays in Australia, and there is no cross-border replication.
This page documents where we are today and where the design is going. For the concrete Azure resources see Azure Infrastructure.
Current State (as of UK launch)
PPP is single-region today. Both the ppp-uk-uat and ppp-uk-prod Pulumi stacks deploy to uksouth (Azure UK South — London). There is no Australian Azure deployment, no cross-region replication, and no region-routing layer in front of the API.
| What exists | Where |
|---|---|
| UAT Azure stack | api/infra-azure/Pulumi.ppp-uk-uat.yaml → azure-native:location: uksouth |
| Production Azure stack | api/infra-azure/Pulumi.ppp-uk-prod.yaml → azure-native:location: uksouth |
| Cloudflare DNS and Pages | pppUat and pppProd stacks under api/infra-cloudflare/ |
| AU-region Pulumi stacks | Not created |
| Region-aware routing at the edge | Not configured |
| Grafana cross-region dashboard | Not created |
Australian and UK doctors who sign up today both read and write to the same UK South PostgreSQL instance. This is a known, explicit trade-off: the platform is pre-revenue and the compliance obligation for Australian data residency is deferred until there is a live Australian customer base to justify the extra operating cost.
Target Design
The target architecture is two fully isolated regional deployments — one in UK South, one in Australia East — fronted by Cloudflare, with no cross-region application traffic and no shared data plane.
Regions
| Region | Azure region | Doctors | Primary compliance driver |
|---|---|---|---|
| UK | UK South (London) | UK-registered (GMC) | UK GDPR, ISO 27001, UK G-Cloud |
| Australia | Australia East (Sydney) | AU-registered (AHPRA) | Australian Privacy Act, IRAP Protected |
Both Azure regions hold the ISO 27001 / SOC 2 Type II certifications required by the compliance posture; UK South adds UK G-Cloud and Australia East adds IRAP Protected.
Isolation Model
Data sovereignty is enforced at the infrastructure layer, not at the application layer. Each region is a fully independent deployment that shares nothing but the Cloudflare edge in front of it.
- Separate Pulumi stacks. A new region is a new pair of stacks (
ppp-au-uat,ppp-au-prod) with their own config, their own state, and no stack references crossing regions. - Separate resource groups. Per-environment resource groups named
ppp-uk-<env>andppp-au-<env>. - Separate databases. Each region gets its own PostgreSQL Flexible Server. No replication between them.
- Separate storage accounts. Each region gets its own Blob Storage account in Locally Redundant Storage (LRS) — deliberately not geo-redundant — so writes cannot leak cross-region.
- Region-locked Container Apps. A Container App in UK South can only reach the UK South database and storage; same for AU East. There is no code path that points at the other region.
- No shared secrets. Each Key Vault is region-scoped and each region's secrets rotate independently.
Routing
The current thinking is to route at signup, not per-request:
- The signup flow asks the doctor for their primary registration body (GMC, AHPRA, GMC + AHPRA, other).
- Registration bodies map 1:1 to regions.
- After signup the user is redirected to the region-specific subdomain (e.g.
au.professionalperformanceportfolio.com), and their session is bound to that region for life. - Cloudflare routes each regional subdomain to the matching
api-<region>-<env>Container App.
This keeps the routing logic simple and auditable — a user only ever sees one region's data — and avoids the need for a region-aware edge proxy or a global database layer.
Cross-Region Reporting (target)
Super-admin dashboards will need a cross-region view (overall adoption, revenue, feature usage) without violating data sovereignty. The design calls for Grafana Cloud with strictly anonymized data. Neither the Grafana stack nor the grafana_* views exist today — this section describes the intended approach when the AU region lands:
- Anonymized database views. Each regional database exposes
grafana_*views containing only aggregates — counts, sums, durations, week/month buckets. Zero PII and no row-level data. - Read-only Postgres user. Each region has a
grafana_readerrole withSELECTongrafana_*only. - Direct regional datasources. Grafana Cloud connects to each regional database over TLS and queries the anonymized views directly — no ETL, no aggregation outside the region.
- Side-by-side panels. The
ppp-metricsdashboard renders UK and AU data in parallel panels so the super admin can see both regions at a glance without either region's rows ever mixing.
Example anonymized view shape (the real DDL lives with the migrations):
CREATE VIEW grafana_adoption_metrics AS
SELECT
date_trunc('month', created_at) AS month,
country_code,
COUNT(*) AS new_users,
COUNT(*) FILTER (WHERE account_type = 'cpd') AS cpd_subscribers,
COUNT(*) FILTER (WHERE account_type = 'ppp') AS ppp_subscribers
FROM ppp_user
GROUP BY 1, 2;Every new analytics dashboard has to land as a grafana_* view in both regional databases before it can be wired into Grafana — this keeps the "no PII crosses regions" rule enforceable in code review.
Migration Sequence
When there is a business case for the Australian region, the rollout will be staged so the UK deployment is never at risk:
- Stack scaffolding. New
ppp-au-uat/ppp-au-prodstack configs underapi/infra-azure/, parameterised off the existing UK stacks. - AU UAT provision.
pulumi upagainstppp-au-uat— Container App, PostgreSQL, Blob, Key Vault, Managed Identity, Log Analytics, ACS (Australia data location). - AU routing. New Cloudflare DNS records and Pages bindings for the
au.subdomain; region-selection UI on the signup page; region-bound sessions in Better Auth. - AU Prod provision.
pulumi upagainstppp-au-prod, followed by end-to-end smoke tests in region. - Grafana cross-region dashboards. Add the AU PostgreSQL datasource to the Grafana stack, create the
ppp-metricspanels, and verify zero PII. - Onboard AU doctors. Marketing to AHPRA-registered doctors, supported by the new regional onboarding flow.
The application code is already country-agnostic — no country-specific SQL, no hard-coded region strings, no tenancy assumptions in the service layer. The primary unknown is the regulatory sign-off (IRAP Protected, Australian Privacy Act attestations) that has to run alongside the technical work.
Why Not Geo-Replicated PostgreSQL?
Two reasons:
- Data sovereignty. Azure's geo-redundant PostgreSQL replicates across Azure geographies (e.g. UK South → UK West). Cross-region replication between UK and AU would push UK patient data through an AU region (or vice versa) at least transiently — that's the exact thing the sovereignty model is built to prevent.
- Cost and operational complexity. Cross-region replication doubles the database footprint and introduces lag that user-facing queries would have to work around. For a pre-revenue platform with a clean signup-routed model, two fully independent databases are simpler, cheaper, and legally defensible.
Related Pages
- System Overview — full end-to-end data flow
- Azure Infrastructure — concrete Azure resources per environment
- Timesheets feature spec — location-bound data that is especially sensitive to region routing
- Mobile feature spec — mobile clients will hit the same region-routed API