Architecture: Centralized Personal Information Store
By Engineering Team•October 1, 2026•7 min read
This is the architecture behind the decisions recorded in ADR-00018 (row-based attribute model), ADR-00019 (dedicated service vs. per-service duplication), ADR-00020 (shared core-lib implementation), and ADR-00021 (PostgreSQL vs. MongoDB), satisfying the requirements in BRD-009 and SR-010.
Diagram

Components
| Component | Language / Runtime | Role |
|---|---|---|
pii-service |
Rust | gRPC-only encrypted attribute store — UpsertAttributes/GetAttributes/DeleteAttributes for the generic EAV model, CreateAddressSnapshots/GetAddressSnapshots for the address-dedup model (FR-01). |
rust-lang-core-lib’s domain::encrypt/service::encrypt/repository::encrypt |
Rust (shared library) | Owns the generic RowAttributeService (validate → AES-256-GCM encrypt/decrypt → repository call → audit-log write), shared byte-for-byte with pci-service (FR-02, FR-03, FR-12, NFR-02). |
PostgreSQL — "pii-service" schema |
PostgreSQL | user_pii_attributes (generic EAV rows), address_snapshots (dedup parent, unique (tenant_id, created_user_id, content_hash)), address_snapshot_attributes (encrypted child rows, reusing the shared write path), row_attribute_audit_log (FR-02, FR-06, FR-07, FR-12). |
inventory-service |
Go | Writes warehouse contact details under entity_type="warehouse" on CreateWarehouse, with a best-effort compensating delete of its own row if the PII write fails (FR-05; gap — see TD-01). |
user-secure-engine |
Rust | Writes/reads profile fields (full_name, email, phone_number, dob, gender) under entity_type="user_personal" on account init and profile update (FR-05). |
notification-service |
Rust | Same PII client pattern as user-secure-engine, wired into a live UserService gRPC surface — its caller_service attribution is currently incorrect (FR-04; gap — see TD-02). |
user-preference-service |
Go | Write-only: pushes a customer’s shipping/billing address bodies under entity_type="user_address" on every address add/update, never storing address content in its own Mongo collection (FR-05). |
order-service |
Go | Reader of entity_type="user_address" (resolving a shopper’s saved address at checkout) and writer/reader of the separate "address.xxx"-prefixed attribute-key namespace via CreateAddressSnapshots/GetAddressSnapshots — stores only AddressSnapshotRef{address_type, snapshot_id} in its own checkout-saga data, never raw address content (FR-05, FR-06). |
shipment-service |
Go | Reads one address snapshot at a time (GetAddressSnapshot, singular) for fulfillment/label generation (FR-10). |
shop-service |
Go | Reads address snapshots in batch (GetAddressSnapshots, plural) for order detail/display (FR-10). |
End-to-end flow (A) — generic attribute write and read
This flow covers any of the three non-address writer/reader paths (inventory-service’s warehouse contact, user-secure-engine’s/notification-service’s user_personal profile fields, user-preference-service’s user_address bodies).
- The consuming service performs its own local write first (e.g.
inventory-serviceinserts the new warehouse’s Postgres row) (NFR-03). - It calls
pii-service’sUpsertAttributeswithcaller_service, a freshtransaction_id, its own chosenentity_type("warehouse"/"user_personal"/"user_address"),entity_id, and the attribute list —tenant_id/user_id/roletravel as gRPC metadata, never in the payload (FR-01, FR-02, FR-04, FR-05, FR-11, NFR-07). rust-lang-core-lib’s sharedRowAttributeServicevalidates the input, encrypts eachplaintext_valuewith AES-256-GCM and a fresh random nonce, and persists it touser_pii_attributesunder the"pii-service"schema (FR-02, FR-03, NFR-01, NFR-02).- The same call writes one
row_attribute_audit_logentry recordingcaller_service,transaction_id,action,entity_type,entity_id(FR-12). - If step 2/3 fails after step 1 succeeded, the caller compensates by rolling back its own local write —
inventory-service’sCreateWarehouseis the only verified implementation of this today, and its compensating delete is itself best-effort (NFR-03; gap — see TD-01). - A later read calls
GetAttributeswith the knownrequested_attributeskey list;pii-servicedecrypts only inside this call and returns adecrypted_attributesmap — a decrypted value is never written to a log line (FR-03).
End-to-end flow (B) — address snapshot at checkout
- At checkout,
order-servicecallsGetAttributesagainstentity_type="user_address"to resolve the shopper’s saved address — the same namespaceuser-preference-servicewrites to (FR-02, FR-05). order-servicebuilds its own"address.xxx"-prefixed attribute set for the shipping and/or billing address and callsCreateAddressSnapshotswith one address block per type (FR-06).- For each block,
pii-servicesorts its attributes byattribute_key, computes a SHA-256 hex digest ofkey=trimmed_lowercased_value\nper attribute, and combines them into onecontent_hash(FR-07). - It looks up
(tenant_id, created_user_id, content_hash)inaddress_snapshots: a match reuses the existingsnapshot_id(is_new_snapshot: false); no match inserts a newaddress_snapshotsrow and writes its attributes toaddress_snapshot_attributesvia the same shared encrypted write path as Flow A, withentity_typehardcoded to"address"andentity_idset to the new snapshot’s UUID (FR-06, FR-07, FR-08). - A concurrent call racing for the same
(tenant_id, created_user_id, content_hash)has its unique-constraint violation detected; the losing request re-fetches the winning row’ssnapshot_idinstead of writing orphaned child attribute rows (FR-09). pii-servicereturnssnapshot_results[{address_type, snapshot_id, is_new_snapshot}];order-servicepersists onlyAddressSnapshotRef{address_type, snapshot_id}on its checkout-saga data — never the raw address content (FR-06).- Later,
shipment-serviceresolves one snapshot at a time (GetAddressSnapshot) for fulfillment/label generation, andshop-serviceresolves snapshots in batch (GetAddressSnapshots) for order detail/display — both decrypt via the"address.xxx"keysorder-serviceoriginally wrote, bypassing the genericGetAttributesread path (which requires a known key list) in favor of a local lookup-by-entity_idplus a second, directly-instantiated cipher (FR-10). - Every call in this flow — including a snapshot lookup that reuses an existing snapshot via dedup — writes its own
row_attribute_audit_logentry the same way Flow A’s step 4 does (FR-12).
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-00019 — Dedicated pii-service vs. Duplicated Per-Service PII Handling
- ADR-00020 — Shared Core-Lib Encryption/Audit/CRUD Pattern vs. In-Service Implementation
- ADR-00021 — PostgreSQL vs. MongoDB for pii-service’s Data Store
- Technical Debt — Centralized Personal Information Store Gaps
- Microservices: pii-service, inventory-service