ADR-00019 — Dedicated pii-service vs. Duplicated Per-Service PII Handling
- Status: Approved / Implemented
- Date: 2026-10-01
- Authors: Engineering Team
Context
Seven real services today need to hold or resolve some piece of personal data — a warehouse contact, a shopper’s profile fields, a saved shipping address. Each of those services could, in principle, encrypt and store its own slice of PII next to its own domain data, the same way it already stores everything else it owns. The alternative is to centralize all of it behind one service that owns encryption, storage, and access logging, and require every consumer to go through it instead of touching PII at rest itself.
Decision Drivers (FRs & NFRs)
See SR-010 for the full requirement list.
- BR-03 (Auditability): an auditor must be able to answer “who accessed this person’s data, when, and which attribute” for any PII access across the whole platform, not per-service.
- FR-01 (gRPC-Only Surface): no HTTP/REST surface, no direct database access from any other service.
- FR-04 / FR-12 (Caller Attribution, Per-Call Audit Logging): every access is attributed to a specific calling service and transaction, and logged once.
- NFR-01 (Per-Service Encryption Key): a single, centrally managed encryption key per data class (PII vs. PCI).
Options Evaluated
Option 1 — One dedicated pii-service, gRPC-only, all consumers call it exclusively (CHOSEN)
pii-service is the sole owner of PII at rest. inventory-service, user-secure-engine, notification-service, user-preference-service, order-service, shipment-service, and shop-service each hold only a reference (an entity_id, a snapshot_id) in their own data store — never the PII content itself. No service has database credentials to pii-service’s schema, and pii-service exposes no HTTP endpoint at all (FR-01) — a gRPC call through its typed, audited RPCs is structurally the only way in or out.
- Pros:
- Single audit trail answers BR-03 directly.
row_attribute_audit_logrecordscaller_service,transaction_id,action,entity_type,entity_idfor every call, in one table, regardless of which of the seven consumers made it — answering “who/when/which service/what attribute” is one query, not a reconciliation across seven independent logging mechanisms in two different languages. - One encryption key, one rotation point, one place to harden.
PII_ENCRYPTION_KEYlives in exactly one service’s environment; a key rotation, a cipher upgrade, or a compliance review touches one codebase. - Structural access control, not policy. Because no consumer holds PII at rest or a database credential to reach it, “a service must not read another service’s PII directly” is enforced by the network topology itself — there is no code path by which
shipment-servicecould queryuser-secure-engine’s profile data even if it wanted to, since neither service stores it. - Consistent encryption practice is guaranteed, not hoped for. Every consumer goes through the same
RowAttributeServiceencrypt/decrypt path (see ADR-00020) — there is no risk of one team’s independent implementation reusing a nonce, logging a decrypted value, or skipping encryption under deadline pressure.
- Single audit trail answers BR-03 directly.
- Cons & Accepted Trade-offs:
pii-serviceis a single point of failure for every consumer’s PII-dependent request path — an outage here degradesinventory-service’s warehouse creation,order-service’s checkout address resolution, and five other services simultaneously, rather than each service’s own PII access failing independently.- Every PII read/write costs a network hop and a gRPC round trip instead of an in-process column read — accepted because compliance/audit guarantees outweigh this latency at today’s call volumes.
pii-service’s small, generic RPC surface (UpsertAttributes/GetAttributes/DeleteAttributes/CreateAddressSnapshots/GetAddressSnapshots) must keep serving every future consumer’s use case through those same five operations — a genuinely new access pattern (e.g. bulk export) requires extending this shared surface carefully rather than a service building its own local workaround.
Option 2 — Each service encrypts and stores its own PII independently
inventory-service adds its own encrypted warehouse_contact columns; user-secure-engine adds its own encrypted profile columns; user-preference-service encrypts address fields inline in its own Mongo documents; and so on — each with its own key, its own audit mechanism, no shared code.
- Pros:
- No cross-service network hop — PII read/write is as fast as any other local query.
- No single point of failure across services — one service’s PII storage outage doesn’t affect another’s.
- Cons (Why Rejected):
- BR-03’s audit requirement becomes a reconciliation problem. Answering “who accessed this person’s data” platform-wide means correlating N independently-designed logging mechanisms across Go, Rust, and Node — some of which might not log PII access distinctly from any other database read at all.
- No structural barrier stops a service from reading another service’s PII. If
shipment-serviceandorder-serviceboth store address data locally, nothing but code review prevents one from querying the other’s table directly if they ever shared a database or a careless migration exposed it — the access boundary becomes a policy to enforce, not a fact about the network. - Encryption practice drifts by team, not by design. One service’s deadline-pressured implementation could reuse a nonce, decrypt-and-log a value for debugging, or skip encryption for a field someone didn’t recognize as PII — there is no single place this is guaranteed correct, unlike Option 1’s one shared encryption path.
- N independent key-management stories instead of one. Each service’s own encryption key needs its own rotation process, its own secret-storage wiring, and its own compliance sign-off — multiplying the operational surface that NFR-01 has to cover.
Final Decision
Option 1 is selected. Centralizing PII behind one gRPC-only pii-service turns BR-03’s audit requirement into a single, always-consistent log instead of a cross-service reconciliation problem, and makes “no service may access PII it doesn’t own” a structural fact (no database credential, no HTTP endpoint, only a typed and audited RPC) rather than a convention every team has to independently uphold. The single-point-of-failure and added-latency costs are accepted as the price of that guarantee, and are mitigated the same way any other critical internal dependency in this platform is — not by abandoning centralization.
Related Documents
- BRD-009 — Centralized Personal Information Store
- SR-010 — Centralized Personal Information Store System Requirements
- ADR-00018 — Row-Based Encrypted Attribute Model, Value-Level Encryption, and the Address-Snapshot Exception
- ADR-00020 — Shared Core-Lib Encryption/Audit/CRUD Pattern vs. In-Service Implementation
- ADR-00021 — PostgreSQL vs. MongoDB for pii-service’s Data Store
- Architecture: Centralized Personal Information Store
- Microservices: pii-service