Compliance Architecture — Technical Documentation

DATA FLOW
DIAGRAM

Version 2.1 — August 2026

This document describes how PII, PHI, and regulated data moves through the RGX Systems Compliance Engine across all five supported industries: healthcare (PHI/HIPAA), legal (privilege & output validation), finance (PCI/financial identifiers), professional_services (EIN/SSN/banking), and real_estate (standard PII). Sensitive data is scrubbed exclusively in-memory before any LLM call or database write. Raw regulated data is never persisted.

Zero-Leakage Architecture

Architecture guarantee: Regulated data (PII, PHI, financial identifiers) is intercepted and anonymized entirely within the RGX gateway — in-memory, before any LLM call is made and before any database write occurs. The LLM provider never receives raw regulated data. No plaintext regulated fields are ever persisted to storage. What follows is the full technical decomposition of each stage.

┌─────────────────────────────────────────────────────────────────────────┐
│                    ZERO-LEAKAGE ARCHITECTURE                            │
│                  RGX AI Data Leakage Protection Layer                   │
└─────────────────────────────────────────────────────────────────────────┘

  ┌──────────────────┐
  │  PARTNER CLIENT  │  Protected request — payload may contain raw
  │   APPLICATION    │  PII, PHI, or financial identifiers
  └────────┬─────────┘
           │  HTTPS / TLS 1.3  (raw regulated data encrypted in transit)
           ▼
  ┌──────────────────────────────────────────────────────────────────────┐
  │              RGX PROTECTION LAYER — INTERCEPTS & SCRUBS PII         │
  │                                                                      │
  │  1. Security token verified (SHA-256 hash only — plaintext never    │
  │     stored)                                                          │
  │  2. Workspace resolved — isolated data context enforced              │
  │  3. Industry compliance profile loaded (healthcare / legal /         │
  │     finance / professional_services / real_estate)                   │
  │  4. Compliance Engine runs ENTIRELY IN-MEMORY:                      │
  │     • Regex patterns scan for HIPAA identifiers, SSNs, EINs,       │
  │       MRNs, NPIs, card numbers, financial account numbers, etc.     │
  │     • Each match replaced with numbered token:                       │
  │       {{REDACTED_PHI_1}}  {{REDACTED_FIN_2}}  {{REDACTED_LEG_3}}  │
  │     • Original PHI string goes out of scope — garbage-collected     │
  │     • ZERO disk / database / log writes of raw regulated data       │
  │  5. Compliance audit event written non-blockingly:                  │
  │     tenant_id · seat_id · redaction_count · pattern_types (no PHI) │
  └──────────────┬───────────────────────────────────────────────────────┘
                 │
                 ├────────────────────────────────────────────────┐
                 ▼                                                │
  ┌──────────────────────────────┐           ┌─────────────────────────────┐
  │  ISOLATED WORKSPACE          │           │  RAW PHI — DISCARDED        │
  │  PIPELINE (per-workspace)    │           │                             │
  │                              │           │  Original input variable     │
  │  Scrubbed payload routed     │           │  is garbage-collected by     │
  │  to LLM via workspace        │           │  Node.js runtime. No write  │
  │  context. Data never bleeds  │           │  to disk, DB, log, or any   │
  │  across workspace boundaries │           │  external service occurs.   │
  └──────────────┬───────────────┘           └─────────────────────────────┘
                 │
                 ▼  ANONYMIZED PAYLOAD SENT TO LLM
  ┌──────────────────────────────────────────────────────────────────────┐
  │                        LLM PROVIDER (Anthropic)                      │
  │                                                                      │
  │  Receives ONLY scrubbed text — {{REDACTED_PHI_1}} tokens, not       │
  │  original values. LLM provider DPA prohibits model training on       │
  │  submitted data. Raw PHI never reaches this layer.                   │
  └──────────────┬───────────────────────────────────────────────────────┘
                 │
                 ▼  SAFE RESPONSE RETURNED
  ┌──────────────────────────────────────────────────────────────────────┐
  │              RESPONSE RETURNED TO PARTNER APPLICATION                │
  │                                                                      │
  │  LLM response contains token labels (not original PHI values).       │
  │  Partner may optionally de-tokenize client-side using the token map  │
  │  returned with the response. RGX does not log                       │
  │  AI response content to persistent storage.                          │
  └──────────────────────────────────────────────────────────────────────┘

  ENCRYPTION:      AES-256-GCM at rest  ·  TLS 1.3 in transit
  SECURITY TOKENS:  SHA-256 hashed — plaintext never stored
  WORKSPACE DATA:   Query-layer isolation — no cross-workspace access possible
    
Partner / External System
RGX Proxy (Render)
LLM Provider
Data Discarded (no write)
Database (no PHI)

Processing Flow — Step by Step

01
Partner’s Application
Client sends request containing PHI
The partner’s application sends a protected request with config.industry: "healthcare". The request body may contain raw PHI: patient text, SSNs, DOBs, MRNs, addresses. The payload is encrypted in transit via TLS 1.3. The partner’s Workspace Security Token is verified before any payload is read.
HTTPS / TLS 1.3 — raw PHI in encrypted transit
02
RGX Protection Layer — Render Infrastructure
Request received, security token authenticated
The request lands on the RGX Node.js/Express process running on Render. The X-Api-Key header carrying the Workspace Security Token is verified against a SHA-256 hash in PostgreSQL. The payload (including any PHI) is held in-process memory only — no disk write occurs at this stage.
In-process memory handoff — no I/O
03
Compliance Engine — In-Memory, No Disk Write
PHI identified and redacted before any persistence or LLM call
The Compliance Engine runs entirely in RAM. It scans the input string using regex patterns for HIPAA identifiers and replaces each match with a sequentially numbered token. The original PHI values are overwritten in the variable — they are not written to any file, database, queue, or external service.
Pattern
SSN (dashed & bare)
Original
123-45-6789
After Scrub
{{REDACTED_PHI_1}}
Pattern
Date of Birth
Original
DOB: 03/15/1972
After Scrub
{{REDACTED_PHI_2}}
Pattern
Medical Record Number
Original
MRN: A4839201
After Scrub
{{REDACTED_PHI_3}}
Pattern
Insurance / Member ID
Original
Member ID: BCX-992847
After Scrub
{{REDACTED_PHI_4}}
Pattern
US Phone Numbers
Original
(555) 214-8832
After Scrub
{{REDACTED_PHI_5}}
Pattern
Email Addresses
Original
patient@example.com
After Scrub
{{REDACTED_PHI_6}}
Pattern
NPI
Original
NPI: 1234567890
After Scrub
{{REDACTED_PHI_7}}
Pattern
Street Address
Original
142 Maple Street
After Scrub
{{REDACTED_PHI_8}}
Pattern
ZIP Codes
Original
90210
After Scrub
{{REDACTED_PHI_9}}
Pattern
Person Name
Original
Margaret Chen
After Scrub
[NAME_1]
Separate pass, same in-memory guarantee
Name Tokenizer — TokenProxy, Every Industry
Person names tokenized independently of the PHI/PII patterns above
Names are not part of the Compliance Engine's pattern set above — they're detected and replaced separately, as [NAME_1], [NAME_2], etc. This step runs for every industry, including real_estate, which has no PHI/PII pattern ruleset of its own. Unlike the PHI/PII tokens above, a name token can be reversed — using a mapping held only in this process's memory, scoped to the request's session_id, and purged after 30 minutes of inactivity. That mapping is never written to disk, logs, or the database. On the RGX-hosted path, reversal happens automatically (see the Response step below). In Passthrough Mode (see below), reversal is not automatic — RGX never sees the partner's own model's response — but the same mapping stays available for that session_id, resolvable on request via POST /process/rehydrate.
Two outputs: redacted text (used) — raw PHI string (discarded)
Raw PHI — Discarded
Original PHI string garbage-collected
The original input variable containing PHI goes out of scope and is garbage-collected by the Node.js runtime. No write to disk, database, log file, or external service occurs. The PHI exists only for the duration of the scrub function’s execution.
LLM Provider — Anthropic / OpenAI
Redacted text sent via HTTPS — no PHI, no names
Only the scrubbed string (containing {{REDACTED_PHI_1}}-style and [NAME_1]-style tokens, not original values) is sent to the LLM provider. The LLM provider never receives raw PHI or a raw name. Anthropic and OpenAI operate under data processing agreements with RGX Systems prohibiting use of submitted data for model training.
LLM response (no PHI) returned to RGX proxy
Post-Processing (legal industry only)
Legal disclaimer appended if industry = legal
For the legal industry profile, output is validated for directive language and a mandatory disclaimer is appended. For healthcare, finance, professional services, and real estate, the LLM response passes through without modification.
PostgreSQL on Render — No PHI Written
Usage metadata logged — content never stored
A usage record is written containing: workspace ID, token ID, endpoint, HTTP method, payload size in bytes, message count, processing time, token counts, estimated cost, status code, source IP, and redaction counts. The actual message text — neither original nor scrubbed — is written to the database.
Name tokens rehydrated, then final response returned
04
Partner’s Application — Response
Names restored, AI-generated response delivered to partner
Before the response is returned, any [NAME_N] token the model echoed back is swapped for the real name using the Name Tokenizer's in-memory mapping (above) — the partner sees the real name normally; only the LLM provider never did. The partner receives a JSON response containing the AI output, token counts, processing time, model used, and a redactions count confirming how many PHI/PII patterns and names were scrubbed in total. The response includes the liability_disclaimer field and, where applicable, legal warnings. No raw PHI or PII is present in the response payload.
Alternative: passthrough mode, no LLM call by RGX
Passthrough Mode — Bring Your Own AI
passthrough: true skips steps 04–05 above entirely
When the request includes passthrough: true, RGX never reaches the LLM Provider step: the scrubbed-and-name-tokenized text from steps 03 and 03b is returned directly to the partner as scrubbed_input, for the partner to send to their own model. Because RGX never sees that model's response, name tokens are not reversed automatically in this mode — the partner receives literal [NAME_N] text. If the finished response needs the real name restored, the partner calls POST /process/rehydrate with the same session_id plus the model's output text, and RGX resolves any [NAME_N] tokens against the same in-memory mapping — still without the name ever reaching a model. Everything about PHI/PII handling (in-memory only, zero persistence, per-industry ruleset) is identical to the RGX-hosted path above.

Key Security Properties

PHI Persistence
None. Raw PHI is never written to any database, log file, message queue, or external service. It exists only in process memory for the duration of the scrub operation.
LLM Exposure
None. LLM providers (Anthropic, OpenAI) receive only the scrubbed/redacted text. PHI values are replaced with bracketed labels before any network call.
Encryption in Transit
TLS 1.3 for all traffic (Partner → RGX, RGX → LLM provider). HTTPS enforced; HTTP requests are rejected.
Encryption at Rest
AES-256-GCM for sensitive configuration data. Render’s PostgreSQL instances use encrypted volumes. Security tokens are SHA-256 hashed; plaintext tokens are never stored.
Database Contents (PHI-related)
Payload size in bytes, redaction count (integer), redaction pattern types (e.g., “ssn”, “dob”), token counts, processing time. No PHI values, no message text, no patient identifiers.
Infrastructure Provider
Render Services, Inc. — SOC 2 Type II certified, HIPAA BAA available and executed with RGX Systems. All compute and database runs within Render’s US-region infrastructure on AWS.
LLM Provider BAA
Anthropic, PBC — operates under a data processing agreement with RGX Systems. Does not use submitted data for model training. Does not receive raw PHI (scrubbed before transmission).
Data Retention
Usage metadata (no PHI) retained for 12 months for billing and audit. Monthly billing aggregates retained 7 years per financial regulations. PHI: zero retention (not stored).
Zero-Retention Purge
The workspace purge endpoint permanently and irreversibly deletes all data associated with a client workspace. Confirmed in writing on request.
Access Controls
Production system access restricted to authorised RGX Systems personnel. Multi-factor authentication required. Access log maintained. Role-based permissions enforced at the database level.
Breach Notification
RGX Systems will notify the covered partner/MSP within 72 hours of becoming aware of any impermissible use or disclosure of PHI, per the signed BAA and 45 CFR §164.410.

Note on the inbound webhook endpoint: The public inbound webhook receiver stores a truncated body preview (first 500 characters) for webhook event logging. Partners should not route raw PHI through the inbound webhook endpoint. PHI should only be submitted through the authenticated protection gateway, where scrubbing is enforced.

Partner responsibility: RGX Systems scrubs PHI from input submitted through the protection gateway. Partners are responsible for ensuring that their applications only transmit PHI through the authenticated gateway endpoints, and that their own systems (front-end UI, local databases, logs) comply with applicable HIPAA obligations. RGX Systems’ scrubbing does not substitute for the partner’s independent HIPAA compliance obligations toward its own clients.

Supporting Documents

Business Associate Agreement
rgxsystems.com/baa — HIPAA BAA for partners serving healthcare clients. Contact legal@rgxsystems.com to execute.
Privacy Policy
rgxsystems.com/privacy-policy — Full data collection and retention policy including PHI handling.
Data Processing Agreement
rgxsystems.com/dpa — GDPR/CCPA-aligned DPA for partners with EU or California clients.
Security Overview
rgxsystems.com/security — Infrastructure security, encryption, and access control details.
Security Questionnaires
Contact security@rgxsystems.com to complete a vendor security questionnaire or request pen test documentation.